Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e99efe8105 | |||
| 30de4d207a | |||
| 69829266a4 | |||
| ca1b8c52ed |
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user