Skip to content

Create a wrapper script to generate python client; regenerate the python client #1347

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
merged 63 commits into from
May 23, 2025

Conversation

eric-maynard
Copy link
Contributor

@eric-maynard eric-maynard commented Apr 9, 2025

As noted in #755 and elsewhere, the generated types in client/python are currently out of date. This introduces a script to regenerate them and a gradle task to run that script.

I've also run the script, which necessitated several things to get tests passing:

  1. There were small nonfunctional spec changes needed in order to keep the Python client working
  2. The CLI and its tests required a few fixes to work with the updated Python client
  3. Many of the regtests required fixes to work with the updated Python client

@eric-maynard
Copy link
Contributor Author

@snazy can you take a look at this draft? My impression is that I should be using the headers from codeconfig but I'd like to get your perspective on the best approach here. Additionally, this way of manually modifying files looks a little suspect to me but I could not find a way to easily augment the generator to do what we want.

@@ -260,6 +260,7 @@ paths:
parameters:
- $ref: '#/components/parameters/page-token'
- $ref: '#/components/parameters/page-size'
- $ref: '#/components/parameters/prefix'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This change is needed due to an unfortunate bug in the python generator wherein parameters are overriden, not extended. Without this, the method list_namespaces doesn't have a prefix argument.

Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we make a note somewhere (e.g. spec/README.md) that these changes are needed? Since iceberg-rest-catalog-open-api.yaml should be a copy-paste of upstream one, we may easily lose track of these additional changes the next time we copy-paste from the upstream.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ideally, the CI will fail when a bad copy/paste happens. We need to wire up the CI to the new task but I would like to do that in a followup. For now, let me add this in the README!

Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: it'd be nice to add the comment directly here like Non functional change required by Python generator. I believe this is the place where people may get confused every time pulling iceberg spec upstream.

Copy link
Contributor

@HonahX HonahX left a comment

Choose a reason for hiding this comment

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

This looks great! Just to confirm, currently we expect to manually regenerate the client after a spec change so the CI should not run the regeneration yet.

"./polaris/management/__pycache__/"
"./polaris/management/models/__pycache__/"
"./polaris/management/api/__pycache__/"
)
Copy link
Contributor

@HonahX HonahX May 23, 2025

Choose a reason for hiding this comment

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

[non-blocker] Shall we add ./.DS_STORE to exclude_paths for mac users? This makes running regenerate.sh fails in my mac locally with

Re-applying license headers
No header compatible with file ./.DS_Store

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
)
"./.DS_Store"
"./poetry.lock"
)

Also "poetry.lock" should be excluded

Copy link
Contributor

Choose a reason for hiding this comment

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

Synced with Eric offline, I believe we can solve this in a follow-up which automate the regeneration during test

Copy link
Contributor

@HonahX HonahX left a comment

Choose a reason for hiding this comment

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

LGTM!

@github-project-automation github-project-automation bot moved this from PRs In Progress to Ready to merge in Basic Kanban Board May 23, 2025
Copy link
Contributor

@sfc-gh-ygu sfc-gh-ygu left a comment

Choose a reason for hiding this comment

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

LGTM

@eric-maynard eric-maynard merged commit af26732 into apache:main May 23, 2025
6 checks passed
@github-project-automation github-project-automation bot moved this from Ready to merge to Done in Basic Kanban Board May 23, 2025
eric-maynard added a commit that referenced this pull request May 30, 2025
I ran these commands from main:

```
redocly bundle spec/polaris-catalog-service.yaml -o spec/generated/bundled-polaris-catalog-service.yaml
./gradlew regeneratePythonClient
```

I didn't realize before that some Python types are generated form the bundled spec, so some of the fixes from #1347 didn't get properly applied before.
eric-maynard added a commit that referenced this pull request Jun 2, 2025
It looks like this method lost the `prefix` and `namespace` parameters in #1347. They're re-introduced to the spec here, and then I've run:
```
redocly bundle spec/polaris-catalog-service.yaml -o spec/generated/bundled-polaris-catalog-service.yaml
./gradlew regeneratePythonClient
```

Then, some manual reverts:
```
alias gitrevert='git checkout upstream/main --'
gitrevert client/python/.github/workflows/python.yml
gitrevert client/python/.gitlab-ci.yml
gitrevert client/python/pyproject.toml
```

I still hope to automate this process as part of CI soon; see #1675
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants