Skip to content

Commit eb2c9f1

Browse files
author
nazarfil
committed
fix: fixes pieplines
1 parent 79c4382 commit eb2c9f1

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

openhexa/sdk/pipelines/run.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from typing import Any
77

88
from openhexa.graphql import CurrentPipelineRunCurrentPipelineRunPipeline
9-
from openhexa.sdk.client import get_openhexa
9+
from openhexa.sdk.client import OpenHexaClient
1010
from openhexa.sdk.pipelines.log_level import LogLevel
1111
from openhexa.sdk.utils import Environment, get_environment, graphql
1212
from openhexa.sdk.workspaces import workspace
@@ -23,26 +23,25 @@ class CurrentRun:
2323
def _connected(self):
2424
return "HEXA_SERVER_URL" in os.environ
2525

26-
@property
27-
def pipeline_run_id(self) -> Any:
28-
"""Get the current pipeline run ID."""
29-
if self._connected:
30-
return get_openhexa().current_pipeline_run()["id"]
26+
def _is_connected(self):
27+
if "HEXA_SERVER_URL" in os.environ:
28+
return True
3129
else:
3230
raise RuntimeError(
3331
"CurrentRun is not connected to the OpenHEXA server. "
3432
"Make sure to set the HEXA_SERVER_URL environment variable."
3533
)
3634

35+
@property
36+
def pipeline_run_id(self) -> Any:
37+
"""Get the current pipeline run ID."""
38+
self._is_connected()
39+
return OpenHexaClient().current_pipeline_run().id
40+
3741
def get_pipline(self) -> CurrentPipelineRunCurrentPipelineRunPipeline:
3842
"""Get the current pipeline."""
39-
if self._connected:
40-
return get_openhexa().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-
)
43+
self._is_connected()
44+
return OpenHexaClient().current_pipeline_run().pipeline
4645

4746
def add_file_output(self, path: str):
4847
"""Record a run output for a file creation operation.

0 commit comments

Comments
 (0)