Repository navigation
[SDK build process] Implement make regenerate command
#319
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
Closed
Closed
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -154,3 +154,7 @@ dmypy.json | |
| # Datasets | ||
| *.hdf5 | ||
| *~ | ||
|
|
||
| # Code generation files | ||
| gen/ | ||
| downloads/ | ||
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 |
|---|---|---|
| @@ -1,48 +1,48 @@ | ||
| .PHONY: image develop tests tag-and-push docs version package upload upload-spruce license | ||
| SHELL = /bin/bash | ||
| mkfile_path := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) | ||
|
|
||
| PYPI_USERNAME ?= __token__ | ||
|
|
||
| image: | ||
| MODULE=pinecone ../scripts/build.sh ./ | ||
|
|
||
| develop: | ||
| poetry install -E grpc | ||
|
|
||
| test-unit: | ||
| @echo "Running tests..." | ||
| poetry run pytest --cov=pinecone --timeout=120 tests/unit | ||
|
|
||
| test-grpc-unit: | ||
| @echo "Running tests..." | ||
| poetry run pytest --cov=pinecone --timeout=120 tests/unit_grpc | ||
|
|
||
| make type-check: | ||
| poetry run mypy pinecone --exclude pinecone/core | ||
|
|
||
| version: | ||
| poetry version | ||
|
|
||
| package: | ||
| poetry build | ||
|
|
||
| upload: | ||
| poetry publish --verbose --username ${PYPI_USERNAME} --password ${PYPI_PASSWORD} | ||
|
|
||
| upload-spruce: | ||
| # Configure Poetry for publishing to testpypi | ||
| poetry config repositories.test-pypi https://test.pypi.org/legacy/ | ||
| poetry publish --verbose -r test-pypi --username ${PYPI_USERNAME} --password ${PYPI_PASSWORD} | ||
| gcloud-auth: | ||
| docker run -ti --name gcloud-config gcr.io/google.com/cloudsdktool/google-cloud-cli gcloud auth login | ||
|
|
||
| clean: | ||
| rm -rf downloads | ||
| rm -rf gen | ||
|
|
||
| download: | ||
| mkdir downloads | ||
| docker run --rm \ | ||
| --volumes-from gcloud-config \ | ||
| -v ${mkfile_path}:/workspace \ | ||
| -w /workspace \ | ||
| gcr.io/google.com/cloudsdktool/google-cloud-cli \ | ||
| gcloud storage cp gs://api-codegen/_latest downloads --recursive | ||
|
|
||
| regenerate: clean download | ||
| # Remove problematic query param | ||
| jq 'walk(if type == "array" then map(if type == "object" then select(.name != "filter") else . end) else . end)' downloads/_latest/openapi/pinecone_api.json > tmp.json | ||
| mv tmp.json downloads/_latest/openapi/pinecone_api.json | ||
|
|
||
| license: | ||
| # Add license header using https://github.com/google/addlicense. | ||
| # If the license header already exists in a file, re-running this command has no effect. | ||
| pushd ${mkfile_path}/pinecone && \ | ||
| docker run --rm -it -v ${mkfile_path}/pinecone:/src ghcr.io/google/addlicense:latest -f ./license_header.txt *.py */*.py */*/*.py */*/*/*.py */*/*/*/*.py */*/*/*/*/*.py */*/*/*/*/*/*.py; \ | ||
| popd | ||
|
|
||
| set-production: | ||
| echo "production" > pinecone/__environment__ | ||
|
|
||
| set-development: | ||
| echo "" > pinecone/__environment__ | ||
| # Generate new openapi rest client | ||
| rm -rf pinecone/core | ||
| mkdir -p pinecone/core | ||
| docker run --rm -v ${mkfile_path}:/workspace openapitools/openapi-generator-cli:v5.2.0 generate \ | ||
| --input-spec /workspace/downloads/_latest/openapi/pinecone_api.json \ | ||
| --config /workspace/codegen/openapi/openapi-generator-args.python.json \ | ||
| --generator-name python \ | ||
| --template-dir /workspace/codegen/openapi/templates5.2.0 \ | ||
| --output /workspace/gen/python | ||
| cp -r ${mkfile_path}gen/python/pinecone/core/* ${mkfile_path}pinecone/core/ | ||
|
|
||
| # Update grpc client | ||
| mkdir -p pinecone/core/grpc/protos | ||
| cp -r ${mkfile_path}downloads/_latest/python/pinecone/data/v1/* ${mkfile_path}pinecone/core/grpc/protos | ||
| sed -i '' 's|pinecone\.data\.v1|pinecone.core.grpc.protos|g' pinecone/core/grpc/protos/vector_service_pb2_grpc.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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "packageName": "pinecone.core.client", | ||
| "pythonAttrNoneIfUnset": true | ||
| } |
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,55 @@ | ||
| # {{{projectName}}} | ||
| {{#appDescriptionWithNewLines}} | ||
| {{{appDescriptionWithNewLines}}} | ||
| {{/appDescriptionWithNewLines}} | ||
|
|
||
| This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: | ||
|
|
||
| - API version: {{appVersion}} | ||
| - Package version: {{packageVersion}} | ||
| {{^hideGenerationTimestamp}} | ||
| - Build date: {{generatedDate}} | ||
| {{/hideGenerationTimestamp}} | ||
| - Build package: {{generatorClass}} | ||
| {{#infoUrl}} | ||
| For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) | ||
| {{/infoUrl}} | ||
|
|
||
| ## Requirements. | ||
|
|
||
| Python >= 3.6 | ||
|
|
||
| ## Installation & Usage | ||
| ### pip install | ||
|
|
||
| If the python package is hosted on a repository, you can install directly using: | ||
|
|
||
| ```sh | ||
| pip install git+https://{{gitHost}}/{{{gitUserId}}}/{{{gitRepoId}}}.git | ||
| ``` | ||
| (you may need to run `pip` with root permission: `sudo pip install git+https://{{gitHost}}/{{{gitUserId}}}/{{{gitRepoId}}}.git`) | ||
|
|
||
| Then import the package: | ||
| ```python | ||
| import {{{packageName}}} | ||
| ``` | ||
|
|
||
| ### 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 {{{packageName}}} | ||
| ``` | ||
|
|
||
| ## Getting Started | ||
|
|
||
| Please follow the [installation procedure](#installation--usage) and then run the following: | ||
|
|
||
| {{> README_common }} |
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,111 @@ | ||
| ```python | ||
| {{#apiInfo}}{{#apis}}{{#-last}}{{#hasHttpSignatureMethods}}import datetime{{/hasHttpSignatureMethods}}{{/-last}}{{/apis}}{{/apiInfo}} | ||
| import time | ||
| import {{{packageName}}} | ||
| from pprint import pprint | ||
| {{#apiInfo}} | ||
| {{#apis}} | ||
| {{#-first}} | ||
| from {{apiPackage}} import {{classVarName}} | ||
| {{#imports}} | ||
| {{{import}}} | ||
| {{/imports}} | ||
| {{#operations}} | ||
| {{#operation}} | ||
| {{#-first}} | ||
| {{> python_doc_auth_partial}} | ||
|
|
||
| # Enter a context with an instance of the API client | ||
| with {{{packageName}}}.ApiClient(configuration) as api_client: | ||
| # Create an instance of the API class | ||
| api_instance = {{classVarName}}.{{{classname}}}(api_client) | ||
| {{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} | ||
| {{/allParams}} | ||
|
|
||
| try: | ||
| {{#summary}} # {{{.}}} | ||
| {{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}){{#returnType}} | ||
| pprint(api_response){{/returnType}} | ||
| except {{{packageName}}}.PineconeApiException as e: | ||
| print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) | ||
| {{/-first}} | ||
| {{/operation}} | ||
| {{/operations}} | ||
| {{/-first}} | ||
| {{/apis}} | ||
| {{/apiInfo}} | ||
| ``` | ||
|
|
||
| ## Documentation for API Endpoints | ||
|
|
||
| All URIs are relative to *{{basePath}}* | ||
|
|
||
| Class | Method | HTTP request | Description | ||
| ------------ | ------------- | ------------- | ------------- | ||
| {{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} | ||
| {{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} | ||
|
|
||
| ## Documentation For Models | ||
|
|
||
| {{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}{{{classname}}}.md) | ||
| {{/model}}{{/models}} | ||
|
|
||
| ## Documentation For Authorization | ||
|
|
||
| {{^authMethods}} | ||
| All endpoints do not require authorization. | ||
| {{/authMethods}} | ||
| {{#authMethods}} | ||
| {{#last}} Authentication schemes defined for the API:{{/last}} | ||
| ## {{{name}}} | ||
|
|
||
| {{#isApiKey}} | ||
| - **Type**: API key | ||
| - **API key parameter name**: {{{keyParamName}}} | ||
| - **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}} | ||
| {{/isApiKey}} | ||
| {{#isBasic}} | ||
| {{#isBasicBasic}} | ||
| - **Type**: HTTP basic authentication | ||
| {{/isBasicBasic}} | ||
| {{#isBasicBearer}} | ||
| - **Type**: Bearer authentication{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} | ||
| {{/isBasicBearer}} | ||
| {{#isHttpSignature}} | ||
| - **Type**: HTTP signature authentication | ||
| {{/isHttpSignature}} | ||
| {{/isBasic}} | ||
| {{#isOAuth}} | ||
| - **Type**: OAuth | ||
| - **Flow**: {{{flow}}} | ||
| - **Authorization URL**: {{{authorizationUrl}}} | ||
| - **Scopes**: {{^scopes}}N/A{{/scopes}} | ||
| {{#scopes}} - **{{{scope}}}**: {{{description}}} | ||
| {{/scopes}} | ||
| {{/isOAuth}} | ||
|
|
||
| {{/authMethods}} | ||
|
|
||
| ## Author | ||
|
|
||
| {{#apiInfo}}{{#apis}}{{#-last}}{{infoEmail}} | ||
| {{/-last}}{{/apis}}{{/apiInfo}} | ||
|
|
||
| ## Notes for Large OpenAPI documents | ||
| If the OpenAPI document is large, imports in {{{packageName}}}.apis and {{{packageName}}}.models may fail with a | ||
| RecursionError indicating the maximum recursion limit has been exceeded. In that case, there are a couple of solutions: | ||
|
|
||
| Solution 1: | ||
| Use specific imports for apis and models like: | ||
| - `from {{{packageName}}}.api.default_api import DefaultApi` | ||
| - `from {{{packageName}}}.model.pet import Pet` | ||
|
|
||
| Solution 2: | ||
| Before importing the package, adjust the maximum recursion limit as shown below: | ||
| ``` | ||
| import sys | ||
| sys.setrecursionlimit(1500) | ||
| import {{{packageName}}} | ||
| from {{{packageName}}}.apis import * | ||
| from {{{packageName}}}.models import * | ||
| ``` |
42 changes: 42 additions & 0 deletions
42
codegen/openapi/templates5.2.0/README_onlypackage.mustache
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,42 @@ | ||
| # {{{projectName}}} | ||
| {{#appDescription}} | ||
| {{{appDescription}}} | ||
| {{/appDescription}} | ||
|
|
||
| The `{{packageName}}` package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: | ||
|
|
||
| - API version: {{appVersion}} | ||
| - Package version: {{packageVersion}} | ||
| {{^hideGenerationTimestamp}} | ||
| - Build date: {{generatedDate}} | ||
| {{/hideGenerationTimestamp}} | ||
| - Build package: {{generatorClass}} | ||
| {{#infoUrl}} | ||
| For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) | ||
| {{/infoUrl}} | ||
|
|
||
| ## Requirements. | ||
|
|
||
| Python >= 3.6 | ||
|
|
||
| ## Installation & Usage | ||
|
|
||
| This python library package is generated without supporting files like setup.py or requirements files | ||
|
|
||
| To be able to use it, you will need these dependencies in your own package that uses this library: | ||
|
|
||
| * urllib3 >= 1.25.3 | ||
| * python-dateutil | ||
| {{#asyncio}} | ||
| * aiohttp | ||
| {{/asyncio}} | ||
| {{#tornado}} | ||
| * tornado>=4.2,<5 | ||
| {{/tornado}} | ||
|
|
||
| ## Getting Started | ||
|
|
||
| In your own code, to use this library to connect and interact with {{{projectName}}}, | ||
| you can run the following: | ||
|
|
||
| {{> README_common }} |
Empty file.
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,9 @@ | ||
| {{#apiInfo}} | ||
| {{#apis}} | ||
| {{#-first}} | ||
| # do not import all apis into this module because that uses a lot of memory and stack frames | ||
| # if you need the ability to import all apis from one package, import them with | ||
| # from {{packageName}}.apis import {{classname}} | ||
| {{/-first}} | ||
| {{/apis}} | ||
| {{/apiInfo}} |
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 @@ | ||
| {{#apiInfo}} | ||
| {{#apis}} | ||
| {{#-first}} | ||
|
|
||
| # flake8: noqa | ||
|
|
||
| # Import all APIs into this package. | ||
| # If you have many APIs here with many many models used in each API this may | ||
| # raise a `RecursionError`. | ||
| # In order to avoid this, import only the API that you directly need like: | ||
| # | ||
| # from {{packagename}}.api.{{classVarName}} import {{classname}} | ||
| # | ||
| # or import this package, but before doing it, use: | ||
| # | ||
| # import sys | ||
| # sys.setrecursionlimit(n) | ||
|
|
||
| # Import APIs into API package: | ||
| {{/-first}} | ||
| from {{apiPackage}}.{{classVarName}} import {{classname}} | ||
| {{/apis}} | ||
| {{/apiInfo}} |
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 @@ | ||
| # we can not import model classes here because that would create a circular | ||
| # reference which would not work in python2 | ||
| # do not import all models into this module because that uses a lot of memory and stack frames | ||
| # if you need the ability to import all models from one package, import them with | ||
| # from {{packageName}.models import ModelA, ModelB |
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,16 @@ | ||
| # flake8: noqa | ||
|
|
||
| # import all models into this package | ||
| # if you have many models here with many references from one model to another this may | ||
| # raise a RecursionError | ||
| # to avoid this, import only the models that you directly need like: | ||
| # from from {{modelPackage}}.pet import Pet | ||
| # or import this package, but before doing it, use: | ||
| # import sys | ||
| # sys.setrecursionlimit(n) | ||
|
|
||
| {{#models}} | ||
| {{#model}} | ||
| from {{modelPackage}}.{{classFilename}} import {{classname}} | ||
| {{/model}} | ||
| {{/models}} |
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,26 @@ | ||
| # flake8: noqa | ||
|
|
||
| {{>partial_header}} | ||
|
|
||
| __version__ = "{{packageVersion}}" | ||
|
|
||
| # import ApiClient | ||
| from {{packageName}}.api_client import ApiClient | ||
|
|
||
| # import Configuration | ||
| from {{packageName}}.configuration import Configuration | ||
| {{#hasHttpSignatureMethods}} | ||
| from {{packageName}}.signing import HttpSigningConfiguration | ||
| {{/hasHttpSignatureMethods}} | ||
|
|
||
| # import exceptions | ||
| from {{packageName}}.exceptions import PineconeException | ||
| from {{packageName}}.exceptions import PineconeApiAttributeError | ||
| from {{packageName}}.exceptions import PineconeApiTypeError | ||
| from {{packageName}}.exceptions import PineconeApiValueError | ||
| from {{packageName}}.exceptions import PineconeApiKeyError | ||
| from {{packageName}}.exceptions import PineconeApiException | ||
| {{#recursionLimit}} | ||
|
|
||
| __import__('sys').setrecursionlimit({{{.}}}) | ||
| {{/recursionLimit}} |
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
Query params with type
objectseem to break the python generator. See OpenAPITools/openapi-generator#1587This jq command is doing a bit of surgery on the spec file to remove a query param called
filterwith typeobject.