Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): Encode VTKJS file contents as base64 string #39

Merged
merged 3 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.github
docs
tests

Dockerfile
8 changes: 4 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
Expand Down
7 changes: 7 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
{
Expand Down
2 changes: 1 addition & 1 deletion extras-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
honeybee-energy>=1.95.35
honeybee-radiance>=1.64.118
ladybug-vtk>=0.13.9
ladybug-vtk>=0.14.1
2 changes: 1 addition & 1 deletion honeybee_display/attr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions honeybee_display/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
import logging
import json
import base64
import pickle
import tempfile
import uuid
Expand Down Expand Up @@ -198,6 +199,8 @@ 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)
f_contents = b.decode('utf-8')
output_file.write(f_contents)
else:
raise ValueError('Unrecognized output-format "{}".'.format(output_format))
Expand Down
2 changes: 1 addition & 1 deletion honeybee_display/colorobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
13 changes: 7 additions & 6 deletions honeybee_display/model.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
"""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
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
Expand Down Expand Up @@ -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(
Expand All @@ -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]
Expand Down Expand Up @@ -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:
Expand All @@ -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(
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading