-
Notifications
You must be signed in to change notification settings - Fork 29
codegen: add Python urllib3 client #46
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
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
0b1f199
codegen: add Python urllib3 client codegen
jackye1995 915bbb3
fix ci
jackye1995 df1068e
install poetry before caching
jackye1995 8060648
fix ci
jackye1995 21b7e7e
fix ci
jackye1995 b236c62
fix ci
jackye1995 f8316f4
fix ci
jackye1995 16bd752
fix ci
jackye1995 eea9f37
fix ci
jackye1995 60f4603
address review
jackye1995 094e82b
rebase
jackye1995 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| name: Python | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
| types: | ||
| - opened | ||
| - synchronize | ||
| - ready_for_review | ||
| - reopened | ||
| paths: | ||
| - spec/** | ||
| - python/** | ||
| - .github/workflows/python.yml | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | ||
|
|
||
| env: | ||
| # This env var is used by Swatinem/rust-cache@v2 for the cache | ||
| # key, so we set it to make sure it is always consistent. | ||
| CARGO_TERM_COLOR: always | ||
| # Disable full debug symbol generation to speed up CI build and keep memory down | ||
| # "1" means line tables only, which is useful for panic tracebacks. | ||
| RUSTFLAGS: "-C debuginfo=1" | ||
| RUST_BACKTRACE: "1" | ||
| # according to: https://matklad.github.io/2021/09/04/fast-rust-builds.html | ||
| # CI builds are faster with incremental disabled. | ||
| CARGO_INCREMENTAL: "0" | ||
| CARGO_BUILD_JOBS: "1" | ||
|
|
||
| jobs: | ||
| linux-build: | ||
| runs-on: ubuntu-24.04 | ||
| timeout-minutes: 60 | ||
| strategy: | ||
| matrix: | ||
| python-version: [ 3.11 ] # Ray does not support 3.12 yet. | ||
| steps: | ||
| - name: Install dependencies | ||
| run: | | ||
| sudo apt update | ||
| sudo apt install -y protobuf-compiler libssl-dev | ||
| # pin the toolchain version to avoid surprises | ||
| - uses: actions-rust-lang/setup-rust-toolchain@v1 | ||
| with: | ||
| toolchain: stable | ||
| - uses: rui314/setup-mold@v1 | ||
| - name: Install cargo-llvm-cov | ||
| uses: taiki-e/install-action@cargo-llvm-cov | ||
| - name: Checkout lance repo | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| repository: lancedb/lance | ||
| path: lance | ||
| - name: Checkout lance-catalog repo | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| path: lance-catalog | ||
| - uses: Swatinem/rust-cache@v2 | ||
| with: | ||
| workspaces: lance/python | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
| cache: 'pip' | ||
| - name: Set up Python virtual environment | ||
| run: | | ||
| python -m venv venv | ||
| source venv/bin/activate | ||
| pip install maturin | ||
| pip install poetry | ||
| - name: Install Lance Python SDK | ||
| working-directory: lance/python | ||
| run: | | ||
| source ../../venv/bin/activate | ||
| maturin develop | ||
| - name: Test lance_catalog_urllib3_client with Python ${{ matrix.python-version }} | ||
| working-directory: lance-catalog/python/lance_catalog_urllib3_client | ||
| run: | | ||
| source ../../../venv/bin/activate | ||
| poetry install | ||
| poetry run pytest |
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,33 @@ | ||
|
|
||
| VERSION = 0.0.1 | ||
|
|
||
| clean-python-urllib3-client: | ||
| rm -rf lance-catalog-urllib3-client/** | ||
|
|
||
| gen-python-urllib3-client: clean-python-urllib3-client | ||
| openapi-generator-cli generate \ | ||
| -i ../spec/catalog.yaml \ | ||
| -g python \ | ||
| -o lance_catalog_urllib3_client \ | ||
| --additional-properties=packageName=lance_catalog_urllib3_client,packageVersion=$(VERSION),library=urllib3 | ||
| # TODO: using .openapi-generator-ignore was not working, manually delete unused files for now | ||
| rm -rf lance_catalog_urllib3_client/.github | ||
| rm -rf lance_catalog_urllib3_client/.gitignore | ||
| rm -rf lance_catalog_urllib3_client/.gitlab-ci.yml | ||
| rm -rf lance_catalog_urllib3_client/.travis.yml | ||
| rm -rf lance_catalog_urllib3_client/git_push.sh | ||
| rm -rf lance_catalog_urllib3_client/requirements.txt | ||
| rm -rf lance_catalog_urllib3_client/setup.cfg | ||
| rm -rf lance_catalog_urllib3_client/setup.py | ||
| rm -rf lance_catalog_urllib3_client/test-requirements.txt | ||
| rm -rf lance_catalog_urllib3_client/tox.ini | ||
|
|
||
| build-python-urllib3-client: gen-python-urllib3-client | ||
| cd lance_catalog_urllib3_client; \ | ||
| poetry run pytest | ||
|
|
||
| clean: clean-python-urllib3-client | ||
|
|
||
| gen: gen-python-urllib3-client | ||
|
|
||
| build: build-python-urllib3-client | ||
23 changes: 23 additions & 0 deletions
23
python/lance_catalog_urllib3_client/.openapi-generator-ignore
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,23 @@ | ||
| # OpenAPI Generator Ignore | ||
| # Generated by openapi-generator https://github.com/openapitools/openapi-generator | ||
|
|
||
| # Use this file to prevent files from being overwritten by the generator. | ||
| # The patterns follow closely to .gitignore or .dockerignore. | ||
|
|
||
| # As an example, the C# client generator defines ApiClient.cs. | ||
| # You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: | ||
| #ApiClient.cs | ||
|
|
||
| # You can match any string of characters against a directory, file or extension with a single asterisk (*): | ||
| #foo/*/qux | ||
| # The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux | ||
|
|
||
| # You can recursively match patterns against a directory, file or extension with a double asterisk (**): | ||
| #foo/**/qux | ||
| # This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux | ||
|
|
||
| # You can also negate patterns with an exclamation (!). | ||
| # For example, you can ignore all files in a docs folder with the file extension .md: | ||
| #docs/*.md | ||
| # Then explicitly reverse the ignore rule for a single file: | ||
| #!docs/README.md |
34 changes: 34 additions & 0 deletions
34
python/lance_catalog_urllib3_client/.openapi-generator/FILES
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,34 @@ | ||
| .github/workflows/python.yml | ||
| .gitignore | ||
| .gitlab-ci.yml | ||
| .travis.yml | ||
| README.md | ||
| docs/CreateNamespaceRequest.md | ||
| docs/CreateNamespaceResponse.md | ||
| docs/ErrorModel.md | ||
| docs/GetNamespaceResponse.md | ||
| docs/ListNamespacesResponse.md | ||
| docs/NamespaceApi.md | ||
| git_push.sh | ||
| lance_catalog_urllib3_client/__init__.py | ||
| lance_catalog_urllib3_client/api/__init__.py | ||
| lance_catalog_urllib3_client/api/namespace_api.py | ||
| lance_catalog_urllib3_client/api_client.py | ||
| lance_catalog_urllib3_client/api_response.py | ||
| lance_catalog_urllib3_client/configuration.py | ||
| lance_catalog_urllib3_client/exceptions.py | ||
| lance_catalog_urllib3_client/models/__init__.py | ||
| lance_catalog_urllib3_client/models/create_namespace_request.py | ||
| lance_catalog_urllib3_client/models/create_namespace_response.py | ||
| lance_catalog_urllib3_client/models/error_model.py | ||
| lance_catalog_urllib3_client/models/get_namespace_response.py | ||
| lance_catalog_urllib3_client/models/list_namespaces_response.py | ||
| lance_catalog_urllib3_client/py.typed | ||
| lance_catalog_urllib3_client/rest.py | ||
| pyproject.toml | ||
| requirements.txt | ||
| setup.cfg | ||
| setup.py | ||
| test-requirements.txt | ||
| test/__init__.py | ||
| tox.ini |
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 @@ | ||
| 7.12.0 |
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,120 @@ | ||
| # lance-catalog-urllib3-client | ||
| **Lance Catalog** is an OpenAPI specification on top of the storage-based Lance format. | ||
| It provides an integration point for catalog service like Apache Hive MetaStore (HMS), Apache Gravitino, etc. | ||
| to store and use Lance tables. To integrate, the catalog service implements a **Lance Catalog Adapter**, | ||
| which is a REST server that converts the Lance catalog requests to native requests against the catalog service. | ||
| Different tools can integrate with Lance Catalog using the generated OpenAPI clients in various languages, | ||
| and invoke operations in Lance Catalog to read, write and manage Lance tables in the integrated catalog services. | ||
|
|
||
|
|
||
| This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: | ||
|
|
||
| - API version: 0.0.1 | ||
| - Package version: 0.0.1 | ||
| - Generator version: 7.12.0 | ||
| - Build package: org.openapitools.codegen.languages.PythonClientCodegen | ||
|
|
||
| ## Requirements. | ||
|
|
||
| Python 3.8+ | ||
|
|
||
| ## Installation & Usage | ||
| ### pip install | ||
|
|
||
| If the python package is hosted on a repository, you can install directly using: | ||
|
|
||
| ```sh | ||
| pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git | ||
| ``` | ||
| (you may need to run `pip` with root permission: `sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git`) | ||
|
|
||
| Then import the package: | ||
| ```python | ||
| import lance_catalog_urllib3_client | ||
| ``` | ||
|
|
||
| ### Setuptools | ||
|
|
||
| Install via [Setuptools](http://pypi.python.org/pypi/setuptools). | ||
|
|
||
| ```sh | ||
| python setup.py install --user | ||
| ``` | ||
| (or `sudo python setup.py install` to install the package for all users) | ||
|
|
||
| Then import the package: | ||
| ```python | ||
| import lance_catalog_urllib3_client | ||
| ``` | ||
|
|
||
| ### Tests | ||
|
|
||
| Execute `pytest` to run the tests. | ||
|
|
||
| ## Getting Started | ||
|
|
||
| Please follow the [installation procedure](#installation--usage) and then run the following: | ||
|
|
||
| ```python | ||
|
|
||
| import lance_catalog_urllib3_client | ||
| from lance_catalog_urllib3_client.rest import ApiException | ||
| from pprint import pprint | ||
|
|
||
| # Defining the host is optional and defaults to http://localhost:2333 | ||
| # See configuration.py for a list of all supported configuration parameters. | ||
| configuration = lance_catalog_urllib3_client.Configuration( | ||
| host = "http://localhost:2333" | ||
| ) | ||
|
|
||
|
|
||
|
|
||
| # Enter a context with an instance of the API client | ||
| with lance_catalog_urllib3_client.ApiClient(configuration) as api_client: | ||
| # Create an instance of the API class | ||
| api_instance = lance_catalog_urllib3_client.NamespaceApi(api_client) | ||
| create_namespace_request = lance_catalog_urllib3_client.CreateNamespaceRequest() # CreateNamespaceRequest | | ||
|
|
||
| try: | ||
| # Create a new namespace. A catalog can manage one or more namespaces. A namespace is used to manage one or more tables. There are three modes when trying to create a namespace: * CREATE: Create the namespace if it does not exist. If a namespace of the same name already exists, the operation fails with 400. * EXIST_OK: Create the namespace if it does not exist. If a namespace of the same name already exists, the operation succeeds and the existing namespace is kept. * OVERWRITE: Create the namespace if it does not exist. If a namespace of the same name already exists, the existing namespace is dropped and a new namespace with this name with no table is created. | ||
| api_response = api_instance.create_namespace(create_namespace_request) | ||
| print("The response of NamespaceApi->create_namespace:\n") | ||
| pprint(api_response) | ||
| except ApiException as e: | ||
| print("Exception when calling NamespaceApi->create_namespace: %s\n" % e) | ||
|
|
||
| ``` | ||
|
|
||
| ## Documentation for API Endpoints | ||
|
|
||
| All URIs are relative to *http://localhost:2333* | ||
|
|
||
| Class | Method | HTTP request | Description | ||
| ------------ | ------------- | ------------- | ------------- | ||
| *NamespaceApi* | [**create_namespace**](docs/NamespaceApi.md#create_namespace) | **POST** /v1/namespaces | Create a new namespace. A catalog can manage one or more namespaces. A namespace is used to manage one or more tables. There are three modes when trying to create a namespace: * CREATE: Create the namespace if it does not exist. If a namespace of the same name already exists, the operation fails with 400. * EXIST_OK: Create the namespace if it does not exist. If a namespace of the same name already exists, the operation succeeds and the existing namespace is kept. * OVERWRITE: Create the namespace if it does not exist. If a namespace of the same name already exists, the existing namespace is dropped and a new namespace with this name with no table is created. | ||
| *NamespaceApi* | [**drop_namespace**](docs/NamespaceApi.md#drop_namespace) | **DELETE** /v1/namespaces/{ns} | Drop a namespace from the catalog. Namespace must be empty. | ||
| *NamespaceApi* | [**get_namespace**](docs/NamespaceApi.md#get_namespace) | **GET** /v1/namespaces/{ns} | Get information about a namespace | ||
| *NamespaceApi* | [**list_namespaces**](docs/NamespaceApi.md#list_namespaces) | **GET** /v1/namespaces | List all namespaces in the catalog. | ||
| *NamespaceApi* | [**namespace_exists**](docs/NamespaceApi.md#namespace_exists) | **HEAD** /v1/namespaces/{ns} | Check if a namespace exists | ||
|
|
||
|
|
||
| ## Documentation For Models | ||
|
|
||
| - [CreateNamespaceRequest](docs/CreateNamespaceRequest.md) | ||
| - [CreateNamespaceResponse](docs/CreateNamespaceResponse.md) | ||
| - [ErrorModel](docs/ErrorModel.md) | ||
| - [GetNamespaceResponse](docs/GetNamespaceResponse.md) | ||
| - [ListNamespacesResponse](docs/ListNamespacesResponse.md) | ||
|
|
||
|
|
||
| <a id="documentation-for-authorization"></a> | ||
| ## Documentation For Authorization | ||
|
|
||
| Endpoints do not require authorization. | ||
|
|
||
|
|
||
| ## Author | ||
|
|
||
|
|
||
|
|
||
|
|
Oops, something went wrong.
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.
I am thinking about using a single Makefile to generate multi-language native clients.
Can we do that?
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.
yes I also plan to do that after this PR is merged
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.
http://jujhnugtggithub.com/lancedb/lance-catalog/issues/47