1 Commits

Author SHA1 Message Date
Jonathon Broughton 564b4a8012 fixes
build and deploy Speckle functions / publish-automate-function-version (push) Has been cancelled
2023-11-13 04:39:51 +00:00
8 changed files with 54 additions and 46 deletions
+1 -1
View File
@@ -6,7 +6,7 @@
"dockerFile": "../Dockerfile",
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "poetry install --no-root",
"postCreateCommand": "poetry install --no-root",
// Configure tool-specific properties.
"customizations": {
-2
View File
@@ -4,8 +4,6 @@ dist/
*.egg-info/
.cache/
*.log
.ruff_cache/
.venv/
.env/
.git/
Dockerfile copy*
Regular → Executable
View File
+3 -1
View File
@@ -246,4 +246,6 @@ COPY . /home/speckle
# Using poetry, we generate a list of requirements, save them to requirements.txt, and then use pip to install them
RUN poetry export --format requirements.txt --output /home/speckle/requirements.txt --without-hashes && \
pip install --requirement /home/speckle/requirements.txt
pip install --requirement /home/speckle/requirements.txt
RUN poetry install --no-root
+10 -10
View File
@@ -15,7 +15,7 @@ from Geometry.mesh import cast
def detect_clashes_old(
reference_elements: List[Element], latest_elements: List[Element], _tolerance: float
reference_elements: List[Element], latest_elements: List[Element], _tolerance: float
) -> list[tuple[str, str, float]]:
"""
Detect clashes between two sets of mesh elements using Pymesh.
@@ -46,11 +46,11 @@ def detect_clashes_old(
continue
intersection = pymesh.boolean(
latest_pymesh, operation="intersection"
latest_pymesh, ref_pymesh, operation="intersection"
)
if (
intersection and intersection.volume > 0
intersection and intersection.volume > 0
): # TODO: could tolerance relate to this?
severity = intersection.volume / min(
ref_pymesh.volume, latest_pymesh.volume
@@ -62,7 +62,7 @@ def detect_clashes_old(
def check_for_clash(
ref_element: Element, latest_element: Element
ref_element: Element, latest_element: Element
) -> Optional[tuple[Any, Any, Any]]:
"""
Check for a clash between two elements and calculate the severity of the clash.
@@ -82,7 +82,7 @@ def check_for_clash(
if not ref_pymesh or not latest_pymesh:
continue
intersection = pymesh.boolean(latest_pymesh, operation="intersection")
intersection = pymesh.boolean(latest_pymesh, ref_pymesh, operation="intersection")
if intersection and intersection.volume > 0:
severity = intersection.volume / min(
ref_pymesh.volume, latest_pymesh.volume
@@ -92,7 +92,7 @@ def check_for_clash(
def detect_clashes(
reference_elements: List[Element], latest_elements: List[Element], _tolerance: float
reference_elements: List[Element], latest_elements: List[Element], _tolerance: float
) -> List[Tuple[str, str, float]]:
"""
Detect clashes between two sets of mesh elements using parallel processing.
@@ -121,10 +121,10 @@ def detect_clashes(
def detect_and_report_clashes(
reference_elements: list[Element],
latest_elements: list[Element],
tolerance: float,
automate_context: AutomationContext,
reference_elements: list[Element],
latest_elements: list[Element],
tolerance: float,
automate_context: AutomationContext,
) -> list[tuple[str, str, float]]:
clashes = detect_clashes(reference_elements, latest_elements, tolerance)
+24 -31
View File
@@ -36,27 +36,25 @@ class FunctionInputs(AutomateBase):
title="Static Model Name",
description="Name of the static structural model.",
)
tolerance: float = Field(
default=25.0,
title="Tolerance",
description="Specify the tolerance value for the analysis. \
Negative values relaxes the test, positive values make it more strict.",
readonly=True,
)
tolerance_unit: str = Field( # Using the SpecklePy Units enum here
default=Units.mm,
json_schema_extra={"examples": ["mm", "cm", "m"]},
title="Tolerance Unit",
description="Unit of the tolerance value.",
readonly=True,
)
tolerance: float = Field(
default=25.0,
title="Tolerance",
description="Specify the tolerance value for the analysis. \
Negative values relaxes the test, positive values make it more strict.",
readonly=True,
)
tolerance_unit: str = Field( # Using the SpecklePy Units enum here
default=Units.mm,
json_schema_extra={"examples": ["mm", "cm", "m"]},
title="Tolerance Unit",
description="Unit of the tolerance value.",
readonly=True,
)
def automate_function(
automate_context: AutomationContext,
function_inputs: FunctionInputs,
automate_context: AutomationContext,
function_inputs: FunctionInputs,
) -> None:
"""This is an example Speckle Automate function.
@@ -129,26 +127,21 @@ def automate_function(
speckle_to_element(obj) for obj in latest_displayable_objects
]
# using trimesh library process all these meshes in the form of A vs B
# and get the clashes
tolerance = function_inputs.tolerance
clashes = detect_and_report_clashes(
reference_mesh_elements, latest_mesh_elements, tolerance, automate_context
)
# all object count
# all reference objects count
# all latest objects count
percentage_reference_objects_clashing = (
len(set([ref_id for ref_id, latest_id, severity in clashes]))
/ len(reference_mesh_elements)
* 100
len(set([ref_id for ref_id, latest_id, severity in clashes]))
/ len(reference_mesh_elements)
* 100
)
percentage_latest_objects_clashing = (
len(set([latest_id for ref_id, latest_id, severity in clashes]))
/ len(latest_mesh_elements)
* 100
len(set([latest_id for ref_id, latest_id, severity in clashes]))
/ len(latest_mesh_elements)
* 100
)
# all clashes count
@@ -170,7 +163,7 @@ def automate_function(
def get_reference_model(
automate_context: AutomationContext, static_model_name: str
automate_context: AutomationContext, static_model_name: str
) -> Base:
# the static reference model will be retrieved from the project using model name stored in the inputs
speckle_client = automate_context.speckle_client
Generated
+15 -1
View File
@@ -796,6 +796,20 @@ tomli = {version = ">=1.0.0", markers = "python_version < \"3.11\""}
[package.extras]
testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"]
[[package]]
name = "python-dotenv"
version = "1.0.0"
description = "Read key-value pairs from a .env file and set them as environment variables"
optional = false
python-versions = ">=3.8"
files = [
{file = "python-dotenv-1.0.0.tar.gz", hash = "sha256:a8df96034aae6d2d50a4ebe8216326c61c3eb64836776504fcca410e5937a3ba"},
{file = "python_dotenv-1.0.0-py3-none-any.whl", hash = "sha256:f5971a9226b701070a4bf2c38c89e5a3f0d64de8debda981d1db98583009122a"},
]
[package.extras]
cli = ["click (>=5.0)"]
[[package]]
name = "requests"
version = "2.31.0"
@@ -1274,4 +1288,4 @@ multidict = ">=4.0"
[metadata]
lock-version = "2.0"
python-versions = "^3.10"
content-hash = "3abedc1c21df21ba5ab28f1ea6dc49c8a84c768e0f8f155e5c619ca3fd023765"
content-hash = "e4e56818583a9f0fad2adbfbc4dcb2ebaa1fc8f917004477f0e1574237b7850a"
+1
View File
@@ -15,6 +15,7 @@ black = "^23.3.0"
mypy = "^1.3.0"
ruff = "^0.0.271"
pytest = "^7.4.2"
python-dotenv = "^1.0.0"
[build-system]
requires = ["poetry-core"]