Skip to content

Commit b338b18

Browse files
Auto-generated API code (#2571)
1 parent 7c9ec88 commit b338b18

File tree

2 files changed

+112
-0
lines changed

2 files changed

+112
-0
lines changed

elasticsearch/_async/client/ml.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5043,6 +5043,62 @@ async def update_model_snapshot(
50435043
path_parts=__path_parts,
50445044
)
50455045

5046+
@_rewrite_parameters(
5047+
body_fields=("number_of_allocations",),
5048+
)
5049+
async def update_trained_model_deployment(
5050+
self,
5051+
*,
5052+
model_id: str,
5053+
error_trace: t.Optional[bool] = None,
5054+
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
5055+
human: t.Optional[bool] = None,
5056+
number_of_allocations: t.Optional[int] = None,
5057+
pretty: t.Optional[bool] = None,
5058+
body: t.Optional[t.Dict[str, t.Any]] = None,
5059+
) -> ObjectApiResponse[t.Any]:
5060+
"""
5061+
Updates certain properties of trained model deployment.
5062+
5063+
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/update-trained-model-deployment.html>`_
5064+
5065+
:param model_id: The unique identifier of the trained model. Currently, only
5066+
PyTorch models are supported.
5067+
:param number_of_allocations: The number of model allocations on each node where
5068+
the model is deployed. All allocations on a node share the same copy of the
5069+
model in memory but use a separate set of threads to evaluate the model.
5070+
Increasing this value generally increases the throughput. If this setting
5071+
is greater than the number of hardware threads it will automatically be changed
5072+
to a value less than the number of hardware threads.
5073+
"""
5074+
if model_id in SKIP_IN_PATH:
5075+
raise ValueError("Empty value passed for parameter 'model_id'")
5076+
__path_parts: t.Dict[str, str] = {"model_id": _quote(model_id)}
5077+
__path = f'/_ml/trained_models/{__path_parts["model_id"]}/deployment/_update'
5078+
__query: t.Dict[str, t.Any] = {}
5079+
__body: t.Dict[str, t.Any] = body if body is not None else {}
5080+
if error_trace is not None:
5081+
__query["error_trace"] = error_trace
5082+
if filter_path is not None:
5083+
__query["filter_path"] = filter_path
5084+
if human is not None:
5085+
__query["human"] = human
5086+
if pretty is not None:
5087+
__query["pretty"] = pretty
5088+
if not __body:
5089+
if number_of_allocations is not None:
5090+
__body["number_of_allocations"] = number_of_allocations
5091+
__headers = {"accept": "application/json", "content-type": "application/json"}
5092+
return await self.perform_request( # type: ignore[return-value]
5093+
"POST",
5094+
__path,
5095+
params=__query,
5096+
headers=__headers,
5097+
body=__body,
5098+
endpoint_id="ml.update_trained_model_deployment",
5099+
path_parts=__path_parts,
5100+
)
5101+
50465102
@_rewrite_parameters()
50475103
async def upgrade_job_snapshot(
50485104
self,

elasticsearch/_sync/client/ml.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5043,6 +5043,62 @@ def update_model_snapshot(
50435043
path_parts=__path_parts,
50445044
)
50455045

5046+
@_rewrite_parameters(
5047+
body_fields=("number_of_allocations",),
5048+
)
5049+
def update_trained_model_deployment(
5050+
self,
5051+
*,
5052+
model_id: str,
5053+
error_trace: t.Optional[bool] = None,
5054+
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
5055+
human: t.Optional[bool] = None,
5056+
number_of_allocations: t.Optional[int] = None,
5057+
pretty: t.Optional[bool] = None,
5058+
body: t.Optional[t.Dict[str, t.Any]] = None,
5059+
) -> ObjectApiResponse[t.Any]:
5060+
"""
5061+
Updates certain properties of trained model deployment.
5062+
5063+
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/update-trained-model-deployment.html>`_
5064+
5065+
:param model_id: The unique identifier of the trained model. Currently, only
5066+
PyTorch models are supported.
5067+
:param number_of_allocations: The number of model allocations on each node where
5068+
the model is deployed. All allocations on a node share the same copy of the
5069+
model in memory but use a separate set of threads to evaluate the model.
5070+
Increasing this value generally increases the throughput. If this setting
5071+
is greater than the number of hardware threads it will automatically be changed
5072+
to a value less than the number of hardware threads.
5073+
"""
5074+
if model_id in SKIP_IN_PATH:
5075+
raise ValueError("Empty value passed for parameter 'model_id'")
5076+
__path_parts: t.Dict[str, str] = {"model_id": _quote(model_id)}
5077+
__path = f'/_ml/trained_models/{__path_parts["model_id"]}/deployment/_update'
5078+
__query: t.Dict[str, t.Any] = {}
5079+
__body: t.Dict[str, t.Any] = body if body is not None else {}
5080+
if error_trace is not None:
5081+
__query["error_trace"] = error_trace
5082+
if filter_path is not None:
5083+
__query["filter_path"] = filter_path
5084+
if human is not None:
5085+
__query["human"] = human
5086+
if pretty is not None:
5087+
__query["pretty"] = pretty
5088+
if not __body:
5089+
if number_of_allocations is not None:
5090+
__body["number_of_allocations"] = number_of_allocations
5091+
__headers = {"accept": "application/json", "content-type": "application/json"}
5092+
return self.perform_request( # type: ignore[return-value]
5093+
"POST",
5094+
__path,
5095+
params=__query,
5096+
headers=__headers,
5097+
body=__body,
5098+
endpoint_id="ml.update_trained_model_deployment",
5099+
path_parts=__path_parts,
5100+
)
5101+
50465102
@_rewrite_parameters()
50475103
def upgrade_job_snapshot(
50485104
self,

0 commit comments

Comments
 (0)