diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e5af18f60..00704e042 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: - name: Set up Python 3.x uses: actions/setup-python@v4 with: - python-version: 3.x + python-version: "3.11" - name: Install dependencies run: python3 -m pip install nox - name: Lint the code @@ -28,7 +28,7 @@ jobs: runs-on: ${{ matrix.runs-on }} name: test-${{ matrix.python-version }} - continue-on-error: true + continue-on-error: false steps: - name: Checkout Repository uses: actions/checkout@v3 @@ -43,4 +43,4 @@ jobs: run: .ci/run-nox.sh env: PYTHON_VERSION: ${{ matrix.python-version }} - NOX_SESSION: ${{ matrix.nox-session }} \ No newline at end of file + NOX_SESSION: ${{ matrix.nox-session }} diff --git a/.readthedocs.yml b/.readthedocs.yml index f98f5b245..b8dd3e7ca 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -7,7 +7,7 @@ build: # to set AIOHTTP_NO_EXTENSIONS to 1 but it has to be done in # https://readthedocs.org/dashboard/elasticsearch-py/environmentvariables/ # because of https://github.com/readthedocs/readthedocs.org/issues/6311 - python: "3" + python: "3.12" python: install: diff --git a/dev-requirements.txt b/dev-requirements.txt index 9fdcd5870..2aaaf3a56 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -15,9 +15,8 @@ twine build nox -# No wheels for Python 3.10 yet! -numpy; python_version<"3.10" -pandas; python_version<"3.10" +numpy +pandas # Testing the 'search_mvt' API response mapbox-vector-tile diff --git a/docs/guide/release-notes.asciidoc b/docs/guide/release-notes.asciidoc index 3f859644b..074f507e2 100644 --- a/docs/guide/release-notes.asciidoc +++ b/docs/guide/release-notes.asciidoc @@ -1,6 +1,10 @@ [[release-notes]] == Release notes +* <> +* <> +* <> +* <> * <> * <> * <> @@ -27,6 +31,33 @@ * <> * <> +[discrete] +[[rn-8-10-1]] +=== 8.10.1 (2023-10-13) + +- Removed deprecation warnings when using `body` parameter +- Fixed some type hints to use covariant Sequence instead of invariant List + +[discrete] +[[rn-8-10-0]] +=== 8.10.0 (2023-09-22) + +- Added the Query rules APIs +- Added the Synonyms APIs + +[discrete] +[[rn-8-9-0]] +=== 8.9.0 (2023-08-10) + +- Added the `cluster.info` API +- Updated the `inference_config` argument in `ml.put_trained_model` API to reflect an improvement in the specification + +[discrete] +[[rn-8-8-1]] +=== 8.8.1 (2023-07-06) + +* Added the `rank` parameter to the `search` API + [discrete] [[rn-8-8-0]] === 8.8.0 (2023-05-25) @@ -39,21 +70,21 @@ [[rn-8-7-0]] === 8.7.0 (2023-04-06) -* Added the ``health_report`` API -* Added the ``transform.schedule_now_transform`` API -* Added the ``from_`` request parameter to the ``transform.start_transform`` API -* Added the ``buffer``, ``grid_agg``, and ``with_labels`` parameters to the ``search_mvt`` API -* Added the ``allow_auto_create`` parameter to the ``cluster.create_component_template`` API -* Added the ``delete_user_annotations`` parameter to the ``ml.delete_job``, ``ml.reset_job`` API -* Added the ``start`` and ``end`` parameters to the ``ml.preview_datafeed`` API -* Added the ``priority`` parameter to the ``ml.start_datafeed`` API -* Added the ``job_id`` parameter to the ``ml.update_datafeed`` API -* Added the ``model_prune_window`` parameter to the ``ml.update_job`` API -* Added the ``feature_states`` parameter to the ``snapshot.restore_snapshot`` API -* Added the ``timeout`` parameter to the ``transform.get_transform_stats`` API -* Added the ``from_`` parameter to the ``transform.start_transform`` API -* Changed the ``input`` parameter of the ``ml.put_trained_models`` API from required to optional -* Fixed the ``cluster.create_component_template`` API by removing the erroneously provided ``aliases``, ``mappings``, and ``settings`` parameters. Only the ``template`` parameter should be used for specifying component templates. +* Added the `health_report` API +* Added the `transform.schedule_now_transform` API +* Added the `from_` request parameter to the `transform.start_transform` API +* Added the `buffer`, `grid_agg`, and `with_labels` parameters to the `search_mvt` API +* Added the `allow_auto_create` parameter to the `cluster.create_component_template` API +* Added the `delete_user_annotations` parameter to the `ml.delete_job`, `ml.reset_job` API +* Added the `start` and `end` parameters to the `ml.preview_datafeed` API +* Added the `priority` parameter to the `ml.start_datafeed` API +* Added the `job_id` parameter to the `ml.update_datafeed` API +* Added the `model_prune_window` parameter to the `ml.update_job` API +* Added the `feature_states` parameter to the `snapshot.restore_snapshot` API +* Added the `timeout` parameter to the `transform.get_transform_stats` API +* Added the `from_` parameter to the `transform.start_transform` API +* Changed the `input` parameter of the `ml.put_trained_models` API from required to optional +* Fixed the `cluster.create_component_template` API by removing the erroneously provided `aliases`, `mappings`, and `settings` parameters. Only the `template` parameter should be used for specifying component templates. [discrete] [[rn-8-6-2]] diff --git a/docs/sphinx/async.rst b/docs/sphinx/async.rst index 3cc4427ac..0f0b82123 100644 --- a/docs/sphinx/async.rst +++ b/docs/sphinx/async.rst @@ -94,17 +94,31 @@ For example if using FastAPI that might look like this: .. code-block:: python + import os + from contextlib import asynccontextmanager + from fastapi import FastAPI from elasticsearch import AsyncElasticsearch - app = FastAPI() - es = AsyncElasticsearch() + ELASTICSEARCH_URL = os.environ["ELASTICSEARCH_URL"] + es = None - # This gets called once the app is shutting down. - @app.on_event("shutdown") - async def app_shutdown(): + @asynccontextmanager + async def lifespan(app: FastAPI): + global es + es = AsyncElasticsearch(ELASTICSEARCH_URL) + yield await es.close() + app = FastAPI(lifespan=lifespan) + + @app.get("/") + async def main(): + return await es.info() + +You can run this example by saving it to ``main.py`` and executing +``ELASTICSEARCH_URL=http://localhost:9200 uvicorn main:app``. + Async Helpers ------------- diff --git a/elasticsearch/_async/client/ml.py b/elasticsearch/_async/client/ml.py index 9c1339aa1..38c312df3 100644 --- a/elasticsearch/_async/client/ml.py +++ b/elasticsearch/_async/client/ml.py @@ -3303,6 +3303,7 @@ async def put_trained_model_vocabulary( human: t.Optional[bool] = None, merges: t.Optional[t.Sequence[str]] = None, pretty: t.Optional[bool] = None, + scores: t.Optional[t.Sequence[float]] = None, ) -> ObjectApiResponse[t.Any]: """ Creates a trained model vocabulary @@ -3312,6 +3313,7 @@ async def put_trained_model_vocabulary( :param model_id: The unique identifier of the trained model. :param vocabulary: The model vocabulary, which must not be empty. :param merges: The optional model merges if required by the tokenizer. + :param scores: The optional vocabulary value scores if required by the tokenizer. """ if model_id in SKIP_IN_PATH: raise ValueError("Empty value passed for parameter 'model_id'") @@ -3332,6 +3334,8 @@ async def put_trained_model_vocabulary( __body["merges"] = merges if pretty is not None: __query["pretty"] = pretty + if scores is not None: + __body["scores"] = scores __headers = {"accept": "application/json", "content-type": "application/json"} return await self.perform_request( # type: ignore[return-value] "PUT", __path, params=__query, headers=__headers, body=__body diff --git a/elasticsearch/_async/client/transform.py b/elasticsearch/_async/client/transform.py index 307ac31f6..c4e603fe4 100644 --- a/elasticsearch/_async/client/transform.py +++ b/elasticsearch/_async/client/transform.py @@ -29,6 +29,7 @@ async def delete_transform( self, *, transform_id: str, + delete_dest_index: t.Optional[bool] = None, error_trace: t.Optional[bool] = None, filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, force: t.Optional[bool] = None, @@ -42,6 +43,9 @@ async def delete_transform( ``_ :param transform_id: Identifier for the transform. + :param delete_dest_index: If this value is true, the destination index is deleted + together with the transform. If false, the destination index will not be + deleted :param force: If this value is false, the transform must be stopped before it can be deleted. If true, the transform is deleted regardless of its current state. @@ -52,6 +56,8 @@ async def delete_transform( raise ValueError("Empty value passed for parameter 'transform_id'") __path = f"/_transform/{_quote(transform_id)}" __query: t.Dict[str, t.Any] = {} + if delete_dest_index is not None: + __query["delete_dest_index"] = delete_dest_index if error_trace is not None: __query["error_trace"] = error_trace if filter_path is not None: diff --git a/elasticsearch/_sync/client/ml.py b/elasticsearch/_sync/client/ml.py index ce85e587c..3a7a7601c 100644 --- a/elasticsearch/_sync/client/ml.py +++ b/elasticsearch/_sync/client/ml.py @@ -3303,6 +3303,7 @@ def put_trained_model_vocabulary( human: t.Optional[bool] = None, merges: t.Optional[t.Sequence[str]] = None, pretty: t.Optional[bool] = None, + scores: t.Optional[t.Sequence[float]] = None, ) -> ObjectApiResponse[t.Any]: """ Creates a trained model vocabulary @@ -3312,6 +3313,7 @@ def put_trained_model_vocabulary( :param model_id: The unique identifier of the trained model. :param vocabulary: The model vocabulary, which must not be empty. :param merges: The optional model merges if required by the tokenizer. + :param scores: The optional vocabulary value scores if required by the tokenizer. """ if model_id in SKIP_IN_PATH: raise ValueError("Empty value passed for parameter 'model_id'") @@ -3332,6 +3334,8 @@ def put_trained_model_vocabulary( __body["merges"] = merges if pretty is not None: __query["pretty"] = pretty + if scores is not None: + __body["scores"] = scores __headers = {"accept": "application/json", "content-type": "application/json"} return self.perform_request( # type: ignore[return-value] "PUT", __path, params=__query, headers=__headers, body=__body diff --git a/elasticsearch/_sync/client/transform.py b/elasticsearch/_sync/client/transform.py index fce52db75..63631d3fd 100644 --- a/elasticsearch/_sync/client/transform.py +++ b/elasticsearch/_sync/client/transform.py @@ -29,6 +29,7 @@ def delete_transform( self, *, transform_id: str, + delete_dest_index: t.Optional[bool] = None, error_trace: t.Optional[bool] = None, filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, force: t.Optional[bool] = None, @@ -42,6 +43,9 @@ def delete_transform( ``_ :param transform_id: Identifier for the transform. + :param delete_dest_index: If this value is true, the destination index is deleted + together with the transform. If false, the destination index will not be + deleted :param force: If this value is false, the transform must be stopped before it can be deleted. If true, the transform is deleted regardless of its current state. @@ -52,6 +56,8 @@ def delete_transform( raise ValueError("Empty value passed for parameter 'transform_id'") __path = f"/_transform/{_quote(transform_id)}" __query: t.Dict[str, t.Any] = {} + if delete_dest_index is not None: + __query["delete_dest_index"] = delete_dest_index if error_trace is not None: __query["error_trace"] = error_trace if filter_path is not None: