Compare commits

...

18 Commits

Author SHA1 Message Date
Gergő Jedlicska f6917b0761 Merge pull request #318 from specklesystems/gergo/markLogs
feat: reduce log message context for object results
2023-11-13 11:39:49 +01:00
Gergő Jedlicska 04764b17eb feat: reduce log message context for object results 2023-11-13 09:14:06 +01:00
Gergő Jedlicska dbe3d759f6 Merge pull request #317 from specklesystems/KatKatKateryna-patch-1
handle "append" with incoming type "list"
2023-11-13 09:09:23 +01:00
KatKatKateryna f6ff484e66 handle "append" with incoming type "list" 2023-11-13 04:53:03 +08:00
Gergő Jedlicska bd000395af Merge pull request #316 from specklesystems/gergo/contextViewFix
fix: report relative url for context view
2023-11-11 08:32:40 +01:00
Gergő Jedlicska 10f49579fd fix: report relative url for context view 2023-11-11 08:29:16 +01:00
Gergő Jedlicska 1693465dfc Merge pull request #314 from specklesystems/kate/stream_wrapper_fe2
update stream wrapper; add tests
2023-11-10 15:15:12 +01:00
Gergő Jedlicska c3a7ead8f5 Merge branch 'main' into kate/stream_wrapper_fe2 2023-11-10 15:11:28 +01:00
Gergő Jedlicska d151a8d0ae Merge pull request #315 from specklesystems/jrm/minio/fix
Pinned MinIO version for integration test docker compose
2023-11-10 15:06:14 +01:00
Gergő Jedlicska c0dd88cbdb fix: pin minio release to fix tests 2023-11-10 15:04:30 +01:00
Jedd Morgan 71d3589e72 pinned MinIO version for integration test docker compose 2023-11-10 13:54:02 +00:00
KatKatKateryna 5bde1bc2d6 remove library 2023-11-09 17:36:06 +00:00
KatKatKateryna 75e6f0229a update stream wrapper; add tests 2023-11-09 17:34:57 +00:00
Gergő Jedlicska 5d7e71f357 Merge pull request #313 from specklesystems/oguzhan/text-object
Chore (Objects): Add text object definition
2023-10-30 12:37:02 +01:00
oguzhankoral 6c223b6fb3 Exclude displayStyle from Text object
It shouldn't be have displayStyle for general purpose Text object, because displayStyle more Rhino and AutoCAD specific
2023-10-30 14:07:36 +03:00
oguzhankoral e6131a7956 Fix typo on type of displayValue 2023-10-30 11:51:15 +03:00
oguzhankoral 45b50e4f26 Add optional props of Objects.Other.Text 2023-10-30 11:42:30 +03:00
oguzhankoral d9b92490ec Add text object definition 2023-10-27 16:33:02 +03:00
8 changed files with 98 additions and 16 deletions
+1 -1
View File
@@ -33,7 +33,7 @@ services:
retries: 30
minio:
image: "minio/minio"
image: "minio/minio:RELEASE.2023-10-25T06-33-25Z"
command: server /data --console-address ":9001"
restart: always
volumes:
+1 -1
View File
@@ -1,6 +1,6 @@
[tool.poetry]
name = "specklepy"
version = "2.17.5"
version = "2.17.8"
description = "The Python SDK for Speckle 2.0"
readme = "README.md"
authors = ["Speckle Systems <devops@speckle.systems>"]
+7 -3
View File
@@ -163,6 +163,10 @@ class AutomationContext:
self._automation_result.result_versions.append(version_id)
return model_id, version_id
@property
def context_view(self) -> Optional[str]:
return self._automation_result.result_view
def set_context_view(
self,
# f"{model_id}@{version_id} or {model_id} "
@@ -177,7 +181,7 @@ class AutomationContext:
else []
)
if resource_ids:
link_resources.append(*resource_ids)
link_resources.extend(resource_ids)
if not link_resources:
raise Exception(
"We do not have enough resource ids to compose a context view"
@@ -401,8 +405,8 @@ class AutomationContext:
else:
id_list = [object_ids]
print(
f"Object {', '.join(id_list)} was marked with {level.value.upper()}",
f"/{category} cause: {message}",
f"Created new {level.value.upper()}"
f" category: {category} caused by: {message}"
)
self._automation_result.object_results.append(
ResultCase(
+2
View File
@@ -146,5 +146,7 @@ def run_function(
"Function error. Check the automation run logs for details."
)
finally:
if not automation_context.context_view:
automation_context.set_context_view()
automation_context.report_run_status()
return automation_context
+47 -2
View File
@@ -1,5 +1,6 @@
from urllib.parse import unquote, urlparse
from warnings import warn
from gql import gql
from specklepy.core.api.client import SpeckleClient
from specklepy.core.api.credentials import (
@@ -81,13 +82,25 @@ class StreamWrapper:
" provided."
)
# check for fe2 URL
if "/projects/" in parsed.path:
use_fe2 = True
else:
use_fe2 = False
while segments:
segment = segments.pop(0)
if segments and segment.lower() == "streams":
if segments and (
(use_fe2 is False and segment.lower() == "streams")
or (use_fe2 is True and segment.lower() == "projects")
):
self.stream_id = segments.pop(0)
elif segments and segment.lower() == "commits":
self.commit_id = segments.pop(0)
elif segments and segment.lower() == "branches":
elif segments and (
(use_fe2 is False and segment.lower() == "branches")
or (use_fe2 is True and segment.lower() == "models")
):
self.branch_name = unquote(segments.pop(0))
elif segments and segment.lower() == "objects":
self.object_id = segments.pop(0)
@@ -101,6 +114,38 @@ class StreamWrapper:
" provided."
)
if use_fe2 is True and self.branch_name is not None:
if "," in self.branch_name:
raise SpeckleException("Multi-model urls are not supported yet")
if "@" in self.branch_name:
model_id = self.branch_name.split("@")[0]
self.commit_id = self.branch_name.split("@")[1]
else:
model_id = self.branch_name
# get branch name
query = gql(
"""
query Project($project_id: String!, $model_id: String!) {
project(id: $project_id) {
id
model(id: $model_id) {
name
}
}
}
"""
)
self._client = self.get_client()
params = {"project_id": self.stream_id, "model_id": model_id}
project = self._client.httpclient.execute(query, params)
try:
self.branch_name = project["project"]["model"]["name"]
except KeyError as ke:
raise SpeckleException("Project model name is not found", ke)
if not self.stream_id:
raise SpeckleException(
f"Cannot parse {url} into a stream wrapper class - no stream id found."
+13 -1
View File
@@ -1,7 +1,7 @@
from typing import Any, List, Optional
from deprecated import deprecated
from specklepy.objects.geometry import Point, Vector
from specklepy.objects.geometry import Point, Vector, Plane, Polyline
from .base import Base
@@ -71,6 +71,18 @@ class DisplayStyle(Base, speckle_type=OTHER + "DisplayStyle"):
lineweight: float = 0
class Text(Base, speckle_type=OTHER + "Text"):
"""
Text object to render it on viewer.
"""
plane: Plane
value: str
height: float
rotation: float
displayValue: Optional[List[Polyline]] = None
richText: Optional[str] = None
class Transform(
Base,
speckle_type=OTHER + "Transform",
@@ -255,8 +255,8 @@ def test_create_version_in_project(
def test_set_context_view(automation_context: AutomationContext) -> None:
automation_context.set_context_view()
assert automation_context._automation_result.result_view is not None
assert automation_context._automation_result.result_view.endswith(
assert automation_context.context_view is not None
assert automation_context.context_view.endswith(
f"models/{automation_context.automation_run_data.model_id}@{automation_context.automation_run_data.version_id}"
)
@@ -267,8 +267,8 @@ def test_set_context_view(automation_context: AutomationContext) -> None:
dummy_context = "foo@bar"
automation_context.set_context_view([dummy_context])
assert automation_context._automation_result.result_view is not None
assert automation_context._automation_result.result_view.endswith(
assert automation_context.context_view is not None
assert automation_context.context_view.endswith(
f"models/{automation_context.automation_run_data.model_id}@{automation_context.automation_run_data.version_id},{dummy_context}"
)
automation_context.report_run_status()
@@ -280,8 +280,6 @@ def test_set_context_view(automation_context: AutomationContext) -> None:
[dummy_context], include_source_model_version=False
)
assert automation_context._automation_result.result_view is not None
assert automation_context._automation_result.result_view.endswith(
f"models/{dummy_context}"
)
assert automation_context.context_view is not None
assert automation_context.context_view.endswith(f"models/{dummy_context}")
automation_context.report_run_status()
+21
View File
@@ -126,3 +126,24 @@ def test_wrapper_url_match(user_path) -> None:
account = wrap.get_account()
assert account.userInfo.email is None
def test_parse_project():
wrap = StreamWrapper("https://latest.speckle.systems/projects/843d07eb10")
assert wrap.type == "stream"
def test_parse_model():
wrap = StreamWrapper(
"https://latest.speckle.systems/projects/843d07eb10/models/d9eb4918c8"
)
assert wrap.branch_name == "building wrapper"
assert wrap.type == "branch"
def test_parse_version():
wrap = StreamWrapper(
"https://latest.speckle.systems/projects/843d07eb10/models/4e7345c838@c42d5cbac1"
)
assert wrap.type == "commit"