Compare commits

...

4 Commits

Author SHA1 Message Date
Jonathon Broughton e99efe8105 Add workspaceId to test automation run and schema 2026-04-07 22:03:13 +01:00
Jonathon Broughton 30de4d207a Handle generic exceptions in AutomationContext project retrieval 2026-04-07 22:03:12 +01:00
Jonathon Broughton 69829266a4 extend AutomationRunData model to include workspace_id 2026-04-07 21:59:18 +01:00
Jonathon Broughton ca1b8c52ed add workspace_id property and resolution logic in AutomationContext 2026-04-07 21:59:17 +01:00
3 changed files with 32 additions and 1 deletions
@@ -97,6 +97,33 @@ class AutomationContext:
"""Get the current status message."""
return self._automation_result.status_message
@property
def workspace_id(self) -> Optional[str]:
"""Get the workspace id for the current automation run, if available."""
return self.automation_run_data.workspace_id
def resolve_workspace_id(self) -> Optional[str]:
"""Return workspace id from run data or project lookup fallback."""
workspace_id = self.workspace_id
if workspace_id and workspace_id.strip():
return workspace_id.strip()
project_id = self.automation_run_data.project_id
if not project_id:
return None
try:
project = self.speckle_client.project.get(project_id)
except Exception:
return None
workspace_id = getattr(project, "workspace_id", None)
if isinstance(workspace_id, str) and workspace_id.strip():
resolved_workspace_id = workspace_id.strip()
self.automation_run_data.workspace_id = resolved_workspace_id
return resolved_workspace_id
return None
def elapsed(self) -> float:
"""Return the elapsed time in seconds since the initialization time."""
return time.perf_counter() - self._init_time
+2
View File
@@ -68,6 +68,7 @@ def create_test_automation_run(
createTestAutomationRun(automationId: $automationId) {
automationRunId
functionRunId
workspaceId
triggers {
payload {
modelId
@@ -119,6 +120,7 @@ def create_test_automation_run_data(
return AutomationRunData(
project_id=test_automation_environment.project_id,
workspace_id=test_automation_run_data.workspace_id,
speckle_server_url=test_automation_environment.server_url,
automation_id=test_automation_environment.automation_id,
automation_run_id=test_automation_run_data.automation_run_id,
+3 -1
View File
@@ -1,7 +1,7 @@
""""""
from enum import Enum
from typing import Any, Literal
from typing import Any, Literal, Optional
from pydantic import BaseModel, ConfigDict, Field
from pydantic.alias_generators import to_camel
@@ -31,6 +31,7 @@ class AutomationRunData(BaseModel):
"""Values of the project / model that triggered the run of this function."""
project_id: str
workspace_id: Optional[str] = None
speckle_server_url: str
automation_id: str
automation_run_id: str
@@ -48,6 +49,7 @@ class TestAutomationRunData(BaseModel):
automation_run_id: str
function_run_id: str
workspace_id: Optional[str] = None
triggers: list[VersionCreationTrigger]