From 5855b361164dc9deebd2a338dad938ae3e38f619 Mon Sep 17 00:00:00 2001 From: Chris Mackey Date: Wed, 3 Jul 2024 11:22:10 -0700 Subject: [PATCH 1/3] fix(cli): Encode VTKJS file contents as base64 string I'm also doing a lot of other updates to the CI. --- .dockerignore | 5 +++++ .github/workflows/ci.yaml | 8 ++++---- .releaserc.json | 7 +++++++ honeybee_display/attr.py | 2 +- honeybee_display/cli/__init__.py | 5 ++++- honeybee_display/colorobj.py | 2 +- honeybee_display/model.py | 2 +- setup.py | 1 + 8 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..02639e5 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +.github +docs +tests + +Dockerfile diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7471fda..96a9c7d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -40,9 +40,9 @@ jobs: with: python-version: 3.7 - name: set up node # we need node for for semantic release - uses: actions/setup-node@v2.1.2 + uses: actions/setup-node@v4 with: - node-version: 14.2.0 + node-version: 22.2.0 - name: install python dependencies run: | python -m pip install --upgrade pip @@ -54,8 +54,8 @@ jobs: - name: run semantic release id: new_release run: | - nextRelease="`npx semantic-release@^17.0.0 --dryRun | grep -oP 'Published release \K.*? ' || true`" - npx semantic-release@^17.0.0 + nextRelease="`npx semantic-release@^23.1.1 --dryRun | grep -oP 'Published release \K.*? ' || true`" + npx semantic-release@^23.1.1 echo "::set-output name=tag::$nextRelease" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.releaserc.json b/.releaserc.json index 1030a39..692bd0d 100644 --- a/.releaserc.json +++ b/.releaserc.json @@ -3,6 +3,13 @@ "@semantic-release/commit-analyzer", "@semantic-release/release-notes-generator", "@semantic-release/github", + [ + "@semantic-release/github", + { + "successComment": false, + "failTitle": false + } + ], [ "@semantic-release/exec", { diff --git a/honeybee_display/attr.py b/honeybee_display/attr.py index f0f56a8..bba513f 100644 --- a/honeybee_display/attr.py +++ b/honeybee_display/attr.py @@ -114,7 +114,7 @@ class FaceAttribute(RoomAttribute): boundary_conditions: List of face boundary conditions to be included in the visualization set. This condition will be applied as a secondary check for - the face_types that are set using the face_types argument. Valid values + the face_types that are set using the face_types argument. Valid values are: * Outdoors diff --git a/honeybee_display/cli/__init__.py b/honeybee_display/cli/__init__.py index 4743092..767e00e 100644 --- a/honeybee_display/cli/__init__.py +++ b/honeybee_display/cli/__init__.py @@ -4,6 +4,7 @@ import os import logging import json +import base64 import pickle import tempfile import uuid @@ -198,7 +199,9 @@ def model_to_vis_set( else: # vtkjs can only be read as binary with open(out_file_path, 'rb') as of: f_contents = of.read() - output_file.write(f_contents) + b = base64.b64encode(f_contents) + base64_string = b.decode('utf-8') + output_file.write(base64_string) else: raise ValueError('Unrecognized output-format "{}".'.format(output_format)) except Exception as e: diff --git a/honeybee_display/colorobj.py b/honeybee_display/colorobj.py index 7556691..064bb8f 100644 --- a/honeybee_display/colorobj.py +++ b/honeybee_display/colorobj.py @@ -195,7 +195,7 @@ def color_face_to_vis_set( else: m_vec = base_plane.y if base_plane.n.z < 0 else -base_plane.y base_plane = base_plane.move(m_vec * txt_h) - else: #it's a Mesh3D + else: # it's a Mesh3D base_plane = Plane(Vector3D(0, 0, 1), f_geo.center) # create the text label label = DisplayText3D( diff --git a/honeybee_display/model.py b/honeybee_display/model.py index f59f3f3..fec42f0 100644 --- a/honeybee_display/model.py +++ b/honeybee_display/model.py @@ -6,7 +6,7 @@ from ladybug.datatype.generic import GenericType from ladybug.color import Color from ladybug_display.geometry3d import DisplayPoint3D, DisplayLineSegment3D, \ - DisplayPolyline3D, DisplayFace3D, DisplayMesh3D + DisplayFace3D, DisplayMesh3D from ladybug_display.visualization import VisualizationSet, ContextGeometry, \ AnalysisGeometry, VisualizationData, VisualizationMetaData from honeybee.boundarycondition import Outdoors, Ground, Surface diff --git a/setup.py b/setup.py index 6934bfd..0374e6c 100644 --- a/setup.py +++ b/setup.py @@ -30,6 +30,7 @@ classifiers=[ "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.10", "Programming Language :: Python :: Implementation :: CPython", "License :: OSI Approved :: GNU Affero General Public License v3", "Operating System :: OS Independent" From bc0684086a85fbedac5f33593afd6e5f12f3aadc Mon Sep 17 00:00:00 2001 From: Chris Mackey Date: Wed, 3 Jul 2024 11:35:01 -0700 Subject: [PATCH 2/3] fix(model): Ensure that UTF-8 encoding is always used --- honeybee_display/model.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/honeybee_display/model.py b/honeybee_display/model.py index fec42f0..2c55d69 100644 --- a/honeybee_display/model.py +++ b/honeybee_display/model.py @@ -1,6 +1,7 @@ """Method to translate a Model to a VisualizationSet.""" import os import json +import io from ladybug_geometry.geometry3d import Point3D, Face3D from ladybug.datatype.generic import GenericType @@ -384,7 +385,7 @@ def model_to_vis_set( g_values = _read_sensor_grid_result(g_dir) meta_file = os.path.join(g_dir, 'vis_metadata.json') if os.path.isfile(meta_file): - with open(meta_file, 'r') as mf: + with io.open(meta_file, 'r', encoding='utf-8') as mf: m_data = json.load(mf) gm_data = VisualizationMetaData.from_dict(m_data) v_data = VisualizationData( @@ -398,7 +399,7 @@ def model_to_vis_set( # create the analysis geometry if len(data_sets) != 0: ex_gi_file = os.path.join(gi_dirs[0], gi_file) - with open(ex_gi_file) as json_file: + with io.open(ex_gi_file, encoding='utf-8') as json_file: grid_list = json.load(json_file) grid_objs = [grids[g['full_id']] for g in grid_list] grid_meshes = [g.mesh for g in grid_objs] @@ -487,7 +488,7 @@ def _read_sensor_grid_result(result_folder): raise ValueError('Result folder contains no grids_info.json.') # load the list of grids and gather all of the results - with open(grid_json) as json_file: + with io.open(grid_json, encoding='utf-8') as json_file: grid_list = json.load(json_file) results = [] for grid in grid_list: @@ -510,14 +511,14 @@ def _read_sensor_grid_result(result_folder): 'Loading results for {} with {} sensors. ' 'Starting from line {}.'.format(grid_id, sensor_count, st_ln) ) - with open(result_file) as inf: + with io.open(result_file, encoding='utf-8') as inf: for _ in range(st_ln): next(inf) for count in range(sensor_count): try: value = float(next(inf)) except (StopIteration, ValueError): - with open(result_file, 'r') as rf: + with io.open(result_file, 'r', encoding='utf-8') as rf: content = rf.read() ln_count = len(content.split()) raise ValueError( From 251aa4a1cef9e6804b0b4af7362199722c4d2c6a Mon Sep 17 00:00:00 2001 From: Chris Mackey Date: Wed, 3 Jul 2024 12:22:28 -0700 Subject: [PATCH 3/3] fix(cli): Ensure that HTML can still be written to stdout --- extras-requirements.txt | 2 +- honeybee_display/cli/__init__.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/extras-requirements.txt b/extras-requirements.txt index 5545434..b07a27f 100644 --- a/extras-requirements.txt +++ b/extras-requirements.txt @@ -1,3 +1,3 @@ honeybee-energy>=1.95.35 honeybee-radiance>=1.64.118 -ladybug-vtk>=0.13.9 +ladybug-vtk>=0.14.1 diff --git a/honeybee_display/cli/__init__.py b/honeybee_display/cli/__init__.py index 767e00e..a3ab19a 100644 --- a/honeybee_display/cli/__init__.py +++ b/honeybee_display/cli/__init__.py @@ -199,9 +199,9 @@ def model_to_vis_set( else: # vtkjs can only be read as binary with open(out_file_path, 'rb') as of: f_contents = of.read() - b = base64.b64encode(f_contents) - base64_string = b.decode('utf-8') - output_file.write(base64_string) + b = base64.b64encode(f_contents) + f_contents = b.decode('utf-8') + output_file.write(f_contents) else: raise ValueError('Unrecognized output-format "{}".'.format(output_format)) except Exception as e: