Compare commits

..

1 Commits

Author SHA1 Message Date
Jedd Morgan f20fc7edb3 Fix stream wrapper client call (#457)
Publish Python Package / test (push) Has been cancelled
Publish Python Package / Build and Publish Python Package (push) Has been cancelled
2025-10-01 11:17:44 +01:00
4 changed files with 12 additions and 49 deletions
+1 -21
View File
@@ -6,7 +6,6 @@ from os import getenv
from speckleifc.main import open_and_convert_file
from specklepy.core.api.client import SpeckleClient
from specklepy.core.api.credentials import get_accounts_for_server
from specklepy.logging import metrics
@@ -56,26 +55,7 @@ def cmd_line_import() -> None:
json.dump({"success": False, "error": str(e)}, f)
def manual_import() -> None:
PROJECT_ID = "f3a42bdf24"
MODEL_ID = "0e23cfdea3"
SERVER_URL = "app.speckle.systems"
metrics.set_host_app(
"ifc",
)
account = get_accounts_for_server(SERVER_URL)[0]
client = SpeckleClient(SERVER_URL, use_ssl=not SERVER_URL.startswith("http://"))
client.authenticate_with_account(account)
project = client.project.get(PROJECT_ID)
open_and_convert_file(FILE_PATH, project, None, MODEL_ID, client)
if __name__ == "__main__":
start = time.time()
# cmd_line_import()
manual_import()
cmd_line_import()
print(f"Total time (including cleanup): {(time.time() - start) * 1000}ms")
+1 -2
View File
@@ -13,8 +13,7 @@ def _create_iterator_settings() -> settings:
# no need to weld verts
ifc_settings.set("weld-vertices", False)
# Speckle meshes are all in world coords
ifc_settings.set("use-world-coords", False)
ifc_settings.set("permissive-shape-reuse", False)
ifc_settings.set("use-world-coords", True)
# Tiny performance improvement,
ifc_settings.set("no-wire-intersection-check", True)
# Rendermaterials inherit the material names instead of type + unique id
+2 -4
View File
@@ -54,10 +54,9 @@ class ImportJob:
)
children = self._convert_children(step_element)
id = step_element.id()
display_value = self.cached_display_values.get(id, [])
display_value = self.cached_display_values.get(step_element.id(), [])
if display_value:
if display_value is not None:
self.geometries_used += 1
# Extract current storey name from DataObject if available
@@ -128,7 +127,6 @@ class ImportJob:
self.geometries_count += 1
id = cast(int, shape.id)
print(f"converted {id}")
try:
display_value = geometry_to_speckle(
shape, self._render_material_manager
+8 -22
View File
@@ -1,8 +1,6 @@
from urllib.parse import quote, unquote, urlparse
from warnings import warn
from gql import gql
from specklepy.core.api.client import SpeckleClient
from specklepy.core.api.credentials import (
Account,
@@ -139,27 +137,11 @@ class StreamWrapper:
if use_fe2 is True and self.branch_name is not None:
self.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": self.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) from ke
self._client = self.get_client()
model = self._client.model.get(self.model_id, self.stream_id)
self.branch_name = model.name
if not self.stream_id:
raise SpeckleException(
@@ -175,6 +157,10 @@ class StreamWrapper:
"""
Gets an account object for this server from the local accounts db
(added via Speckle Manager or a json file)
WARNING: this function will return ANY account for the server,
just because you pass a token in doesn't guarantee it will be used.
This whole class could do with a re-design...
"""
if self._account and self._account.token:
return self._account