33import datetime
44import errno
55import os
6- import uuid
76from typing import Any
87
8+ from openhexa .graphql import CurrentPipelineRunCurrentPipelineRunPipeline
9+ from openhexa .sdk .client import OpenHexaClient
910from openhexa .sdk .pipelines .log_level import LogLevel
1011from openhexa .sdk .utils import Environment , get_environment , graphql
1112from openhexa .sdk .workspaces import workspace
12- from openhexa .sdk .client import OpenHexaClient
13-
14- from openhexa .graphql import CurrentPipelineRunCurrentPipelineRunPipeline
1513
1614
1715class CurrentRun :
@@ -28,11 +26,24 @@ def _connected(self):
2826 @property
2927 def pipeline_run_id (self ) -> Any :
3028 """Get the current pipeline run ID."""
31- return OpenHexaClient ().current_pipeline_run ()["id" ]
29+ if self ._connected :
30+ # Use the OpenHexaClient to get the current pipeline run ID
31+ return OpenHexaClient ().current_pipeline_run ()["id" ]
32+ else :
33+ raise RuntimeError (
34+ "CurrentRun is not connected to the OpenHEXA server. "
35+ "Make sure to set the HEXA_SERVER_URL environment variable."
36+ )
3237
3338 def get_pipline (self ) -> CurrentPipelineRunCurrentPipelineRunPipeline :
3439 """Get the current pipeline."""
35- return OpenHexaClient ().current_pipeline_run ()["pipeline" ]
40+ if self ._connected :
41+ return OpenHexaClient ().current_pipeline_run ()["pipeline" ]
42+ else :
43+ raise RuntimeError (
44+ "CurrentRun is not connected to the OpenHEXA server. "
45+ "Make sure to set the HEXA_SERVER_URL environment variable."
46+ )
3647
3748 def add_file_output (self , path : str ):
3849 """Record a run output for a file creation operation.
0 commit comments