Skip to content

Commit

Permalink
Merge branch 'main' into fix/issue352/document-lifecycle-guide-and-sa…
Browse files Browse the repository at this point in the history
…mple

Signed-off-by: DJ Carrillo  <[email protected]>
  • Loading branch information
Djcarrillo6 authored Oct 27, 2023
2 parents 15ea292 + bcfef11 commit 9a7463f
Show file tree
Hide file tree
Showing 284 changed files with 5,840 additions and 4,805 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Generate `cluster` client from API specs ([#530](https://github.com/opensearch-project/opensearch-py/pull/530))
- Generate `nodes` client from API specs ([#514](https://github.com/opensearch-project/opensearch-py/pull/514))
- Generate `cat` client from API specs ([#529](https://github.com/opensearch-project/opensearch-py/pull/529))
- Use API generator for all APIs ([#551](https://github.com/opensearch-project/opensearch-py/pull/551))
### Deprecated
- Deprecated point-in-time APIs (list_all_point_in_time, create_point_in_time, delete_point_in_time) and Security Client APIs (health_check and update_audit_config) ([#502](https://github.com/opensearch-project/opensearch-py/pull/502))
### Removed
Expand Down
14 changes: 6 additions & 8 deletions DEVELOPER_GUIDE.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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
```
6 changes: 5 additions & 1 deletion benchmarks/bench_async.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
#!/usr/bin/env python

# -*- coding: utf-8 -*-
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.
#
# Modifications Copyright OpenSearch Contributors. See
# GitHub history for details.

import asyncio
import uuid
Expand All @@ -24,7 +28,7 @@ async def index_records(client, item_count):
client.index(
index=index_name,
body={
"title": f"Moneyball",
"title": "Moneyball",
"director": "Bennett Miller",
"year": "2011",
},
Expand Down
7 changes: 6 additions & 1 deletion benchmarks/bench_info_sync.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
#!/usr/bin/env python

# -*- coding: utf-8 -*-
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.
#
# Modifications Copyright OpenSearch Contributors. See
# GitHub history for details.


import logging
import sys
Expand Down Expand Up @@ -35,7 +40,7 @@ def get_info(client, request_count):
tt = 0
for n in range(request_count):
start = time.time() * 1000
rc = client.info()
client.info()
total_time = time.time() * 1000 - start
tt += total_time
return tt
Expand Down
9 changes: 6 additions & 3 deletions benchmarks/bench_sync.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
#!/usr/bin/env python

# -*- coding: utf-8 -*-
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.
#
# Modifications Copyright OpenSearch Contributors. See
# GitHub history for details.

import json
import logging
import sys
import time
import uuid

Expand All @@ -20,9 +26,6 @@
index_name = "test-index-sync"
item_count = 1000

import logging
import sys

root = logging.getLogger()
# root.setLevel(logging.DEBUG)
# logging.getLogger("urllib3.connectionpool").setLevel(logging.DEBUG)
Expand Down
5 changes: 5 additions & 0 deletions benchmarks/bench_sync_async.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
#!/usr/bin/env python

# -*- coding: utf-8 -*-
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.
#
# Modifications Copyright OpenSearch Contributors. See
# GitHub history for details.


import bench_async
import bench_sync
Expand Down
7 changes: 5 additions & 2 deletions benchmarks/thread_with_return_value.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#!/usr/bin/env python

# -*- coding: utf-8 -*-
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.
#
# Modifications Copyright OpenSearch Contributors. See
# GitHub history for details.


from threading import Thread

Expand Down
1 change: 1 addition & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ sphinx<7.3
sphinx_rtd_theme
jinja2
pytz
deepmerge

# No wheels for Python 3.10 yet!
numpy; python_version<"3.10"
Expand Down
9 changes: 9 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.
#
# Modifications Copyright OpenSearch Contributors. See
# GitHub history for details.

# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
Expand Down
11 changes: 11 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
Expand Down Expand Up @@ -33,6 +34,9 @@
"opensearchpy/",
"test_opensearchpy/",
"utils/",
"samples/",
"benchmarks/",
"docs/",
)


Expand Down Expand Up @@ -87,3 +91,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)
1 change: 1 addition & 0 deletions opensearchpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
Expand Down
1 change: 1 addition & 0 deletions opensearchpy/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
Expand Down
1 change: 1 addition & 0 deletions opensearchpy/_async/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
Expand Down
1 change: 1 addition & 0 deletions opensearchpy/_async/_extra_imports.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
Expand Down
Loading

0 comments on commit 9a7463f

Please sign in to comment.