Skip to content

feat: Add lots of methods to OpenHexaClient#281

Merged
yolanfery merged 7 commits into
mainfrom
addMethodsToSDK
Jun 26, 2025
Merged

feat: Add lots of methods to OpenHexaClient#281
yolanfery merged 7 commits into
mainfrom
addMethodsToSDK

Conversation

@yolanfery

@yolanfery yolanfery commented Jun 26, 2025

Copy link
Copy Markdown
Contributor
  • Manually add a good amount of queries and mutations used in the frontend
  • Clean/Rename some of them to propose a clean interface for resulting Python methods
  • Automatically generate Python code using ariadne-codegen
  • Bring in the latest Graphql schema from the monorepo
  • This change should have minimal impact to existing features (the client is only used in 2 places right now)

Comment thread openhexa/cli/cli.py Outdated
for pipeline in workspace_pipelines:
if pipeline.type == "zipFile":
current_version = f"v{pipeline.current_version.version_number}" if pipeline.current_version else "N/A"
current_version = "N/A" if not pipeline.current_version else f"v{pipeline.current_version.version_number}"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This helps with warning in IDE because current version can be None

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this change identical to what it was before? In general I think if condition is easier to reason about than if not condition.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, not a big deal, PyCharm prefers it inverted (I think it does not handle perfectly Optional typing). VS Code seems fine with it so I am reverting this change

@bramj bramj Jun 26, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PyCharm prefers it inverted

Interesting! And weird :p But not a big deal indeed, you can do as you prefer

"""The countries of the workspace."""
try:
return OpenHexaClient().get_countries(workspace_slug=self.slug).workspace.countries
return OpenHexaClient().workspace(slug=self.slug).workspace.countries

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use a more generic query

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

@bramj bramj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yolanfery Nice exploration! What do you think about this approach? I think it strikes a good balance between the manual and generated.
I would add methods for the datasets as well, what do you think?

Comment thread openhexa/cli/cli.py Outdated
for pipeline in workspace_pipelines:
if pipeline.type == "zipFile":
current_version = f"v{pipeline.current_version.version_number}" if pipeline.current_version else "N/A"
current_version = "N/A" if not pipeline.current_version else f"v{pipeline.current_version.version_number}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this change identical to what it was before? In general I think if condition is easier to reason about than if not condition.

Comment thread openhexa/cli/cli.py Outdated
workspace_pipelines = (
OpenHexaClient().get_workspace_pipelines(workspace_slug=settings.current_workspace).pipelines.items
)
workspace_pipelines = OpenHexaClient().pipelines(workspace_slug=settings.current_workspace).pipelines.items

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a nitpick, and it slightly annoys me that I have to do a superfluous .pipelines on this method before getting to the .items 🙂

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you and wanted to fix this but didn't look far enough to change this.

Thanks for pushing me a bit further, I have found a plugin that does exactly that

@yolanfery

Copy link
Copy Markdown
Contributor Author

@yolanfery Nice exploration! What do you think about this approach? I think it strikes a good balance between the manual and generated.

It feels nice, yes

I would add methods for the datasets as well, what do you think?

Done

@yolanfery yolanfery requested a review from bramj June 26, 2025 10:38
@nazarfil

nazarfil commented Jun 26, 2025

Copy link
Copy Markdown
  • Manually add a good amount of queries and mutations used in the frontend
  • Clean/Rename some of them to propose a clean interface for resulting Python methods
  • Automatically generate Python code using ariadne-codegen
  • Bring in the latest Graphql schema from the monorepo
  • This change should have minimal impact to existing features (the client is only used in 2 places right now)

This is very nice to have.
Screenshot 2025-06-26 at 14 11 54

I have checked that in the toolbox we technically never use SDK (we have used it in past to define connection type DHIS2, IASO etc and derive client instantiation from it) but now clients are changed to be instantiated explicitly from credentials.
It means that we could potentially deprecate OpenHexa client in the toolbox that redefines queries manually and offer this autogenerated one.

@yolanfery

Copy link
Copy Markdown
Contributor Author

It means that we could potentially deprecate OpenHexa client in the toolbox that redefines queries manually and offer this autogenerated one.

Yes definitely ! Thanks for checking

@yolanfery yolanfery merged commit c348d2b into main Jun 26, 2025
4 checks passed
@yolanfery yolanfery deleted the addMethodsToSDK branch June 26, 2025 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants