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,23 @@ 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" ]
32-
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+ )
3337 def get_pipline (self ) -> CurrentPipelineRunCurrentPipelineRunPipeline :
3438 """Get the current pipeline."""
35- return OpenHexaClient ().current_pipeline_run ()["pipeline" ]
39+ if self ._connected :
40+ return OpenHexaClient ().current_pipeline_run ()["pipeline" ]
41+ else :
42+ raise RuntimeError (
43+ "CurrentRun is not connected to the OpenHEXA server. "
44+ "Make sure to set the HEXA_SERVER_URL environment variable."
45+ )
3646
3747 def add_file_output (self , path : str ):
3848 """Record a run output for a file creation operation.
0 commit comments