File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33from ..utils import OpenHexaClient
44
5- openhexa = OpenHexaClient ()
5+ _openhexa = None
66
7+ def get_openhexa ():
8+ global _openhexa
9+ if _openhexa is None :
10+ _openhexa = OpenHexaClient ()
11+ return _openhexa
712
8- __all__ = ["openhexa " ]
13+ __all__ = ["get_openhexa " ]
Original file line number Diff line number Diff line change 55import os
66from typing import Any
77
8- from openhexa .graphql import CurrentPipelineRunCurrentPipelineRunPipeline
9- from openhexa .sdk .client import OpenHexaClient
8+
109from openhexa .sdk .pipelines .log_level import LogLevel
1110from openhexa .sdk .utils import Environment , get_environment , graphql
1211from openhexa .sdk .workspaces import workspace
1312
13+ from openhexa .sdk .client import get_openhexa
14+
15+ from openhexa .graphql import CurrentPipelineRunCurrentPipelineRunPipeline
16+
1417
1518class CurrentRun :
1619 """Represents the current run of a pipeline.
@@ -27,18 +30,18 @@ def _connected(self):
2730 def pipeline_run_id (self ) -> Any :
2831 """Get the current pipeline run ID."""
2932 if self ._connected :
30- # Use the OpenHexaClient to get the current pipeline run ID
31- return OpenHexaClient ().current_pipeline_run ()["id" ]
33+ return get_openhexa ().current_pipeline_run ()["id" ]
3234 else :
3335 raise RuntimeError (
3436 "CurrentRun is not connected to the OpenHEXA server. "
3537 "Make sure to set the HEXA_SERVER_URL environment variable."
3638 )
3739
40+
3841 def get_pipline (self ) -> CurrentPipelineRunCurrentPipelineRunPipeline :
3942 """Get the current pipeline."""
4043 if self ._connected :
41- return OpenHexaClient ().current_pipeline_run ()["pipeline" ]
44+ return get_openhexa ().current_pipeline_run ()["pipeline" ]
4245 else :
4346 raise RuntimeError (
4447 "CurrentRun is not connected to the OpenHEXA server. "
You can’t perform that action at this time.
0 commit comments