diff --git a/README.md b/README.md index 11181367..5e1aacc5 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ pip install git+https://github.com/opensearch-project/opensearch-py.git Then import it like any other module: ```python -from opensearch import OpenSearch +from opensearchpy import OpenSearch ``` If you prefer to add the client manually or just want to examine the source code, see [opensearch-py on GitHub](https://github.com/opensearch-project/opensearch-py). @@ -41,7 +41,7 @@ If you prefer to add the client manually or just want to examine the source code ## Sample code ```python -from opensearch import OpenSearch +from opensearchpy import OpenSearch host = 'localhost' port = 9200 diff --git a/noxfile.py b/noxfile.py index 1f08f3b3..08922c62 100644 --- a/noxfile.py +++ b/noxfile.py @@ -29,8 +29,8 @@ import nox SOURCE_FILES = ( "setup.py", "noxfile.py", - "opensearch/", - "test_opensearch/", + "opensearchpy/", + "test_opensearchpy/", "utils/", ) @@ -68,15 +68,15 @@ def lint(session): # Run mypy on the package and then the type examples separately for # the two different mypy use-cases, ourselves and our users. - session.run("mypy", "--strict", "opensearch/") - session.run("mypy", "--strict", "test_opensearch/test_types/sync_types.py") - session.run("mypy", "--strict", "test_opensearch/test_types/async_types.py") + session.run("mypy", "--strict", "opensearchpy/") + session.run("mypy", "--strict", "test_opensearchpy/test_types/sync_types.py") + session.run("mypy", "--strict", "test_opensearchpy/test_types/async_types.py") # Make sure we don't require aiohttp to be installed for users to # receive type hint information from mypy. session.run("python", "-m", "pip", "uninstall", "--yes", "aiohttp") - session.run("mypy", "--strict", "opensearch/") - session.run("mypy", "--strict", "test_opensearch/test_types/sync_types.py") + session.run("mypy", "--strict", "opensearchpy/") + session.run("mypy", "--strict", "test_opensearchpy/test_types/sync_types.py") @nox.session() diff --git a/opensearch/__init__.py b/opensearchpy/__init__.py similarity index 100% rename from opensearch/__init__.py rename to opensearchpy/__init__.py diff --git a/opensearch/__init__.pyi b/opensearchpy/__init__.pyi similarity index 100% rename from opensearch/__init__.pyi rename to opensearchpy/__init__.pyi diff --git a/opensearch/_async/__init__.py b/opensearchpy/_async/__init__.py similarity index 100% rename from opensearch/_async/__init__.py rename to opensearchpy/_async/__init__.py diff --git a/opensearch/_async/_extra_imports.py b/opensearchpy/_async/_extra_imports.py similarity index 100% rename from opensearch/_async/_extra_imports.py rename to opensearchpy/_async/_extra_imports.py diff --git a/opensearch/_async/client/__init__.py b/opensearchpy/_async/client/__init__.py similarity index 98% rename from opensearch/_async/client/__init__.py rename to opensearchpy/_async/client/__init__.py index 815e2926..cf33ae1d 100644 --- a/opensearch/_async/client/__init__.py +++ b/opensearchpy/_async/client/__init__.py @@ -52,13 +52,13 @@ class AsyncOpenSearch(object): The instance has attributes ``cat``, ``cluster``, ``indices``, ``ingest``, ``nodes``, ``snapshot`` and ``tasks`` that provide access to instances of - :class:`~opensearch.client.CatClient`, - :class:`~opensearch.client.ClusterClient`, - :class:`~opensearch.client.IndicesClient`, - :class:`~opensearch.client.IngestClient`, - :class:`~opensearch.client.NodesClient`, - :class:`~opensearch.client.SnapshotClient` and - :class:`~opensearch.client.TasksClient` respectively. This is the + :class:`~opensearchpy.client.CatClient`, + :class:`~opensearchpy.client.ClusterClient`, + :class:`~opensearchpy.client.IndicesClient`, + :class:`~opensearchpy.client.IngestClient`, + :class:`~opensearchpy.client.NodesClient`, + :class:`~opensearchpy.client.SnapshotClient` and + :class:`~opensearchpy.client.TasksClient` respectively. This is the preferred (and only supported) way to get access to those classes and their methods. @@ -69,7 +69,7 @@ class AsyncOpenSearch(object): client = OpenSearch(connection_class=ThriftConnection) If you want to turn on :ref:`sniffing` you have several options (described - in :class:`~opensearch.Transport`):: + in :class:`~opensearchpy.Transport`):: # create connection that will automatically inspect the cluster to get # the list of active nodes. Start with nodes running on @@ -95,7 +95,7 @@ class AsyncOpenSearch(object): ]) If using SSL, there are several parameters that control how we deal with - certificates (see :class:`~opensearch.Urllib3HttpConnection` for + certificates (see :class:`~opensearchpy.Urllib3HttpConnection` for detailed description of the options):: client = OpenSearch( @@ -109,7 +109,7 @@ class AsyncOpenSearch(object): ) If using SSL, but don't verify the certs, a warning message is showed - optionally (see :class:`~opensearch.Urllib3HttpConnection` for + optionally (see :class:`~opensearchpy.Urllib3HttpConnection` for detailed description of the options):: client = OpenSearch( @@ -123,7 +123,7 @@ class AsyncOpenSearch(object): ) SSL client authentication is supported - (see :class:`~opensearch.Urllib3HttpConnection` for + (see :class:`~opensearchpy.Urllib3HttpConnection` for detailed description of the options):: client = OpenSearch( @@ -156,7 +156,7 @@ class AsyncOpenSearch(object): is used to encode all outgoing requests. However, you can implement your own custom serializer:: - from opensearch.serializer import JSONSerializer + from opensearchpy.serializer import JSONSerializer class SetEncoder(JSONSerializer): def default(self, obj): @@ -174,16 +174,16 @@ class AsyncOpenSearch(object): """ :arg hosts: list of nodes, or a single node, we should connect to. Node should be a dictionary ({"host": "localhost", "port": 9200}), - the entire dictionary will be passed to the :class:`~opensearch.Connection` + the entire dictionary will be passed to the :class:`~opensearchpy.Connection` class as kwargs, or a string in the format of ``host[:port]`` which will be translated to a dictionary automatically. If no value is given the - :class:`~opensearch.Connection` class defaults will be used. + :class:`~opensearchpy.Connection` class defaults will be used. - :arg transport_class: :class:`~opensearch.Transport` subclass to use. + :arg transport_class: :class:`~opensearchpy.Transport` subclass to use. :arg kwargs: any additional arguments will be passed on to the - :class:`~opensearch.Transport` class and, subsequently, to the - :class:`~opensearch.Connection` instances. + :class:`~opensearchpy.Transport` class and, subsequently, to the + :class:`~opensearchpy.Connection` instances. """ self.transport = transport_class(_normalize_hosts(hosts), **kwargs) diff --git a/opensearch/_async/client/__init__.pyi b/opensearchpy/_async/client/__init__.pyi similarity index 100% rename from opensearch/_async/client/__init__.pyi rename to opensearchpy/_async/client/__init__.pyi diff --git a/opensearch/_async/client/cat.py b/opensearchpy/_async/client/cat.py similarity index 100% rename from opensearch/_async/client/cat.py rename to opensearchpy/_async/client/cat.py diff --git a/opensearch/_async/client/cat.pyi b/opensearchpy/_async/client/cat.pyi similarity index 100% rename from opensearch/_async/client/cat.pyi rename to opensearchpy/_async/client/cat.pyi diff --git a/opensearch/_async/client/cluster.py b/opensearchpy/_async/client/cluster.py similarity index 100% rename from opensearch/_async/client/cluster.py rename to opensearchpy/_async/client/cluster.py diff --git a/opensearch/_async/client/cluster.pyi b/opensearchpy/_async/client/cluster.pyi similarity index 100% rename from opensearch/_async/client/cluster.pyi rename to opensearchpy/_async/client/cluster.pyi diff --git a/opensearch/_async/client/dangling_indices.py b/opensearchpy/_async/client/dangling_indices.py similarity index 100% rename from opensearch/_async/client/dangling_indices.py rename to opensearchpy/_async/client/dangling_indices.py diff --git a/opensearch/_async/client/dangling_indices.pyi b/opensearchpy/_async/client/dangling_indices.pyi similarity index 100% rename from opensearch/_async/client/dangling_indices.pyi rename to opensearchpy/_async/client/dangling_indices.pyi diff --git a/opensearch/_async/client/features.py b/opensearchpy/_async/client/features.py similarity index 100% rename from opensearch/_async/client/features.py rename to opensearchpy/_async/client/features.py diff --git a/opensearch/_async/client/features.pyi b/opensearchpy/_async/client/features.pyi similarity index 100% rename from opensearch/_async/client/features.pyi rename to opensearchpy/_async/client/features.pyi diff --git a/opensearch/_async/client/indices.py b/opensearchpy/_async/client/indices.py similarity index 100% rename from opensearch/_async/client/indices.py rename to opensearchpy/_async/client/indices.py diff --git a/opensearch/_async/client/indices.pyi b/opensearchpy/_async/client/indices.pyi similarity index 100% rename from opensearch/_async/client/indices.pyi rename to opensearchpy/_async/client/indices.pyi diff --git a/opensearch/_async/client/ingest.py b/opensearchpy/_async/client/ingest.py similarity index 100% rename from opensearch/_async/client/ingest.py rename to opensearchpy/_async/client/ingest.py diff --git a/opensearch/_async/client/ingest.pyi b/opensearchpy/_async/client/ingest.pyi similarity index 100% rename from opensearch/_async/client/ingest.pyi rename to opensearchpy/_async/client/ingest.pyi diff --git a/opensearch/_async/client/nodes.py b/opensearchpy/_async/client/nodes.py similarity index 100% rename from opensearch/_async/client/nodes.py rename to opensearchpy/_async/client/nodes.py diff --git a/opensearch/_async/client/nodes.pyi b/opensearchpy/_async/client/nodes.pyi similarity index 100% rename from opensearch/_async/client/nodes.pyi rename to opensearchpy/_async/client/nodes.pyi diff --git a/opensearch/_async/client/remote.py b/opensearchpy/_async/client/remote.py similarity index 100% rename from opensearch/_async/client/remote.py rename to opensearchpy/_async/client/remote.py diff --git a/opensearch/_async/client/remote.pyi b/opensearchpy/_async/client/remote.pyi similarity index 100% rename from opensearch/_async/client/remote.pyi rename to opensearchpy/_async/client/remote.pyi diff --git a/opensearch/_async/client/snapshot.py b/opensearchpy/_async/client/snapshot.py similarity index 100% rename from opensearch/_async/client/snapshot.py rename to opensearchpy/_async/client/snapshot.py diff --git a/opensearch/_async/client/snapshot.pyi b/opensearchpy/_async/client/snapshot.pyi similarity index 100% rename from opensearch/_async/client/snapshot.pyi rename to opensearchpy/_async/client/snapshot.pyi diff --git a/opensearch/_async/client/tasks.py b/opensearchpy/_async/client/tasks.py similarity index 100% rename from opensearch/_async/client/tasks.py rename to opensearchpy/_async/client/tasks.py diff --git a/opensearch/_async/client/tasks.pyi b/opensearchpy/_async/client/tasks.pyi similarity index 100% rename from opensearch/_async/client/tasks.pyi rename to opensearchpy/_async/client/tasks.pyi diff --git a/opensearch/_async/client/utils.py b/opensearchpy/_async/client/utils.py similarity index 100% rename from opensearch/_async/client/utils.py rename to opensearchpy/_async/client/utils.py diff --git a/opensearch/_async/client/utils.pyi b/opensearchpy/_async/client/utils.pyi similarity index 100% rename from opensearch/_async/client/utils.pyi rename to opensearchpy/_async/client/utils.pyi diff --git a/opensearch/_async/compat.py b/opensearchpy/_async/compat.py similarity index 100% rename from opensearch/_async/compat.py rename to opensearchpy/_async/compat.py diff --git a/opensearch/_async/compat.pyi b/opensearchpy/_async/compat.pyi similarity index 100% rename from opensearch/_async/compat.pyi rename to opensearchpy/_async/compat.pyi diff --git a/opensearch/_async/helpers.py b/opensearchpy/_async/helpers.py similarity index 92% rename from opensearch/_async/helpers.py rename to opensearchpy/_async/helpers.py index eaf1471a..b39b816f 100644 --- a/opensearch/_async/helpers.py +++ b/opensearchpy/_async/helpers.py @@ -42,7 +42,7 @@ from ..helpers.actions import ( from ..helpers.errors import ScanError from .client import AsyncOpenSearch # noqa -logger = logging.getLogger("opensearch.helpers") +logger = logging.getLogger("opensearchpy.helpers") async def _chunk_actions(actions, chunk_size, max_chunk_bytes, serializer): @@ -146,7 +146,7 @@ async def async_streaming_bulk( """ Streaming bulk consumes actions from the iterable passed in and yields results per action. For non-streaming usecases use - :func:`~opensearch.helpers.async_bulk` which is a wrapper around streaming + :func:`~opensearchpy.helpers.async_bulk` which is a wrapper around streaming bulk that returns summary information about the bulk operation once the entire input is consumed and sent. @@ -156,7 +156,7 @@ async def async_streaming_bulk( every subsequent rejection for the same chunk, for double the time every time up to ``max_backoff`` seconds. - :arg client: instance of :class:`~opensearch.AsyncOpenSearch` to use + :arg client: instance of :class:`~opensearchpy.AsyncOpenSearch` to use :arg actions: iterable or async iterable containing the actions to be executed :arg chunk_size: number of docs in one chunk sent to client (default: 500) :arg max_chunk_bytes: the maximum size of the request in bytes (default: 100MB) @@ -242,7 +242,7 @@ async def async_bulk( client, actions, stats_only=False, ignore_status=(), *args, **kwargs ): """ - Helper for the :meth:`~opensearch.AsyncOpenSearch.bulk` api that provides + Helper for the :meth:`~opensearchpy.AsyncOpenSearch.bulk` api that provides a more human friendly interface - it consumes an iterator of actions and sends them to opensearch in chunks. It returns a tuple with summary information - number of successfully executed actions and either list of @@ -254,19 +254,19 @@ async def async_bulk( When errors are being collected original document data is included in the error dictionary which can lead to an extra high memory usage. If you need to process a lot of data and want to ignore/collect errors please consider - using the :func:`~opensearch.helpers.async_streaming_bulk` helper which will + using the :func:`~opensearchpy.helpers.async_streaming_bulk` helper which will just return the errors and not store them in memory. - :arg client: instance of :class:`~opensearch.AsyncOpenSearch` to use + :arg client: instance of :class:`~opensearchpy.AsyncOpenSearch` to use :arg actions: iterator containing the actions :arg stats_only: if `True` only report number of successful/failed operations instead of just number of successful and a list of error responses :arg ignore_status: list of HTTP status code that you want to ignore Any additional keyword arguments will be passed to - :func:`~opensearch.helpers.async_streaming_bulk` which is used to execute - the operation, see :func:`~opensearch.helpers.async_streaming_bulk` for more + :func:`~opensearchpy.helpers.async_streaming_bulk` which is used to execute + the operation, see :func:`~opensearchpy.helpers.async_streaming_bulk` for more accepted parameters. """ success, failed = 0, 0 @@ -304,7 +304,7 @@ async def async_scan( ): """ Simple abstraction on top of the - :meth:`~opensearch.AsyncOpenSearch.scroll` api - a simple iterator that + :meth:`~opensearchpy.AsyncOpenSearch.scroll` api - a simple iterator that yields all hits as returned by underlining scroll requests. By default scan does not return results in any pre-determined order. To @@ -313,8 +313,8 @@ async def async_scan( may be an expensive operation and will negate the performance benefits of using ``scan``. - :arg client: instance of :class:`~opensearch.AsyncOpenSearch` to use - :arg query: body for the :meth:`~opensearch.AsyncOpenSearch.search` api + :arg client: instance of :class:`~opensearchpy.AsyncOpenSearch` to use + :arg query: body for the :meth:`~opensearchpy.AsyncOpenSearch.search` api :arg scroll: Specify how long a consistent view of the index should be maintained for scrolled search :arg raise_on_error: raises an exception (``ScanError``) if an error is @@ -329,10 +329,10 @@ async def async_scan( scroll API at the end of the method on completion or error, defaults to true. :arg scroll_kwargs: additional kwargs to be passed to - :meth:`~opensearch.AsyncOpenSearch.scroll` + :meth:`~opensearchpy.AsyncOpenSearch.scroll` Any additional keyword arguments will be passed to the initial - :meth:`~opensearch.AsyncOpenSearch.search` call:: + :meth:`~opensearchpy.AsyncOpenSearch.search` call:: async_scan(client, query={"query": {"match": {"title": "python"}}}, @@ -427,7 +427,7 @@ async def async_reindex( to another, potentially (if `target_client` is specified) on a different cluster. If you don't specify the query you will reindex all the documents. - Since ``2.3`` a :meth:`~opensearch.AsyncOpenSearch.reindex` api is + Since ``2.3`` a :meth:`~opensearchpy.AsyncOpenSearch.reindex` api is available as part of opensearch itself. It is recommended to use the api instead of this helper wherever possible. The helper is here mostly for backwards compatibility and for situations where more flexibility is @@ -437,20 +437,20 @@ async def async_reindex( This helper doesn't transfer mappings, just the data. - :arg client: instance of :class:`~opensearch.AsyncOpenSearch` to use (for + :arg client: instance of :class:`~opensearchpy.AsyncOpenSearch` to use (for read if `target_client` is specified as well) :arg source_index: index (or list of indices) to read documents from :arg target_index: name of the index in the target cluster to populate - :arg query: body for the :meth:`~opensearch.AsyncOpenSearch.search` api + :arg query: body for the :meth:`~opensearchpy.AsyncOpenSearch.search` api :arg target_client: optional, is specified will be used for writing (thus enabling reindex between clusters) :arg chunk_size: number of docs in one chunk sent to client (default: 500) :arg scroll: Specify how long a consistent view of the index should be maintained for scrolled search :arg scan_kwargs: additional kwargs to be passed to - :func:`~opensearch.helpers.async_scan` + :func:`~opensearchpy.helpers.async_scan` :arg bulk_kwargs: additional kwargs to be passed to - :func:`~opensearch.helpers.async_bulk` + :func:`~opensearchpy.helpers.async_bulk` """ target_client = client if target_client is None else target_client docs = async_scan( diff --git a/opensearch/_async/helpers.pyi b/opensearchpy/_async/helpers.pyi similarity index 100% rename from opensearch/_async/helpers.pyi rename to opensearchpy/_async/helpers.pyi diff --git a/opensearch/_async/http_aiohttp.py b/opensearchpy/_async/http_aiohttp.py similarity index 100% rename from opensearch/_async/http_aiohttp.py rename to opensearchpy/_async/http_aiohttp.py diff --git a/opensearch/_async/http_aiohttp.pyi b/opensearchpy/_async/http_aiohttp.pyi similarity index 100% rename from opensearch/_async/http_aiohttp.pyi rename to opensearchpy/_async/http_aiohttp.pyi diff --git a/opensearch/_async/transport.py b/opensearchpy/_async/transport.py similarity index 97% rename from opensearch/_async/transport.py rename to opensearchpy/_async/transport.py index aef67a5e..14aebd94 100644 --- a/opensearch/_async/transport.py +++ b/opensearchpy/_async/transport.py @@ -56,8 +56,8 @@ class AsyncTransport(Transport): """ :arg hosts: list of dictionaries, each containing keyword arguments to create a `connection_class` instance - :arg connection_class: subclass of :class:`~opensearch.Connection` to use - :arg connection_pool_class: subclass of :class:`~opensearch.ConnectionPool` to use + :arg connection_class: subclass of :class:`~opensearchpy.Connection` to use + :arg connection_pool_class: subclass of :class:`~opensearchpy.ConnectionPool` to use :arg host_info_callback: callback responsible for taking the node information from `/_cluster/nodes`, along with already extracted information, and producing a list of arguments (same as `hosts` parameter) @@ -300,7 +300,7 @@ class AsyncTransport(Transport): Mark a connection as dead (failed) in the connection pool. If sniffing on failure is enabled this will initiate the sniffing process. - :arg connection: instance of :class:`~opensearch.Connection` that failed + :arg connection: instance of :class:`~opensearchpy.Connection` that failed """ self.connection_pool.mark_dead(connection) if self.sniff_on_connection_fail: @@ -324,9 +324,9 @@ class AsyncTransport(Transport): :arg method: HTTP method to use :arg url: absolute url (without host) to target :arg headers: dictionary of headers, will be handed over to the - underlying :class:`~opensearch.Connection` class + underlying :class:`~opensearchpy.Connection` class :arg params: dictionary of query parameters, will be handed over to the - underlying :class:`~opensearch.Connection` class for serialization + underlying :class:`~opensearchpy.Connection` class for serialization :arg body: body of the request, will be serialized using serializer and passed to the connection """ diff --git a/opensearch/_async/transport.pyi b/opensearchpy/_async/transport.pyi similarity index 100% rename from opensearch/_async/transport.pyi rename to opensearchpy/_async/transport.pyi diff --git a/opensearch/_version.py b/opensearchpy/_version.py similarity index 100% rename from opensearch/_version.py rename to opensearchpy/_version.py diff --git a/opensearch/client/__init__.py b/opensearchpy/client/__init__.py similarity index 98% rename from opensearch/client/__init__.py rename to opensearchpy/client/__init__.py index a314eb77..3ff2d73d 100644 --- a/opensearch/client/__init__.py +++ b/opensearchpy/client/__init__.py @@ -52,13 +52,13 @@ class OpenSearch(object): The instance has attributes ``cat``, ``cluster``, ``indices``, ``ingest``, ``nodes``, ``snapshot`` and ``tasks`` that provide access to instances of - :class:`~opensearch.client.CatClient`, - :class:`~opensearch.client.ClusterClient`, - :class:`~opensearch.client.IndicesClient`, - :class:`~opensearch.client.IngestClient`, - :class:`~opensearch.client.NodesClient`, - :class:`~opensearch.client.SnapshotClient` and - :class:`~opensearch.client.TasksClient` respectively. This is the + :class:`~opensearchpy.client.CatClient`, + :class:`~opensearchpy.client.ClusterClient`, + :class:`~opensearchpy.client.IndicesClient`, + :class:`~opensearchpy.client.IngestClient`, + :class:`~opensearchpy.client.NodesClient`, + :class:`~opensearchpy.client.SnapshotClient` and + :class:`~opensearchpy.client.TasksClient` respectively. This is the preferred (and only supported) way to get access to those classes and their methods. @@ -69,7 +69,7 @@ class OpenSearch(object): client = OpenSearch(connection_class=ThriftConnection) If you want to turn on :ref:`sniffing` you have several options (described - in :class:`~opensearch.Transport`):: + in :class:`~opensearchpy.Transport`):: # create connection that will automatically inspect the cluster to get # the list of active nodes. Start with nodes running on @@ -95,7 +95,7 @@ class OpenSearch(object): ]) If using SSL, there are several parameters that control how we deal with - certificates (see :class:`~opensearch.Urllib3HttpConnection` for + certificates (see :class:`~opensearchpy.Urllib3HttpConnection` for detailed description of the options):: client = OpenSearch( @@ -109,7 +109,7 @@ class OpenSearch(object): ) If using SSL, but don't verify the certs, a warning message is showed - optionally (see :class:`~opensearch.Urllib3HttpConnection` for + optionally (see :class:`~opensearchpy.Urllib3HttpConnection` for detailed description of the options):: client = OpenSearch( @@ -123,7 +123,7 @@ class OpenSearch(object): ) SSL client authentication is supported - (see :class:`~opensearch.Urllib3HttpConnection` for + (see :class:`~opensearchpy.Urllib3HttpConnection` for detailed description of the options):: client = OpenSearch( @@ -156,7 +156,7 @@ class OpenSearch(object): is used to encode all outgoing requests. However, you can implement your own custom serializer:: - from opensearch.serializer import JSONSerializer + from opensearchpy.serializer import JSONSerializer class SetEncoder(JSONSerializer): def default(self, obj): @@ -174,16 +174,16 @@ class OpenSearch(object): """ :arg hosts: list of nodes, or a single node, we should connect to. Node should be a dictionary ({"host": "localhost", "port": 9200}), - the entire dictionary will be passed to the :class:`~opensearch.Connection` + the entire dictionary will be passed to the :class:`~opensearchpy.Connection` class as kwargs, or a string in the format of ``host[:port]`` which will be translated to a dictionary automatically. If no value is given the - :class:`~opensearch.Connection` class defaults will be used. + :class:`~opensearchpy.Connection` class defaults will be used. - :arg transport_class: :class:`~opensearch.Transport` subclass to use. + :arg transport_class: :class:`~opensearchpy.Transport` subclass to use. :arg kwargs: any additional arguments will be passed on to the - :class:`~opensearch.Transport` class and, subsequently, to the - :class:`~opensearch.Connection` instances. + :class:`~opensearchpy.Transport` class and, subsequently, to the + :class:`~opensearchpy.Connection` instances. """ self.transport = transport_class(_normalize_hosts(hosts), **kwargs) diff --git a/opensearch/client/__init__.pyi b/opensearchpy/client/__init__.pyi similarity index 100% rename from opensearch/client/__init__.pyi rename to opensearchpy/client/__init__.pyi diff --git a/opensearch/client/cat.py b/opensearchpy/client/cat.py similarity index 100% rename from opensearch/client/cat.py rename to opensearchpy/client/cat.py diff --git a/opensearch/client/cat.pyi b/opensearchpy/client/cat.pyi similarity index 100% rename from opensearch/client/cat.pyi rename to opensearchpy/client/cat.pyi diff --git a/opensearch/client/cluster.py b/opensearchpy/client/cluster.py similarity index 100% rename from opensearch/client/cluster.py rename to opensearchpy/client/cluster.py diff --git a/opensearch/client/cluster.pyi b/opensearchpy/client/cluster.pyi similarity index 100% rename from opensearch/client/cluster.pyi rename to opensearchpy/client/cluster.pyi diff --git a/opensearch/client/dangling_indices.py b/opensearchpy/client/dangling_indices.py similarity index 100% rename from opensearch/client/dangling_indices.py rename to opensearchpy/client/dangling_indices.py diff --git a/opensearch/client/dangling_indices.pyi b/opensearchpy/client/dangling_indices.pyi similarity index 100% rename from opensearch/client/dangling_indices.pyi rename to opensearchpy/client/dangling_indices.pyi diff --git a/opensearch/client/features.py b/opensearchpy/client/features.py similarity index 100% rename from opensearch/client/features.py rename to opensearchpy/client/features.py diff --git a/opensearch/client/features.pyi b/opensearchpy/client/features.pyi similarity index 100% rename from opensearch/client/features.pyi rename to opensearchpy/client/features.pyi diff --git a/opensearch/client/indices.py b/opensearchpy/client/indices.py similarity index 100% rename from opensearch/client/indices.py rename to opensearchpy/client/indices.py diff --git a/opensearch/client/indices.pyi b/opensearchpy/client/indices.pyi similarity index 100% rename from opensearch/client/indices.pyi rename to opensearchpy/client/indices.pyi diff --git a/opensearch/client/ingest.py b/opensearchpy/client/ingest.py similarity index 100% rename from opensearch/client/ingest.py rename to opensearchpy/client/ingest.py diff --git a/opensearch/client/ingest.pyi b/opensearchpy/client/ingest.pyi similarity index 100% rename from opensearch/client/ingest.pyi rename to opensearchpy/client/ingest.pyi diff --git a/opensearch/client/nodes.py b/opensearchpy/client/nodes.py similarity index 100% rename from opensearch/client/nodes.py rename to opensearchpy/client/nodes.py diff --git a/opensearch/client/nodes.pyi b/opensearchpy/client/nodes.pyi similarity index 100% rename from opensearch/client/nodes.pyi rename to opensearchpy/client/nodes.pyi diff --git a/opensearch/client/remote.py b/opensearchpy/client/remote.py similarity index 100% rename from opensearch/client/remote.py rename to opensearchpy/client/remote.py diff --git a/opensearch/client/remote.pyi b/opensearchpy/client/remote.pyi similarity index 100% rename from opensearch/client/remote.pyi rename to opensearchpy/client/remote.pyi diff --git a/opensearch/client/snapshot.py b/opensearchpy/client/snapshot.py similarity index 100% rename from opensearch/client/snapshot.py rename to opensearchpy/client/snapshot.py diff --git a/opensearch/client/snapshot.pyi b/opensearchpy/client/snapshot.pyi similarity index 100% rename from opensearch/client/snapshot.pyi rename to opensearchpy/client/snapshot.pyi diff --git a/opensearch/client/tasks.py b/opensearchpy/client/tasks.py similarity index 100% rename from opensearch/client/tasks.py rename to opensearchpy/client/tasks.py diff --git a/opensearch/client/tasks.pyi b/opensearchpy/client/tasks.pyi similarity index 100% rename from opensearch/client/tasks.pyi rename to opensearchpy/client/tasks.pyi diff --git a/opensearch/client/utils.py b/opensearchpy/client/utils.py similarity index 99% rename from opensearch/client/utils.py rename to opensearchpy/client/utils.py index 54b7be97..cfbd9610 100644 --- a/opensearch/client/utils.py +++ b/opensearchpy/client/utils.py @@ -40,7 +40,7 @@ SKIP_IN_PATH = (None, "", b"", [], ()) def _normalize_hosts(hosts): """ Helper function to transform hosts argument to - :class:`~opensearch.OpenSearch` to a list of dicts. + :class:`~opensearchpy.OpenSearch` to a list of dicts. """ # if hosts are empty, just defer to defaults down the line if hosts is None: diff --git a/opensearch/client/utils.pyi b/opensearchpy/client/utils.pyi similarity index 100% rename from opensearch/client/utils.pyi rename to opensearchpy/client/utils.pyi diff --git a/opensearch/compat.py b/opensearchpy/compat.py similarity index 100% rename from opensearch/compat.py rename to opensearchpy/compat.py diff --git a/opensearch/compat.pyi b/opensearchpy/compat.pyi similarity index 100% rename from opensearch/compat.pyi rename to opensearchpy/compat.pyi diff --git a/opensearch/connection/__init__.py b/opensearchpy/connection/__init__.py similarity index 100% rename from opensearch/connection/__init__.py rename to opensearchpy/connection/__init__.py diff --git a/opensearch/connection/__init__.pyi b/opensearchpy/connection/__init__.pyi similarity index 100% rename from opensearch/connection/__init__.pyi rename to opensearchpy/connection/__init__.pyi diff --git a/opensearch/connection/base.py b/opensearchpy/connection/base.py similarity index 98% rename from opensearch/connection/base.py rename to opensearchpy/connection/base.py index b8c27237..199f122f 100644 --- a/opensearch/connection/base.py +++ b/opensearchpy/connection/base.py @@ -48,10 +48,10 @@ from ..exceptions import ( logger = logging.getLogger("opensearch") -# create the opensearch.trace logger, but only set propagate to False if the +# create the opensearchpy.trace logger, but only set propagate to False if the # logger hasn't already been configured -_tracer_already_configured = "opensearch.trace" in logging.Logger.manager.loggerDict -tracer = logging.getLogger("opensearch.trace") +_tracer_already_configured = "opensearchpy.trace" in logging.Logger.manager.loggerDict +tracer = logging.getLogger("opensearchpy.trace") if not _tracer_already_configured: tracer.propagate = False diff --git a/opensearch/connection/base.pyi b/opensearchpy/connection/base.pyi similarity index 100% rename from opensearch/connection/base.pyi rename to opensearchpy/connection/base.pyi diff --git a/opensearch/connection/http_requests.py b/opensearchpy/connection/http_requests.py similarity index 100% rename from opensearch/connection/http_requests.py rename to opensearchpy/connection/http_requests.py diff --git a/opensearch/connection/http_requests.pyi b/opensearchpy/connection/http_requests.pyi similarity index 100% rename from opensearch/connection/http_requests.pyi rename to opensearchpy/connection/http_requests.pyi diff --git a/opensearch/connection/http_urllib3.py b/opensearchpy/connection/http_urllib3.py similarity index 100% rename from opensearch/connection/http_urllib3.py rename to opensearchpy/connection/http_urllib3.py diff --git a/opensearch/connection/http_urllib3.pyi b/opensearchpy/connection/http_urllib3.pyi similarity index 100% rename from opensearch/connection/http_urllib3.pyi rename to opensearchpy/connection/http_urllib3.pyi diff --git a/opensearch/connection/pooling.py b/opensearchpy/connection/pooling.py similarity index 100% rename from opensearch/connection/pooling.py rename to opensearchpy/connection/pooling.py diff --git a/opensearch/connection/pooling.pyi b/opensearchpy/connection/pooling.pyi similarity index 100% rename from opensearch/connection/pooling.pyi rename to opensearchpy/connection/pooling.pyi diff --git a/opensearch/connection_pool.py b/opensearchpy/connection_pool.py similarity index 96% rename from opensearch/connection_pool.py rename to opensearchpy/connection_pool.py index 5ed25959..7f4a4ade 100644 --- a/opensearch/connection_pool.py +++ b/opensearchpy/connection_pool.py @@ -48,7 +48,7 @@ class ConnectionSelector(object): *currently* live connections to choose from. The options dictionary is the one that has been passed to - :class:`~opensearch.Transport` as `hosts` param and the same that is + :class:`~opensearchpy.Transport` as `hosts` param and the same that is used to construct the Connection object itself. When the Connection was created from information retrieved from the cluster via the sniffing process it will be the dictionary returned by the `host_info_callback`. @@ -99,11 +99,11 @@ class RoundRobinSelector(ConnectionSelector): class ConnectionPool(object): """ - Container holding the :class:`~opensearch.Connection` instances, + Container holding the :class:`~opensearchpy.Connection` instances, managing the selection process (via a - :class:`~opensearch.ConnectionSelector`) and dead connections. + :class:`~opensearchpy.ConnectionSelector`) and dead connections. - It's only interactions are with the :class:`~opensearch.Transport` class + It's only interactions are with the :class:`~opensearchpy.Transport` class that drives all the actions within `ConnectionPool`. Initially connections are stored on the class as a list and, along with the @@ -131,12 +131,12 @@ class ConnectionPool(object): ): """ :arg connections: list of tuples containing the - :class:`~opensearch.Connection` instance and it's options + :class:`~opensearchpy.Connection` instance and it's options :arg dead_timeout: number of seconds a connection should be retired for after a failure, increases on consecutive failures :arg timeout_cutoff: number of consecutive failures after which the timeout doesn't increase - :arg selector_class: :class:`~opensearch.ConnectionSelector` + :arg selector_class: :class:`~opensearchpy.ConnectionSelector` subclass to use if more than one connection is live :arg randomize_hosts: shuffle the list of connections upon arrival to avoid dog piling effect across processes diff --git a/opensearch/connection_pool.pyi b/opensearchpy/connection_pool.pyi similarity index 100% rename from opensearch/connection_pool.pyi rename to opensearchpy/connection_pool.pyi diff --git a/opensearch/exceptions.py b/opensearchpy/exceptions.py similarity index 97% rename from opensearch/exceptions.py rename to opensearchpy/exceptions.py index 6e886e1d..9490b519 100644 --- a/opensearch/exceptions.py +++ b/opensearchpy/exceptions.py @@ -49,7 +49,7 @@ class ImproperlyConfigured(Exception): class OpenSearchException(Exception): """ Base class for all exceptions raised by this package's operations (doesn't - apply to :class:`~opensearch.ImproperlyConfigured`). + apply to :class:`~opensearchpy.ImproperlyConfigured`). """ @@ -116,7 +116,7 @@ class TransportError(OpenSearchException): class ConnectionError(TransportError): """ Error raised when there was an exception while talking to OpenSearch. Original - exception from the underlying :class:`~opensearch.Connection` + exception from the underlying :class:`~opensearchpy.Connection` implementation is available as ``.info``. """ diff --git a/opensearch/exceptions.pyi b/opensearchpy/exceptions.pyi similarity index 100% rename from opensearch/exceptions.pyi rename to opensearchpy/exceptions.pyi diff --git a/opensearch/helpers/__init__.py b/opensearchpy/helpers/__init__.py similarity index 100% rename from opensearch/helpers/__init__.py rename to opensearchpy/helpers/__init__.py diff --git a/opensearch/helpers/__init__.pyi b/opensearchpy/helpers/__init__.pyi similarity index 100% rename from opensearch/helpers/__init__.pyi rename to opensearchpy/helpers/__init__.pyi diff --git a/opensearch/helpers/actions.py b/opensearchpy/helpers/actions.py similarity index 94% rename from opensearch/helpers/actions.py rename to opensearchpy/helpers/actions.py index 536d66da..70fd1853 100644 --- a/opensearch/helpers/actions.py +++ b/opensearchpy/helpers/actions.py @@ -32,14 +32,14 @@ from ..compat import Mapping, Queue, map, string_types from ..exceptions import TransportError from .errors import BulkIndexError, ScanError -logger = logging.getLogger("opensearch.helpers") +logger = logging.getLogger("opensearchpy.helpers") def expand_action(data): """ From one document or action definition passed in by the user extract the action/data lines needed for opensearch's - :meth:`~opensearch.OpenSearch.bulk` api. + :meth:`~opensearchpy.OpenSearch.bulk` api. """ # when given a string, assume user wants to index raw json if isinstance(data, string_types): @@ -284,7 +284,7 @@ def streaming_bulk( """ Streaming bulk consumes actions from the iterable passed in and yields results per action. For non-streaming usecases use - :func:`~opensearch.helpers.bulk` which is a wrapper around streaming + :func:`~opensearchpy.helpers.bulk` which is a wrapper around streaming bulk that returns summary information about the bulk operation once the entire input is consumed and sent. @@ -294,7 +294,7 @@ def streaming_bulk( every subsequent rejection for the same chunk, for double the time every time up to ``max_backoff`` seconds. - :arg client: instance of :class:`~opensearch.OpenSearch` to use + :arg client: instance of :class:`~opensearchpy.OpenSearch` to use :arg actions: iterable containing the actions to be executed :arg chunk_size: number of docs in one chunk sent to client (default: 500) :arg max_chunk_bytes: the maximum size of the request in bytes (default: 100MB) @@ -373,7 +373,7 @@ def streaming_bulk( def bulk(client, actions, stats_only=False, ignore_status=(), *args, **kwargs): """ - Helper for the :meth:`~opensearch.OpenSearch.bulk` api that provides + Helper for the :meth:`~opensearchpy.OpenSearch.bulk` api that provides a more human friendly interface - it consumes an iterator of actions and sends them to opensearch in chunks. It returns a tuple with summary information - number of successfully executed actions and either list of @@ -385,19 +385,19 @@ def bulk(client, actions, stats_only=False, ignore_status=(), *args, **kwargs): When errors are being collected original document data is included in the error dictionary which can lead to an extra high memory usage. If you need to process a lot of data and want to ignore/collect errors please consider - using the :func:`~opensearch.helpers.streaming_bulk` helper which will + using the :func:`~opensearchpy.helpers.streaming_bulk` helper which will just return the errors and not store them in memory. - :arg client: instance of :class:`~opensearch.OpenSearch` to use + :arg client: instance of :class:`~opensearchpy.OpenSearch` to use :arg actions: iterator containing the actions :arg stats_only: if `True` only report number of successful/failed operations instead of just number of successful and a list of error responses :arg ignore_status: list of HTTP status code that you want to ignore Any additional keyword arguments will be passed to - :func:`~opensearch.helpers.streaming_bulk` which is used to execute - the operation, see :func:`~opensearch.helpers.streaming_bulk` for more + :func:`~opensearchpy.helpers.streaming_bulk` which is used to execute + the operation, see :func:`~opensearchpy.helpers.streaming_bulk` for more accepted parameters. """ success, failed = 0, 0 @@ -436,7 +436,7 @@ def parallel_bulk( """ Parallel version of the bulk helper run in multiple threads at once. - :arg client: instance of :class:`~opensearch.OpenSearch` to use + :arg client: instance of :class:`~opensearchpy.OpenSearch` to use :arg actions: iterator containing the actions :arg thread_count: size of the threadpool to use for the bulk requests :arg chunk_size: number of docs in one chunk sent to client (default: 500) @@ -506,7 +506,7 @@ def scan( ): """ Simple abstraction on top of the - :meth:`~opensearch.OpenSearch.scroll` api - a simple iterator that + :meth:`~opensearchpy.OpenSearch.scroll` api - a simple iterator that yields all hits as returned by underlining scroll requests. By default scan does not return results in any pre-determined order. To @@ -515,8 +515,8 @@ def scan( may be an expensive operation and will negate the performance benefits of using ``scan``. - :arg client: instance of :class:`~opensearch.OpenSearch` to use - :arg query: body for the :meth:`~opensearch.OpenSearch.search` api + :arg client: instance of :class:`~opensearchpy.OpenSearch` to use + :arg query: body for the :meth:`~opensearchpy.OpenSearch.search` api :arg scroll: Specify how long a consistent view of the index should be maintained for scrolled search :arg raise_on_error: raises an exception (``ScanError``) if an error is @@ -531,10 +531,10 @@ def scan( scroll API at the end of the method on completion or error, defaults to true. :arg scroll_kwargs: additional kwargs to be passed to - :meth:`~opensearch.OpenSearch.scroll` + :meth:`~opensearchpy.OpenSearch.scroll` Any additional keyword arguments will be passed to the initial - :meth:`~opensearch.OpenSearch.search` call:: + :meth:`~opensearchpy.OpenSearch.search` call:: scan(client, query={"query": {"match": {"title": "python"}}}, @@ -627,7 +627,7 @@ def reindex( to another, potentially (if `target_client` is specified) on a different cluster. If you don't specify the query you will reindex all the documents. - Since ``2.3`` a :meth:`~opensearch.OpenSearch.reindex` api is + Since ``2.3`` a :meth:`~opensearchpy.OpenSearch.reindex` api is available as part of opensearch itself. It is recommended to use the api instead of this helper wherever possible. The helper is here mostly for backwards compatibility and for situations where more flexibility is @@ -637,20 +637,20 @@ def reindex( This helper doesn't transfer mappings, just the data. - :arg client: instance of :class:`~opensearch.OpenSearch` to use (for + :arg client: instance of :class:`~opensearchpy.OpenSearch` to use (for read if `target_client` is specified as well) :arg source_index: index (or list of indices) to read documents from :arg target_index: name of the index in the target cluster to populate - :arg query: body for the :meth:`~opensearch.OpenSearch.search` api + :arg query: body for the :meth:`~opensearchpy.OpenSearch.search` api :arg target_client: optional, is specified will be used for writing (thus enabling reindex between clusters) :arg chunk_size: number of docs in one chunk sent to client (default: 500) :arg scroll: Specify how long a consistent view of the index should be maintained for scrolled search :arg scan_kwargs: additional kwargs to be passed to - :func:`~opensearch.helpers.scan` + :func:`~opensearchpy.helpers.scan` :arg bulk_kwargs: additional kwargs to be passed to - :func:`~opensearch.helpers.bulk` + :func:`~opensearchpy.helpers.bulk` """ target_client = client if target_client is None else target_client docs = scan(client, query=query, index=source_index, scroll=scroll, **scan_kwargs) diff --git a/opensearch/helpers/actions.pyi b/opensearchpy/helpers/actions.pyi similarity index 100% rename from opensearch/helpers/actions.pyi rename to opensearchpy/helpers/actions.pyi diff --git a/opensearch/helpers/errors.py b/opensearchpy/helpers/errors.py similarity index 100% rename from opensearch/helpers/errors.py rename to opensearchpy/helpers/errors.py diff --git a/opensearch/helpers/errors.pyi b/opensearchpy/helpers/errors.pyi similarity index 100% rename from opensearch/helpers/errors.pyi rename to opensearchpy/helpers/errors.pyi diff --git a/opensearch/helpers/test.py b/opensearchpy/helpers/test.py similarity index 96% rename from opensearch/helpers/test.py rename to opensearchpy/helpers/test.py index 9e75bf0b..ade17e85 100644 --- a/opensearch/helpers/test.py +++ b/opensearchpy/helpers/test.py @@ -31,8 +31,8 @@ import time from os.path import abspath, dirname, join from unittest import SkipTest, TestCase -from opensearch import OpenSearch -from opensearch.exceptions import ConnectionError +from opensearchpy import OpenSearch +from opensearchpy.exceptions import ConnectionError if "OPENSEARCH_URL" in os.environ: OPENSEARCH_URL = os.environ["OPENSEARCH_URL"] @@ -47,7 +47,7 @@ def get_test_client(nowait=False, **kwargs): kw = {"timeout": 30, "ca_certs": CA_CERTS} if "PYTHON_CONNECTION_CLASS" in os.environ: - from opensearch import connection + from opensearchpy import connection kw["connection_class"] = getattr( connection, os.environ["PYTHON_CONNECTION_CLASS"] diff --git a/opensearch/helpers/test.pyi b/opensearchpy/helpers/test.pyi similarity index 100% rename from opensearch/helpers/test.pyi rename to opensearchpy/helpers/test.pyi diff --git a/opensearch/py.typed b/opensearchpy/py.typed similarity index 100% rename from opensearch/py.typed rename to opensearchpy/py.typed diff --git a/opensearch/serializer.py b/opensearchpy/serializer.py similarity index 100% rename from opensearch/serializer.py rename to opensearchpy/serializer.py diff --git a/opensearch/serializer.pyi b/opensearchpy/serializer.pyi similarity index 100% rename from opensearch/serializer.pyi rename to opensearchpy/serializer.pyi diff --git a/opensearch/transport.py b/opensearchpy/transport.py similarity index 96% rename from opensearch/transport.py rename to opensearchpy/transport.py index be952215..54c271e9 100644 --- a/opensearch/transport.py +++ b/opensearchpy/transport.py @@ -45,7 +45,7 @@ def get_host_info(node_info, host): `None` is returned this node will be skipped. Useful for filtering nodes (by proximity for example) or if additional - information needs to be provided for the :class:`~opensearch.Connection` + information needs to be provided for the :class:`~opensearchpy.Connection` class. By default master only nodes are filtered out since they shouldn't typically be used for API operations. @@ -90,8 +90,8 @@ class Transport(object): """ :arg hosts: list of dictionaries, each containing keyword arguments to create a `connection_class` instance - :arg connection_class: subclass of :class:`~opensearch.Connection` to use - :arg connection_pool_class: subclass of :class:`~opensearch.ConnectionPool` to use + :arg connection_class: subclass of :class:`~opensearchpy.Connection` to use + :arg connection_pool_class: subclass of :class:`~opensearchpy.ConnectionPool` to use :arg host_info_callback: callback responsible for taking the node information from `/_cluster/nodes`, along with already extracted information, and producing a list of arguments (same as `hosts` parameter) @@ -186,7 +186,7 @@ class Transport(object): def add_connection(self, host): """ - Create a new :class:`~opensearch.Connection` instance and add it to the pool. + Create a new :class:`~opensearchpy.Connection` instance and add it to the pool. :arg host: kwargs that will be used to create the instance """ @@ -197,7 +197,7 @@ class Transport(object): """ Instantiate all the connections and create new connection pool to hold them. Tries to identify unchanged hosts and re-use existing - :class:`~opensearch.Connection` instances. + :class:`~opensearchpy.Connection` instances. :arg hosts: same as `__init__` """ @@ -229,8 +229,8 @@ class Transport(object): def get_connection(self): """ - Retrieve a :class:`~opensearch.Connection` instance from the - :class:`~opensearch.ConnectionPool` instance. + Retrieve a :class:`~opensearchpy.Connection` instance from the + :class:`~opensearchpy.ConnectionPool` instance. """ if self.sniffer_timeout: if time.time() >= self.last_sniff + self.sniffer_timeout: @@ -334,7 +334,7 @@ class Transport(object): Mark a connection as dead (failed) in the connection pool. If sniffing on failure is enabled this will initiate the sniffing process. - :arg connection: instance of :class:`~opensearch.Connection` that failed + :arg connection: instance of :class:`~opensearchpy.Connection` that failed """ # mark as dead even when sniffing to avoid hitting this host during the sniff process self.connection_pool.mark_dead(connection) @@ -356,9 +356,9 @@ class Transport(object): :arg method: HTTP method to use :arg url: absolute url (without host) to target :arg headers: dictionary of headers, will be handed over to the - underlying :class:`~opensearch.Connection` class + underlying :class:`~opensearchpy.Connection` class :arg params: dictionary of query parameters, will be handed over to the - underlying :class:`~opensearch.Connection` class for serialization + underlying :class:`~opensearchpy.Connection` class for serialization :arg body: body of the request, will be serialized using serializer and passed to the connection """ diff --git a/opensearch/transport.pyi b/opensearchpy/transport.pyi similarity index 100% rename from opensearch/transport.pyi rename to opensearchpy/transport.pyi diff --git a/setup.py b/setup.py index e0b44cb9..f02432ef 100644 --- a/setup.py +++ b/setup.py @@ -30,7 +30,7 @@ from os.path import abspath, dirname, join from setuptools import find_packages, setup -package_name = "opensearch" +package_name = "opensearchpy" base_dir = abspath(dirname(__file__)) with open(join(base_dir, package_name, "_version.py")) as f: @@ -43,7 +43,7 @@ with open(join(base_dir, "README.md")) as f: packages = [ package - for package in find_packages(where=".", exclude=("test_opensearch*",)) + for package in find_packages(where=".", exclude=("test_opensearchpy*",)) if package == package_name or package.startswith(package_name + ".") ] @@ -82,7 +82,7 @@ setup( "Issue Tracker": "https://github.com/opensearch-project/opensearch-py/issues", }, packages=packages, - package_data={"opensearch": ["py.typed", "*.pyi"]}, + package_data={"opensearchpy": ["py.typed", "*.pyi"]}, include_package_data=True, zip_safe=False, classifiers=[ @@ -105,7 +105,7 @@ setup( ], python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <4", install_requires=install_requires, - test_suite="test_opensearch.run_tests.run_all", + test_suite="test_opensearchpy.run_tests.run_all", tests_require=tests_require, extras_require={ "develop": tests_require + docs_require + generate_require, diff --git a/test_opensearch/__init__.py b/test_opensearchpy/__init__.py similarity index 100% rename from test_opensearch/__init__.py rename to test_opensearchpy/__init__.py diff --git a/test_opensearch/run_tests.py b/test_opensearchpy/run_tests.py similarity index 89% rename from test_opensearch/run_tests.py rename to test_opensearchpy/run_tests.py index 18144f47..87dbbe54 100755 --- a/test_opensearch/run_tests.py +++ b/test_opensearchpy/run_tests.py @@ -59,8 +59,8 @@ def fetch_opensearch_repo(): if environ.get("TEST_OPENSEARCH_NOFETCH", False): return - from test_opensearch.test_cases import SkipTest - from test_opensearch.test_server import get_client + from test_opensearchpy.test_cases import SkipTest + from test_opensearchpy.test_server import get_client # find out the sha of the running client try: @@ -110,15 +110,15 @@ def run_all(argv=None): ignores = [] # Python 3.6+ is required for async if sys.version_info < (3, 6): - ignores.append("test_opensearch/test_async/") + ignores.append("test_opensearchpy/test_async/") # GitHub Actions, run non-server tests if "GITHUB_ACTION" in environ: ignores.extend( [ - "test_opensearch/test_server/", - "test_opensearch/test_server_secured/", - "test_opensearch/test_async/test_server/", + "test_opensearchpy/test_server/", + "test_opensearchpy/test_server_secured/", + "test_opensearchpy/test_async/test_server/", ] ) @@ -129,8 +129,8 @@ def run_all(argv=None): argv.append(join(test_dir, "test_server_secured")) ignores.extend( [ - "test_opensearch/test_server/", - "test_opensearch/test_async/test_server/", + "test_opensearchpy/test_server/", + "test_opensearchpy/test_async/test_server/", ] ) else: @@ -139,7 +139,7 @@ def run_all(argv=None): argv.append(join(test_dir, "test_async/test_server")) ignores.extend( [ - "test_opensearch/test_server_secured/", + "test_opensearchpy/test_server_secured/", ] ) diff --git a/test_opensearch/test_async/__init__.py b/test_opensearchpy/test_async/__init__.py similarity index 100% rename from test_opensearch/test_async/__init__.py rename to test_opensearchpy/test_async/__init__.py diff --git a/test_opensearch/test_async/test_connection.py b/test_opensearchpy/test_async/test_connection.py similarity index 98% rename from test_opensearch/test_async/test_connection.py rename to test_opensearchpy/test_async/test_connection.py index 248fd128..d28ab23b 100644 --- a/test_opensearch/test_async/test_connection.py +++ b/test_opensearchpy/test_async/test_connection.py @@ -37,9 +37,9 @@ import pytest from mock import patch from multidict import CIMultiDict -from opensearch import AIOHttpConnection, __versionstr__ -from opensearch.compat import reraise_exceptions -from opensearch.exceptions import ConnectionError +from opensearchpy import AIOHttpConnection, __versionstr__ +from opensearchpy.compat import reraise_exceptions +from opensearchpy.exceptions import ConnectionError pytestmark = pytest.mark.asyncio @@ -312,7 +312,7 @@ class TestAIOHttpConnection: == str(w[0].message) ) - @patch("opensearch.connection.base.logger") + @patch("opensearchpy.connection.base.logger") async def test_uncompressed_body_logged(self, logger): con = await self._get_mock_connection(connection_params={"http_compress": True}) await con.perform_request("GET", "/", body=b'{"example": "body"}') diff --git a/test_opensearch/test_async/test_server/__init__.py b/test_opensearchpy/test_async/test_server/__init__.py similarity index 100% rename from test_opensearch/test_async/test_server/__init__.py rename to test_opensearchpy/test_async/test_server/__init__.py diff --git a/test_opensearch/test_async/test_server/conftest.py b/test_opensearchpy/test_async/test_server/conftest.py similarity index 89% rename from test_opensearch/test_async/test_server/conftest.py rename to test_opensearchpy/test_async/test_server/conftest.py index 4390c937..d39a0d3a 100644 --- a/test_opensearch/test_async/test_server/conftest.py +++ b/test_opensearchpy/test_async/test_server/conftest.py @@ -28,8 +28,8 @@ import asyncio import pytest -import opensearch -from opensearch.helpers.test import CA_CERTS, OPENSEARCH_URL +import opensearchpy +from opensearchpy.helpers.test import CA_CERTS, OPENSEARCH_URL from ...utils import wipe_cluster @@ -40,11 +40,11 @@ pytestmark = pytest.mark.asyncio async def async_client(): client = None try: - if not hasattr(opensearch, "AsyncOpenSearch"): + if not hasattr(opensearchpy, "AsyncOpenSearch"): pytest.skip("test requires 'AsyncOpenSearch'") kw = {"timeout": 3, "ca_certs": CA_CERTS} - client = opensearch.AsyncOpenSearch(OPENSEARCH_URL, **kw) + client = opensearchpy.AsyncOpenSearch(OPENSEARCH_URL, **kw) # wait for yellow status for _ in range(100): diff --git a/test_opensearch/test_async/test_server/test_clients.py b/test_opensearchpy/test_async/test_server/test_clients.py similarity index 97% rename from test_opensearch/test_async/test_server/test_clients.py rename to test_opensearchpy/test_async/test_server/test_clients.py index 2efffd5a..40c550cb 100644 --- a/test_opensearch/test_async/test_server/test_clients.py +++ b/test_opensearchpy/test_async/test_server/test_clients.py @@ -58,7 +58,7 @@ class TestYarlMissing: self, async_client, monkeypatch ): # This is a defensive test case for if aiohttp suddenly stops using yarl. - from opensearch._async import http_aiohttp + from opensearchpy._async import http_aiohttp monkeypatch.setattr(http_aiohttp, "yarl", False) diff --git a/test_opensearch/test_async/test_server/test_helpers.py b/test_opensearchpy/test_async/test_server/test_helpers.py similarity index 99% rename from test_opensearch/test_async/test_server/test_helpers.py rename to test_opensearchpy/test_async/test_server/test_helpers.py index 81b6960c..90f9ab5d 100644 --- a/test_opensearch/test_async/test_server/test_helpers.py +++ b/test_opensearchpy/test_async/test_server/test_helpers.py @@ -33,8 +33,8 @@ import asyncio import pytest from mock import MagicMock, patch -from opensearch import TransportError, helpers -from opensearch.helpers import ScanError +from opensearchpy import TransportError, helpers +from opensearchpy.helpers import ScanError pytestmark = pytest.mark.asyncio @@ -582,7 +582,7 @@ class TestScan(object): scroll_mock.assert_not_called() clear_mock.assert_not_called() - @patch("opensearch._async.helpers.logger") + @patch("opensearchpy._async.helpers.logger") async def test_logger(self, logger_mock, async_client, scan_teardown): bulk = [] for x in range(4): diff --git a/test_opensearch/test_async/test_server/test_rest_api_spec.py b/test_opensearchpy/test_async/test_server/test_rest_api_spec.py similarity index 98% rename from test_opensearch/test_async/test_server/test_rest_api_spec.py rename to test_opensearchpy/test_async/test_server/test_rest_api_spec.py index d4e63fab..5e831a9d 100644 --- a/test_opensearch/test_async/test_server/test_rest_api_spec.py +++ b/test_opensearchpy/test_async/test_server/test_rest_api_spec.py @@ -34,8 +34,8 @@ import warnings import pytest -from opensearch import OpenSearchWarning -from opensearch.helpers.test import _get_version +from opensearchpy import OpenSearchWarning +from opensearchpy.helpers.test import _get_version from ...test_server.test_rest_api_spec import ( IMPLEMENTED_FEATURES, diff --git a/test_opensearch/test_async/test_transport.py b/test_opensearchpy/test_async/test_transport.py similarity index 98% rename from test_opensearch/test_async/test_transport.py rename to test_opensearchpy/test_async/test_transport.py index 98a9d7fd..ea31fd9c 100644 --- a/test_opensearch/test_async/test_transport.py +++ b/test_opensearchpy/test_async/test_transport.py @@ -33,10 +33,10 @@ import json import pytest from mock import patch -from opensearch import AsyncTransport -from opensearch.connection import Connection -from opensearch.connection_pool import DummyConnectionPool -from opensearch.exceptions import ConnectionError, TransportError +from opensearchpy import AsyncTransport +from opensearchpy.connection import Connection +from opensearchpy.connection_pool import DummyConnectionPool +from opensearchpy.exceptions import ConnectionError, TransportError pytestmark = pytest.mark.asyncio @@ -380,7 +380,7 @@ class TestTransport: assert 1 == len(t.connection_pool.connections) assert "http://1.1.1.1:123" == t.get_connection().host - @patch("opensearch._async.transport.AsyncTransport.sniff_hosts") + @patch("opensearchpy._async.transport.AsyncTransport.sniff_hosts") async def test_sniff_on_fail_failing_does_not_prevent_retires(self, sniff_hosts): sniff_hosts.side_effect = [TransportError("sniff failed")] t = AsyncTransport( @@ -436,7 +436,7 @@ class TestTransport: "port": 123, } - @patch("opensearch._async.transport.AsyncTransport.sniff_hosts") + @patch("opensearchpy._async.transport.AsyncTransport.sniff_hosts") async def test_sniffing_disabled_on_cloud_instances(self, sniff_hosts): t = AsyncTransport( [{}], diff --git a/test_opensearch/test_cases.py b/test_opensearchpy/test_cases.py similarity index 98% rename from test_opensearch/test_cases.py rename to test_opensearchpy/test_cases.py index ebbb04fc..61b402b9 100644 --- a/test_opensearch/test_cases.py +++ b/test_opensearchpy/test_cases.py @@ -28,7 +28,7 @@ from collections import defaultdict from unittest import SkipTest # noqa: F401 from unittest import TestCase -from opensearch import OpenSearch +from opensearchpy import OpenSearch class DummyTransport(object): diff --git a/test_opensearch/test_client/__init__.py b/test_opensearchpy/test_client/__init__.py similarity index 97% rename from test_opensearch/test_client/__init__.py rename to test_opensearchpy/test_client/__init__.py index d421eee2..fb334def 100644 --- a/test_opensearch/test_client/__init__.py +++ b/test_opensearchpy/test_client/__init__.py @@ -28,7 +28,7 @@ from __future__ import unicode_literals import warnings -from opensearch.client import OpenSearch, _normalize_hosts +from opensearchpy.client import OpenSearch, _normalize_hosts from ..test_cases import OpenSearchTestCase, TestCase @@ -121,7 +121,7 @@ class TestClient(OpenSearchTestCase): self.assertEqual("", repr(OtherOpenSearch())) def test_repr_contains_hosts_passed_in(self): - self.assertIn("opensearch.org", repr(OpenSearch(["opensearch.org:123"]))) + self.assertIn("opensearchpy.org", repr(OpenSearch(["opensearch.org:123"]))) def test_repr_truncates_host_to_5(self): hosts = [{"host": "opensearch" + str(i)} for i in range(10)] diff --git a/test_opensearch/test_client/test_cluster.py b/test_opensearchpy/test_client/test_cluster.py similarity index 97% rename from test_opensearch/test_client/test_cluster.py rename to test_opensearchpy/test_client/test_cluster.py index 1644b960..359a527c 100644 --- a/test_opensearch/test_client/test_cluster.py +++ b/test_opensearchpy/test_client/test_cluster.py @@ -24,7 +24,7 @@ # specific language governing permissions and limitations # under the License. -from test_opensearch.test_cases import OpenSearchTestCase +from test_opensearchpy.test_cases import OpenSearchTestCase class TestCluster(OpenSearchTestCase): diff --git a/test_opensearch/test_client/test_indices.py b/test_opensearchpy/test_client/test_indices.py similarity index 97% rename from test_opensearch/test_client/test_indices.py rename to test_opensearchpy/test_client/test_indices.py index ec914251..85fdeeaa 100644 --- a/test_opensearch/test_client/test_indices.py +++ b/test_opensearchpy/test_client/test_indices.py @@ -24,7 +24,7 @@ # specific language governing permissions and limitations # under the License. -from test_opensearch.test_cases import OpenSearchTestCase +from test_opensearchpy.test_cases import OpenSearchTestCase class TestIndices(OpenSearchTestCase): diff --git a/test_opensearch/test_client/test_overrides.py b/test_opensearchpy/test_client/test_overrides.py similarity index 99% rename from test_opensearch/test_client/test_overrides.py rename to test_opensearchpy/test_client/test_overrides.py index e777ef20..d71ef4b5 100644 --- a/test_opensearch/test_client/test_overrides.py +++ b/test_opensearchpy/test_client/test_overrides.py @@ -27,7 +27,7 @@ import pytest -from test_opensearch.test_cases import OpenSearchTestCase +from test_opensearchpy.test_cases import OpenSearchTestCase class TestOverriddenUrlTargets(OpenSearchTestCase): diff --git a/test_opensearch/test_client/test_utils.py b/test_opensearchpy/test_client/test_utils.py similarity index 98% rename from test_opensearch/test_client/test_utils.py rename to test_opensearchpy/test_client/test_utils.py index d3ab825a..43d48d18 100644 --- a/test_opensearch/test_client/test_utils.py +++ b/test_opensearchpy/test_client/test_utils.py @@ -27,8 +27,8 @@ from __future__ import unicode_literals -from opensearch.client.utils import _bulk_body, _escape, _make_path, query_params -from opensearch.compat import PY2 +from opensearchpy.client.utils import _bulk_body, _escape, _make_path, query_params +from opensearchpy.compat import PY2 from ..test_cases import SkipTest, TestCase diff --git a/test_opensearch/test_connection.py b/test_opensearchpy/test_connection.py similarity index 98% rename from test_opensearch/test_connection.py rename to test_opensearchpy/test_connection.py index e296a29b..bca7d3e7 100644 --- a/test_opensearch/test_connection.py +++ b/test_opensearchpy/test_connection.py @@ -40,14 +40,14 @@ from mock import Mock, patch from requests.auth import AuthBase from urllib3._collections import HTTPHeaderDict -from opensearch import __versionstr__ -from opensearch.compat import reraise_exceptions -from opensearch.connection import ( +from opensearchpy import __versionstr__ +from opensearchpy.compat import reraise_exceptions +from opensearchpy.connection import ( Connection, RequestsHttpConnection, Urllib3HttpConnection, ) -from opensearch.exceptions import ( +from opensearchpy.exceptions import ( ConflictError, ConnectionError, NotFoundError, @@ -450,7 +450,7 @@ class TestUrllib3Connection(TestCase): str(w[0].message), ) - @patch("opensearch.connection.base.logger") + @patch("opensearchpy.connection.base.logger") def test_uncompressed_body_logged(self, logger): con = self._get_mock_connection(connection_params={"http_compress": True}) con.perform_request("GET", "/", body=b'{"example": "body"}') @@ -714,9 +714,9 @@ class TestRequestsConnection(TestCase): self.assertEqual(("username", "secret"), con.session.auth) def test_repr(self): - con = self._get_mock_connection({"host": "opensearch.com", "port": 443}) + con = self._get_mock_connection({"host": "opensearchpy.com", "port": 443}) self.assertEqual( - "", repr(con) + "", repr(con) ) def test_conflict_error_is_returned_on_409(self): @@ -731,14 +731,14 @@ class TestRequestsConnection(TestCase): con = self._get_mock_connection(status_code=400) self.assertRaises(RequestError, con.perform_request, "GET", "/", {}, "") - @patch("opensearch.connection.base.logger") + @patch("opensearchpy.connection.base.logger") def test_head_with_404_doesnt_get_logged(self, logger): con = self._get_mock_connection(status_code=404) self.assertRaises(NotFoundError, con.perform_request, "HEAD", "/", {}, "") self.assertEqual(0, logger.warning.call_count) - @patch("opensearch.connection.base.tracer") - @patch("opensearch.connection.base.logger") + @patch("opensearchpy.connection.base.tracer") + @patch("opensearchpy.connection.base.logger") def test_failed_request_logs_and_traces(self, logger, tracer): con = self._get_mock_connection( response_body=b'{"answer": 42}', status_code=500 @@ -765,8 +765,8 @@ class TestRequestsConnection(TestCase): ) ) - @patch("opensearch.connection.base.tracer") - @patch("opensearch.connection.base.logger") + @patch("opensearchpy.connection.base.tracer") + @patch("opensearchpy.connection.base.logger") def test_success_logs_and_traces(self, logger, tracer): con = self._get_mock_connection(response_body=b"""{"answer": "that's it!"}""") status, headers, data = con.perform_request( @@ -805,7 +805,7 @@ class TestRequestsConnection(TestCase): self.assertEqual('> {"question": "what\'s that?"}', req[0][0] % req[0][1:]) self.assertEqual('< {"answer": "that\'s it!"}', resp[0][0] % resp[0][1:]) - @patch("opensearch.connection.base.logger") + @patch("opensearchpy.connection.base.logger") def test_uncompressed_body_logged(self, logger): con = self._get_mock_connection(connection_params={"http_compress": True}) con.perform_request("GET", "/", body=b'{"example": "body"}') @@ -860,7 +860,7 @@ class TestRequestsConnection(TestCase): self.assertEqual(request.headers["authorization"], "Basic dXNlcm5hbWU6c2VjcmV0") - @patch("opensearch.connection.base.tracer") + @patch("opensearchpy.connection.base.tracer") def test_url_prefix(self, tracer): con = self._get_mock_connection({"url_prefix": "/some-prefix/"}) request = self._get_request( diff --git a/test_opensearch/test_connection_pool.py b/test_opensearchpy/test_connection_pool.py similarity index 97% rename from test_opensearch/test_connection_pool.py rename to test_opensearchpy/test_connection_pool.py index 65a54052..b70703be 100644 --- a/test_opensearch/test_connection_pool.py +++ b/test_opensearchpy/test_connection_pool.py @@ -26,13 +26,13 @@ import time -from opensearch.connection import Connection -from opensearch.connection_pool import ( +from opensearchpy.connection import Connection +from opensearchpy.connection_pool import ( ConnectionPool, DummyConnectionPool, RoundRobinSelector, ) -from opensearch.exceptions import ImproperlyConfigured +from opensearchpy.exceptions import ImproperlyConfigured from .test_cases import TestCase diff --git a/test_opensearch/test_exceptions.py b/test_opensearchpy/test_exceptions.py similarity index 97% rename from test_opensearch/test_exceptions.py rename to test_opensearchpy/test_exceptions.py index 061855c8..2171b1c6 100644 --- a/test_opensearch/test_exceptions.py +++ b/test_opensearchpy/test_exceptions.py @@ -24,7 +24,7 @@ # specific language governing permissions and limitations # under the License. -from opensearch.exceptions import TransportError +from opensearchpy.exceptions import TransportError from .test_cases import TestCase diff --git a/test_opensearch/test_helpers.py b/test_opensearchpy/test_helpers.py similarity index 97% rename from test_opensearch/test_helpers.py rename to test_opensearchpy/test_helpers.py index 9d4d2ef9..a071baed 100644 --- a/test_opensearch/test_helpers.py +++ b/test_opensearchpy/test_helpers.py @@ -31,8 +31,8 @@ import time import mock import pytest -from opensearch import OpenSearch, helpers -from opensearch.serializer import JSONSerializer +from opensearchpy import OpenSearch, helpers +from opensearchpy.serializer import JSONSerializer from .test_cases import TestCase @@ -56,7 +56,7 @@ mock_process_bulk_chunk.call_count = 0 class TestParallelBulk(TestCase): @mock.patch( - "opensearch.helpers.actions._process_bulk_chunk", + "opensearchpy.helpers.actions._process_bulk_chunk", side_effect=mock_process_bulk_chunk, ) def test_all_chunks_sent(self, _process_bulk_chunk): @@ -67,7 +67,7 @@ class TestParallelBulk(TestCase): @pytest.mark.skip @mock.patch( - "opensearch.helpers.actions._process_bulk_chunk", + "opensearchpy.helpers.actions._process_bulk_chunk", # make sure we spend some time in the thread side_effect=lambda *a: [ (True, time.sleep(0.001) or threading.current_thread().ident) diff --git a/test_opensearch/test_serializer.py b/test_opensearchpy/test_serializer.py similarity index 98% rename from test_opensearch/test_serializer.py rename to test_opensearchpy/test_serializer.py index aa7d2c25..20c5f6f1 100644 --- a/test_opensearch/test_serializer.py +++ b/test_opensearchpy/test_serializer.py @@ -36,8 +36,8 @@ try: except ImportError: np = pd = None -from opensearch.exceptions import ImproperlyConfigured, SerializationError -from opensearch.serializer import ( +from opensearchpy.exceptions import ImproperlyConfigured, SerializationError +from opensearchpy.serializer import ( DEFAULT_SERIALIZERS, Deserializer, JSONSerializer, diff --git a/test_opensearch/test_server/__init__.py b/test_opensearchpy/test_server/__init__.py similarity index 90% rename from test_opensearch/test_server/__init__.py rename to test_opensearchpy/test_server/__init__.py index 67c82e19..70e93499 100644 --- a/test_opensearch/test_server/__init__.py +++ b/test_opensearchpy/test_server/__init__.py @@ -26,8 +26,8 @@ from unittest import SkipTest -from opensearch.helpers import test -from opensearch.helpers.test import OpenSearchTestCase as BaseTestCase +from opensearchpy.helpers import test +from opensearchpy.helpers.test import OpenSearchTestCase as BaseTestCase client = None @@ -41,7 +41,7 @@ def get_client(**kwargs): # try and locate manual override in the local environment try: - from test_opensearch.local import get_client as local_get_client + from test_opensearchpy.local import get_client as local_get_client new_client = local_get_client(**kwargs) except ImportError: diff --git a/test_opensearch/test_server/conftest.py b/test_opensearchpy/test_server/conftest.py similarity index 93% rename from test_opensearch/test_server/conftest.py rename to test_opensearchpy/test_server/conftest.py index 3feabc28..60437722 100644 --- a/test_opensearch/test_server/conftest.py +++ b/test_opensearchpy/test_server/conftest.py @@ -29,8 +29,8 @@ import time import pytest -import opensearch -from opensearch.helpers.test import CA_CERTS, OPENSEARCH_URL +import opensearchpy +from opensearchpy.helpers.test import CA_CERTS, OPENSEARCH_URL from ..utils import wipe_cluster @@ -53,7 +53,7 @@ def sync_client_factory(): "headers": {"Authorization": "Basic ZWxhc3RpYzpjaGFuZ2VtZQ=="}, } if "PYTHON_CONNECTION_CLASS" in os.environ: - from opensearch import connection + from opensearchpy import connection kw["connection_class"] = getattr( connection, os.environ["PYTHON_CONNECTION_CLASS"] @@ -61,7 +61,7 @@ def sync_client_factory(): # We do this little dance with the URL to force # Requests to respect 'headers: None' within rest API spec tests. - client = opensearch.OpenSearch( + client = opensearchpy.OpenSearch( OPENSEARCH_URL.replace("elastic:changeme@", ""), **kw ) diff --git a/test_opensearch/test_server/test_clients.py b/test_opensearchpy/test_server/test_clients.py similarity index 100% rename from test_opensearch/test_server/test_clients.py rename to test_opensearchpy/test_server/test_clients.py diff --git a/test_opensearch/test_server/test_helpers.py b/test_opensearchpy/test_server/test_helpers.py similarity index 99% rename from test_opensearch/test_server/test_helpers.py rename to test_opensearchpy/test_server/test_helpers.py index 08ef5d00..4029eff2 100644 --- a/test_opensearch/test_server/test_helpers.py +++ b/test_opensearchpy/test_server/test_helpers.py @@ -26,8 +26,8 @@ from mock import patch -from opensearch import TransportError, helpers -from opensearch.helpers import ScanError +from opensearchpy import TransportError, helpers +from opensearchpy.helpers import ScanError from ..test_cases import SkipTest from . import OpenSearchTestCase @@ -550,7 +550,7 @@ class TestScan(OpenSearchTestCase): ) self.assertEqual(client_mock.scroll.call_args[1]["sort"], "asc") - @patch("opensearch.helpers.actions.logger") + @patch("opensearchpy.helpers.actions.logger") def test_logger(self, logger_mock): bulk = [] for x in range(4): diff --git a/test_opensearch/test_server/test_rest_api_spec.py b/test_opensearchpy/test_server/test_rest_api_spec.py similarity index 98% rename from test_opensearch/test_server/test_rest_api_spec.py rename to test_opensearchpy/test_server/test_rest_api_spec.py index 84c5305d..0d328cc0 100644 --- a/test_opensearch/test_server/test_rest_api_spec.py +++ b/test_opensearchpy/test_server/test_rest_api_spec.py @@ -41,10 +41,10 @@ import pytest import urllib3 import yaml -from opensearch import OpenSearchWarning, TransportError -from opensearch.client.utils import _base64_auth_header -from opensearch.compat import string_types -from opensearch.helpers.test import _get_version +from opensearchpy import OpenSearchWarning, TransportError +from opensearchpy.client.utils import _base64_auth_header +from opensearchpy.compat import string_types +from opensearchpy.helpers.test import _get_version from . import get_client diff --git a/test_opensearch/test_server_secured/__init__.py b/test_opensearchpy/test_server_secured/__init__.py similarity index 100% rename from test_opensearch/test_server_secured/__init__.py rename to test_opensearchpy/test_server_secured/__init__.py diff --git a/test_opensearch/test_server_secured/test_clients.py b/test_opensearchpy/test_server_secured/test_clients.py similarity index 89% rename from test_opensearch/test_server_secured/test_clients.py rename to test_opensearchpy/test_server_secured/test_clients.py index 38b551de..e597c6ac 100644 --- a/test_opensearch/test_server_secured/test_clients.py +++ b/test_opensearchpy/test_server_secured/test_clients.py @@ -10,8 +10,8 @@ from unittest import TestCase -from opensearch import OpenSearch -from opensearch.helpers.test import OPENSEARCH_URL +from opensearchpy import OpenSearch +from opensearchpy.helpers.test import OPENSEARCH_URL class TestSecurity(TestCase): diff --git a/test_opensearch/test_transport.py b/test_opensearchpy/test_transport.py similarity index 97% rename from test_opensearch/test_transport.py rename to test_opensearchpy/test_transport.py index 0ed02579..318e1394 100644 --- a/test_opensearch/test_transport.py +++ b/test_opensearchpy/test_transport.py @@ -32,10 +32,10 @@ import time from mock import patch -from opensearch.connection import Connection -from opensearch.connection_pool import DummyConnectionPool -from opensearch.exceptions import ConnectionError, TransportError -from opensearch.transport import Transport, get_host_info +from opensearchpy.connection import Connection +from opensearchpy.connection_pool import DummyConnectionPool +from opensearchpy.exceptions import ConnectionError, TransportError +from opensearchpy.transport import Transport, get_host_info from .test_cases import TestCase @@ -343,7 +343,7 @@ class TestTransport(TestCase): self.assertEqual(1, len(t.connection_pool.connections)) self.assertEqual("http://1.1.1.1:123", t.get_connection().host) - @patch("opensearch.transport.Transport.sniff_hosts") + @patch("opensearchpy.transport.Transport.sniff_hosts") def test_sniff_on_fail_failing_does_not_prevent_retires(self, sniff_hosts): sniff_hosts.side_effect = [TransportError("sniff failed")] t = Transport( @@ -394,7 +394,7 @@ class TestTransport(TestCase): {"host": "somehost.tld", "port": 123}, ) - @patch("opensearch.transport.Transport.sniff_hosts") + @patch("opensearchpy.transport.Transport.sniff_hosts") def test_sniffing_disabled_on_cloud_instances(self, sniff_hosts): t = Transport( [{}], diff --git a/test_opensearch/test_types/README.md b/test_opensearchpy/test_types/README.md similarity index 100% rename from test_opensearch/test_types/README.md rename to test_opensearchpy/test_types/README.md diff --git a/test_opensearch/test_types/aliased_types.py b/test_opensearchpy/test_types/aliased_types.py similarity index 98% rename from test_opensearch/test_types/aliased_types.py rename to test_opensearchpy/test_types/aliased_types.py index bd24c5d6..94fb7a15 100644 --- a/test_opensearch/test_types/aliased_types.py +++ b/test_opensearchpy/test_types/aliased_types.py @@ -26,7 +26,7 @@ from typing import Any, AsyncGenerator, Dict, Generator -from opensearch1 import ( +from opensearchpy1 import ( AIOHttpConnection, AsyncOpenSearch, AsyncTransport, @@ -35,7 +35,7 @@ from opensearch1 import ( RequestsHttpConnection, Transport, ) -from opensearch1.helpers import ( +from opensearchpy1.helpers import ( async_bulk, async_reindex, async_scan, diff --git a/test_opensearch/test_types/async_types.py b/test_opensearchpy/test_types/async_types.py similarity index 98% rename from test_opensearch/test_types/async_types.py rename to test_opensearchpy/test_types/async_types.py index 7850815c..ae4cef5d 100644 --- a/test_opensearch/test_types/async_types.py +++ b/test_opensearchpy/test_types/async_types.py @@ -26,13 +26,13 @@ from typing import Any, AsyncGenerator, Dict -from opensearch import ( +from opensearchpy import ( AIOHttpConnection, AsyncOpenSearch, AsyncTransport, ConnectionPool, ) -from opensearch.helpers import ( +from opensearchpy.helpers import ( async_bulk, async_reindex, async_scan, diff --git a/test_opensearch/test_types/sync_types.py b/test_opensearchpy/test_types/sync_types.py similarity index 95% rename from test_opensearch/test_types/sync_types.py rename to test_opensearchpy/test_types/sync_types.py index 06b993ec..82dce82d 100644 --- a/test_opensearch/test_types/sync_types.py +++ b/test_opensearchpy/test_types/sync_types.py @@ -26,8 +26,8 @@ from typing import Any, Dict, Generator -from opensearch import ConnectionPool, OpenSearch, RequestsHttpConnection, Transport -from opensearch.helpers import bulk, reindex, scan, streaming_bulk +from opensearchpy import ConnectionPool, OpenSearch, RequestsHttpConnection, Transport +from opensearchpy.helpers import bulk, reindex, scan, streaming_bulk client = OpenSearch( [{"host": "localhost", "port": 9443}], diff --git a/test_opensearch/utils.py b/test_opensearchpy/utils.py similarity index 98% rename from test_opensearch/utils.py rename to test_opensearchpy/utils.py index fef7ab8f..17a1c379 100644 --- a/test_opensearch/utils.py +++ b/test_opensearchpy/utils.py @@ -26,7 +26,7 @@ import time -from opensearch import OpenSearch +from opensearchpy import OpenSearch def wipe_cluster(client): @@ -35,7 +35,7 @@ def wipe_cluster(client): try: # If client is async we need to replace the client # with a synchronous one. - from opensearch import AsyncOpenSearch + from opensearchpy import AsyncOpenSearch if isinstance(client, AsyncOpenSearch): client = OpenSearch(client.transport.hosts, verify_certs=False) diff --git a/utils/build-dists.py b/utils/build-dists.py index d541c6a3..7e4d1565 100644 --- a/utils/build-dists.py +++ b/utils/build-dists.py @@ -25,7 +25,7 @@ # under the License. """A command line tool for building and verifying releases -Can be used for building both 'opensearch' and 'opensearchX' dists. +Can be used for building both 'opensearchpy' and 'opensearchpyX' dists. Only requires 'name' in 'setup.py' and the directory to be changed. """ @@ -70,7 +70,7 @@ def run(*argv, expect_exit_code=0): def test_dist(dist): with set_tmp_dir() as tmp_dir: - dist_name = re.match(r"^(opensearch\d*)-", os.path.basename(dist)).group(1) + dist_name = re.match(r"^(opensearchpy\d*)-", os.path.basename(dist)).group(1) # Build the venv and install the dist run("python", "-m", "venv", os.path.join(tmp_dir, "venv")) @@ -117,18 +117,18 @@ def test_dist(dist): # Only need to test 'async_types' for non-aliased package # since 'aliased_types' tests both async and sync. - if dist_name == "opensearch": + if dist_name == "opensearchpy": run( venv_python, "-m", "mypy", "--strict", - os.path.join(base_dir, "test_opensearch/test_types/async_types.py"), + os.path.join(base_dir, "test_opensearchpy/test_types/async_types.py"), ) # Ensure that the namespaces are correct for the dist for suffix in ("", "1", "2", "5", "6", "7", "8", "9", "10"): - distx_name = f"opensearch{suffix}" + distx_name = f"opensearchpy{suffix}" run( venv_python, "-c", @@ -136,15 +136,15 @@ def test_dist(dist): expect_exit_code=256 if distx_name != dist_name else 0, ) - # Check that sync types work for 'opensearch' and - # that aliased types work for 'opensearchX' - if dist_name == "opensearch": + # Check that sync types work for 'opensearchpy' and + # that aliased types work for 'opensearchpyX' + if dist_name == "opensearchpy": run( venv_python, "-m", "mypy", "--strict", - os.path.join(base_dir, "test_opensearch/test_types/sync_types.py"), + os.path.join(base_dir, "test_opensearchpy/test_types/sync_types.py"), ) else: run( @@ -152,7 +152,7 @@ def test_dist(dist): "-m", "mypy", "--strict", - os.path.join(base_dir, "test_opensearch/test_types/aliased_types.py"), + os.path.join(base_dir, "test_opensearchpy/test_types/aliased_types.py"), ) # Uninstall the dist, see that we can't import things anymore @@ -166,11 +166,11 @@ def test_dist(dist): def main(): - run("git", "checkout", "--", "setup.py", "opensearch/") + run("git", "checkout", "--", "setup.py", "opensearchpy/") run("rm", "-rf", "build/", "dist/*", "*.egg-info", ".eggs") # Grab the major version to be used as a suffix. - version_path = os.path.join(base_dir, "opensearch/_version.py") + version_path = os.path.join(base_dir, "opensearchpy/_version.py") with open(version_path) as f: version = re.search( r"^__versionstr__\s+=\s+[\"\']([^\"\']+)[\"\']", f.read(), re.M @@ -228,12 +228,12 @@ def main(): # Rename the module to fit the suffix. shutil.move( - os.path.join(base_dir, "opensearch"), - os.path.join(base_dir, "opensearch%s" % suffix), + os.path.join(base_dir, "opensearchpy"), + os.path.join(base_dir, "opensearchpy%s" % suffix), ) - # Ensure that the version within 'opensearch/_version.py' is correct. - version_path = os.path.join(base_dir, f"opensearch{suffix}/_version.py") + # Ensure that the version within 'opensearchpy/_version.py' is correct. + version_path = os.path.join(base_dir, f"opensearchpy{suffix}/_version.py") with open(version_path) as f: version_data = f.read() version_data = re.sub( @@ -251,11 +251,11 @@ def main(): setup_py = f.read() with open(setup_py_path, "w") as f: f.truncate() - assert 'package_name = "opensearch"' in setup_py + assert 'package_name = "opensearchpy"' in setup_py f.write( setup_py.replace( - 'package_name = "opensearch"', - 'package_name = "opensearch%s"' % suffix, + 'package_name = "opensearchpy"', + 'package_name = "opensearchpy%s"' % suffix, ) ) @@ -263,9 +263,9 @@ def main(): run("python", "setup.py", "sdist", "bdist_wheel") # Clean up everything. - run("git", "checkout", "--", "setup.py", "opensearch/") + run("git", "checkout", "--", "setup.py", "opensearchpy/") if suffix: - run("rm", "-rf", "opensearch%s/" % suffix) + run("rm", "-rf", "opensearchpy%s/" % suffix) # Test everything that got created dists = os.listdir(os.path.join(base_dir, "dist")) diff --git a/utils/generate-api.py b/utils/generate-api.py index 7504057a..c65f143b 100644 --- a/utils/generate-api.py +++ b/utils/generate-api.py @@ -145,7 +145,7 @@ class Module: def filepath(self): return ( CODE_ROOT - / f"opensearch/_async/client/{self.namespace}.py{'i' if self.is_pyi else ''}" + / f"opensearchpy/_async/client/{self.namespace}.py{'i' if self.is_pyi else ''}" ) @@ -185,8 +185,8 @@ class API: # Try setting doc refs like 'current' and 'master' to our branches ref. if BRANCH_NAME is not None: revised_url = re.sub( - "/opensearch/reference/[^/]+/", - f"/opensearch/reference/{BRANCH_NAME}/", + "/opensearchpy/reference/[^/]+/", + f"/opensearchpy/reference/{BRANCH_NAME}/", self.doc_url, ) if is_valid_url(revised_url): @@ -339,9 +339,9 @@ def download_artifact(version): resp = http.request( "GET", f"https://artifacts-api.elastic.co/v1/versions/{version}" ) - packages = json.loads(resp.data)["version"]["builds"][0]["projects"]["opensearch"][ - "packages" - ] + packages = json.loads(resp.data)["version"]["builds"][0]["projects"][ + "opensearchpy" + ]["packages"] for package in packages: if re.match(r"^rest-resources-zip-.*\.zip$", package): zip_url = packages[package]["url"] @@ -411,14 +411,14 @@ def dump_modules(modules): } rules = [ unasync.Rule( - fromdir="/opensearch/_async/client/", - todir="/opensearch/client/", + fromdir="/opensearchpy/_async/client/", + todir="/opensearchpy/client/", additional_replacements=additional_replacements, ), ] filepaths = [] - for root, _, filenames in os.walk(CODE_ROOT / "opensearch/_async"): + for root, _, filenames in os.walk(CODE_ROOT / "opensearchpy/_async"): for filename in filenames: if ( filename.rpartition(".")[-1] @@ -431,7 +431,7 @@ def dump_modules(modules): filepaths.append(os.path.join(root, filename)) unasync.unasync_files(filepaths, rules) - blacken(CODE_ROOT / "opensearch") + blacken(CODE_ROOT / "opensearchpy") if __name__ == "__main__":