Skip to content

Commit 926ac53

Browse files
author
nazarfil
committed
linting
1 parent b3636cd commit 926ac53

4 files changed

Lines changed: 18 additions & 8 deletions

File tree

openhexa/graphql/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
"""GraphQL package."""
22

3-
43
from .base_openhexa_client import BaseOpenHexaClient # noqa: F401 -> Expose base client class
54
from .graphql_client import * # noqa: F403 -> Expose autogenerated types

openhexa/sdk/client/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""OpenHexa Client."""
2+
23
from ..utils import OpenHexaClient
34

45
openhexa = OpenHexaClient()

openhexa/sdk/pipelines/run.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@
33
import datetime
44
import errno
55
import os
6-
import uuid
76
from typing import Any
87

8+
from openhexa.graphql import CurrentPipelineRunCurrentPipelineRunPipeline
9+
from openhexa.sdk.client import OpenHexaClient
910
from openhexa.sdk.pipelines.log_level import LogLevel
1011
from openhexa.sdk.utils import Environment, get_environment, graphql
1112
from openhexa.sdk.workspaces import workspace
12-
from openhexa.sdk.client import OpenHexaClient
13-
14-
from openhexa.graphql import CurrentPipelineRunCurrentPipelineRunPipeline
1513

1614

1715
class 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.

tests/test_current_run.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,3 @@ def test_filtering_log_messages_based_on_settings(mock_graphql, settings):
2828
assert mock_graphql.call_count == 2
2929
mock_graphql.assert_any_call(ANY, {"input": {"priority": "ERROR", "message": "This is an error message"}})
3030
mock_graphql.assert_any_call(ANY, {"input": {"priority": "CRITICAL", "message": "This is a critical message"}})
31-

0 commit comments

Comments
 (0)