Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f6917b0761 | |||
| 04764b17eb | |||
| dbe3d759f6 | |||
| f6ff484e66 | |||
| bd000395af | |||
| 10f49579fd | |||
| 1693465dfc | |||
| c3a7ead8f5 | |||
| d151a8d0ae | |||
| c0dd88cbdb | |||
| 71d3589e72 | |||
| 5bde1bc2d6 | |||
| 75e6f0229a | |||
| 5d7e71f357 | |||
| 6c223b6fb3 | |||
| e6131a7956 | |||
| 45b50e4f26 | |||
| d9b92490ec |
+1
-1
@@ -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
@@ -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>"]
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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."
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user