-
Notifications
You must be signed in to change notification settings - Fork 1
fix: refactor OpenHexaClient to allow usage in both CLI and SDK without circular dependency (HEXA-1314) #279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
yolanfery
merged 5 commits into
main
from
HEXA-1314-fix-circular-dependency-between-sdk-and-cli
Jun 25, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| """GraphQL package.""" | ||
|
|
||
|
|
||
| from .base_openhexa_client import BaseOpenHexaClient # noqa: F401 -> Expose base client class | ||
| from .graphql_client import * # noqa: F403 -> Expose autogenerated types |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| """OpenHexaClient implementation for GraphQL API interaction.""" | ||
|
|
||
| import logging | ||
| from importlib.metadata import version | ||
|
|
||
| from openhexa.graphql.graphql_client import Client | ||
|
|
||
|
|
||
| class BaseOpenHexaClient(Client): | ||
| """OpenHexaClient is a class that provides methods to interact with the OpenHexa GraphQL API.""" | ||
|
|
||
| def __init__(self, url: str, token: str): | ||
| """Initialize the OpenHexaClient with the OpenHexa API URL and headers. | ||
|
|
||
| Args: | ||
| url: GraphQL API URL. | ||
| token: Authentication token. | ||
| """ | ||
| self.token = token | ||
| super().__init__( | ||
| url=url, | ||
| headers={ | ||
| "User-Agent": f"openhexa-sdk/{version('openhexa.sdk')}", | ||
| "Authorization": f"Bearer {self.token}", | ||
| }, | ||
| ) | ||
| logging.getLogger("httpx").setLevel( | ||
| logging.WARNING | ||
| ) # HTTPX logs queries by default, we disable them here with WARNING level | ||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...hexa/cli/graphql/graphql_client/client.py → openhexa/graphql/graphql_client/client.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
openhexa/cli/graphql/graphql_client/enums.py → openhexa/graphql/graphql_client/enums.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...i/graphql/graphql_client/get_countries.py → ...a/graphql/graphql_client/get_countries.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...graphql_client/get_workspace_pipelines.py → ...graphql_client/get_workspace_pipelines.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...cli/graphql/graphql_client/input_types.py → ...exa/graphql/graphql_client/input_types.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,10 +7,11 @@ | |
| from dataclasses import fields, make_dataclass | ||
| from warnings import warn | ||
|
|
||
| from openhexa.graphql.graphql_client import GetCountriesWorkspaceCountries | ||
| from openhexa.utils import stringcase | ||
|
|
||
| from ..datasets import Dataset | ||
| from ..utils import graphql | ||
| from ..utils import OpenHexaClient, graphql | ||
| from .connection import ( | ||
| ConnectionClasses, | ||
| CustomConnection, | ||
|
|
@@ -60,10 +61,8 @@ def slug(self) -> str: | |
| raise WorkspaceConfigError("The workspace slug is not available in this environment.") | ||
|
|
||
| @property | ||
| def countries(self): | ||
| def countries(self) -> list[GetCountriesWorkspaceCountries]: | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now we can use types without circular dependency 🎉 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| """The countries of the workspace.""" | ||
| from openhexa.cli.api import OpenHexaClient | ||
|
|
||
| try: | ||
| return OpenHexaClient().get_countries(workspace_slug=self.slug).workspace.countries | ||
| except KeyError: | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks for changing this!