Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into fix-ci-3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
pquentin committed Nov 8, 2023
2 parents 18867bf + 5183a07 commit ca67740
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 27 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -43,4 +43,4 @@ jobs:
run: .ci/run-nox.sh
env:
PYTHON_VERSION: ${{ matrix.python-version }}
NOX_SESSION: ${{ matrix.nox-session }}
NOX_SESSION: ${{ matrix.nox-session }}
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 2 additions & 3 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
61 changes: 46 additions & 15 deletions docs/guide/release-notes.asciidoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
[[release-notes]]
== Release notes

* <<rn-8-10-1>>
* <<rn-8-10-0>>
* <<rn-8-9-0>>
* <<rn-8-8-1>>
* <<rn-8-8-0>>
* <<rn-8-7-0>>
* <<rn-8-6-2>>
Expand All @@ -27,6 +31,33 @@
* <<rn-8-1-0>>
* <<rn-8-0-0>>

[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)
Expand All @@ -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]]
Expand Down
24 changes: 19 additions & 5 deletions docs/sphinx/async.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
-------------
Expand Down
4 changes: 4 additions & 0 deletions elasticsearch/_async/client/ml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'")
Expand All @@ -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
Expand Down
6 changes: 6 additions & 0 deletions elasticsearch/_async/client/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -42,6 +43,9 @@ async def delete_transform(
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-transform.html>`_
: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.
Expand All @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions elasticsearch/_sync/client/ml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'")
Expand All @@ -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
Expand Down
6 changes: 6 additions & 0 deletions elasticsearch/_sync/client/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -42,6 +43,9 @@ def delete_transform(
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-transform.html>`_
: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.
Expand All @@ -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:
Expand Down

0 comments on commit ca67740

Please sign in to comment.