From 5cea1b57b3a86abce9829ba74fca42d30091128f Mon Sep 17 00:00:00 2001 From: "Daniel (dB.) Doubrovkine" Date: Thu, 26 Oct 2023 11:55:25 -0400 Subject: [PATCH] Add a nox session for client generator. (#554) Signed-off-by: dblock Signed-off-by: roma2023 --- CHANGELOG.md | 1 + DEVELOPER_GUIDE.md | 14 ++++++-------- noxfile.py | 7 +++++++ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6803cf4c..2a9955a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Added guide on making raw JSON REST requests ([#542](https://github.com/opensearch-project/opensearch-py/pull/542)) - Added support for AWS SigV4 for urllib3 ([#547](https://github.com/opensearch-project/opensearch-py/pull/547)) - Added `remote store` client APIs ([#552](https://github.com/opensearch-project/opensearch-py/pull/552)) +- Added `nox -rs generate` ([#554](https://github.com/opensearch-project/opensearch-py/pull/554)) ### Changed - Generate `tasks` client from API specs ([#508](https://github.com/opensearch-project/opensearch-py/pull/508)) - Generate `ingest` client from API specs ([#513](https://github.com/opensearch-project/opensearch-py/pull/513)) diff --git a/DEVELOPER_GUIDE.md b/DEVELOPER_GUIDE.md index 5fe9cad1..dd1fad26 100644 --- a/DEVELOPER_GUIDE.md +++ b/DEVELOPER_GUIDE.md @@ -1,10 +1,10 @@ - [Developer Guide](#developer-guide) - [Prerequisites](#prerequisites) - - [Docker Image Installation](#docker-setup) + - [Install Docker Image](#install-docker-image) - [Running Tests](#running-tests) - - [Integration Tests](#integration-tests) + - [Linter](#linter) - [Documentation](#documentation) - - [Running Python Client Generator](#running-python-client-generator) + - [Client Code Generator](#client-code-generator) # Developer Guide @@ -115,12 +115,10 @@ make html Open `opensearch-py/docs/build/html/index.html` to see results. -## Running Python Client Generator +## Client Code Generator -The following code executes a python client generator that updates the client by utilizing the [openapi specifications](https://github.com/opensearch-project/opensearch-api-specification/blob/main/OpenSearch.openapi.json) found in the "opensearch-api-specification" repository. This process allows for the automatic generation and synchronization of the client code with the latest API specifications. +OpenSearch publishes an [OpenAPI specification](https://github.com/opensearch-project/opensearch-api-specification/blob/main/OpenSearch.openapi.json) in the [opensearch-api-specification](https://github.com/opensearch-project/opensearch-api-specification) repository, which is used to auto-generate the less interesting parts of the client. ``` -cd opensearch-py -python utils/generate-api.py -nox -rs format +nox -rs generate ``` diff --git a/noxfile.py b/noxfile.py index 6b734b48..ba2fe7b9 100644 --- a/noxfile.py +++ b/noxfile.py @@ -87,3 +87,10 @@ def docs(session): "-rdev-requirements.txt", "sphinx-rtd-theme", "sphinx-autodoc-typehints" ) session.run("python", "-m", "pip", "install", "sphinx-autodoc-typehints") + + +@nox.session() +def generate(session): + session.install("-rdev-requirements.txt") + session.run("python", "utils/generate-api.py") + format(session)