From b1f322974e8d25c7f45ef8360daa333b8ee03162 Mon Sep 17 00:00:00 2001 From: scaleway-bot Date: Wed, 12 Mar 2025 08:49:23 +0000 Subject: [PATCH] feat: update generated APIs --- .../scaleway_async/inference/v1/__init__.py | 79 ++ .../scaleway_async/inference/v1/api.py | 867 ++++++++++++++++++ .../scaleway_async/inference/v1/content.py | 24 + .../inference/v1/marshalling.py | 654 +++++++++++++ .../scaleway_async/inference/v1/types.py | 770 ++++++++++++++++ scaleway/scaleway/inference/v1/__init__.py | 79 ++ scaleway/scaleway/inference/v1/api.py | 865 +++++++++++++++++ scaleway/scaleway/inference/v1/content.py | 24 + scaleway/scaleway/inference/v1/marshalling.py | 654 +++++++++++++ scaleway/scaleway/inference/v1/types.py | 770 ++++++++++++++++ 10 files changed, 4786 insertions(+) create mode 100644 scaleway-async/scaleway_async/inference/v1/__init__.py create mode 100644 scaleway-async/scaleway_async/inference/v1/api.py create mode 100644 scaleway-async/scaleway_async/inference/v1/content.py create mode 100644 scaleway-async/scaleway_async/inference/v1/marshalling.py create mode 100644 scaleway-async/scaleway_async/inference/v1/types.py create mode 100644 scaleway/scaleway/inference/v1/__init__.py create mode 100644 scaleway/scaleway/inference/v1/api.py create mode 100644 scaleway/scaleway/inference/v1/content.py create mode 100644 scaleway/scaleway/inference/v1/marshalling.py create mode 100644 scaleway/scaleway/inference/v1/types.py diff --git a/scaleway-async/scaleway_async/inference/v1/__init__.py b/scaleway-async/scaleway_async/inference/v1/__init__.py new file mode 100644 index 000000000..526e0c63a --- /dev/null +++ b/scaleway-async/scaleway_async/inference/v1/__init__.py @@ -0,0 +1,79 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from .types import DeploymentStatus +from .content import DEPLOYMENT_TRANSIENT_STATUSES +from .types import ListDeploymentsRequestOrderBy +from .types import ListModelsRequestOrderBy +from .types import ModelStatus +from .content import MODEL_TRANSIENT_STATUSES +from .types import NodeTypeStock +from .types import ModelSupportedQuantization +from .types import EndpointPrivateNetworkDetails +from .types import EndpointPublicNetworkDetails +from .types import ModelSupportedNode +from .types import DeploymentQuantization +from .types import Endpoint +from .types import ModelSupportInfo +from .types import EndpointSpec +from .types import ModelSource +from .types import Deployment +from .types import Model +from .types import NodeType +from .types import CreateDeploymentRequest +from .types import CreateEndpointRequest +from .types import CreateModelRequest +from .types import DeleteDeploymentRequest +from .types import DeleteEndpointRequest +from .types import DeleteModelRequest +from .types import GetDeploymentCertificateRequest +from .types import GetDeploymentRequest +from .types import GetModelRequest +from .types import ListDeploymentsRequest +from .types import ListDeploymentsResponse +from .types import ListModelsRequest +from .types import ListModelsResponse +from .types import ListNodeTypesRequest +from .types import ListNodeTypesResponse +from .types import UpdateDeploymentRequest +from .types import UpdateEndpointRequest +from .api import InferenceV1API + +__all__ = [ + "DeploymentStatus", + "DEPLOYMENT_TRANSIENT_STATUSES", + "ListDeploymentsRequestOrderBy", + "ListModelsRequestOrderBy", + "ModelStatus", + "MODEL_TRANSIENT_STATUSES", + "NodeTypeStock", + "ModelSupportedQuantization", + "EndpointPrivateNetworkDetails", + "EndpointPublicNetworkDetails", + "ModelSupportedNode", + "DeploymentQuantization", + "Endpoint", + "ModelSupportInfo", + "EndpointSpec", + "ModelSource", + "Deployment", + "Model", + "NodeType", + "CreateDeploymentRequest", + "CreateEndpointRequest", + "CreateModelRequest", + "DeleteDeploymentRequest", + "DeleteEndpointRequest", + "DeleteModelRequest", + "GetDeploymentCertificateRequest", + "GetDeploymentRequest", + "GetModelRequest", + "ListDeploymentsRequest", + "ListDeploymentsResponse", + "ListModelsRequest", + "ListModelsResponse", + "ListNodeTypesRequest", + "ListNodeTypesResponse", + "UpdateDeploymentRequest", + "UpdateEndpointRequest", + "InferenceV1API", +] diff --git a/scaleway-async/scaleway_async/inference/v1/api.py b/scaleway-async/scaleway_async/inference/v1/api.py new file mode 100644 index 000000000..4a25975a8 --- /dev/null +++ b/scaleway-async/scaleway_async/inference/v1/api.py @@ -0,0 +1,867 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. + +from typing import Awaitable, List, Optional, Union + +from scaleway_core.api import API +from scaleway_core.bridge import ( + Region as ScwRegion, + ScwFile, + unmarshal_ScwFile, +) +from scaleway_core.utils import ( + WaitForOptions, + random_name, + validate_path_param, + fetch_all_pages_async, + wait_for_resource_async, +) +from .types import ( + ListDeploymentsRequestOrderBy, + ListModelsRequestOrderBy, + CreateDeploymentRequest, + CreateEndpointRequest, + CreateModelRequest, + Deployment, + DeploymentQuantization, + Endpoint, + EndpointSpec, + ListDeploymentsResponse, + ListModelsResponse, + ListNodeTypesResponse, + Model, + ModelSource, + NodeType, + UpdateDeploymentRequest, + UpdateEndpointRequest, +) +from .content import ( + DEPLOYMENT_TRANSIENT_STATUSES, + MODEL_TRANSIENT_STATUSES, +) +from .marshalling import ( + unmarshal_Endpoint, + unmarshal_Deployment, + unmarshal_Model, + unmarshal_ListDeploymentsResponse, + unmarshal_ListModelsResponse, + unmarshal_ListNodeTypesResponse, + marshal_CreateDeploymentRequest, + marshal_CreateEndpointRequest, + marshal_CreateModelRequest, + marshal_UpdateDeploymentRequest, + marshal_UpdateEndpointRequest, +) + + +class InferenceV1API(API): + """ + This API allows you to handle your Managed Inference services. + """ + + async def list_deployments( + self, + *, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListDeploymentsRequestOrderBy] = None, + project_id: Optional[str] = None, + organization_id: Optional[str] = None, + name: Optional[str] = None, + tags: Optional[List[str]] = None, + ) -> ListDeploymentsResponse: + """ + List inference deployments. + List all your inference deployments. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number to return. + :param page_size: Maximum number of deployments to return per page. + :param order_by: Order in which to return results. + :param project_id: Filter by Project ID. + :param organization_id: Filter by Organization ID. + :param name: Filter by deployment name. + :param tags: Filter by tags. + :return: :class:`ListDeploymentsResponse ` + + Usage: + :: + + result = await api.list_deployments() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/inference/v1/regions/{param_region}/deployments", + params={ + "name": name, + "order_by": order_by, + "organization_id": organization_id + or self.client.default_organization_id, + "page": page, + "page_size": page_size or self.client.default_page_size, + "project_id": project_id or self.client.default_project_id, + "tags": tags, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListDeploymentsResponse(res.json()) + + async def list_deployments_all( + self, + *, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListDeploymentsRequestOrderBy] = None, + project_id: Optional[str] = None, + organization_id: Optional[str] = None, + name: Optional[str] = None, + tags: Optional[List[str]] = None, + ) -> List[Deployment]: + """ + List inference deployments. + List all your inference deployments. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number to return. + :param page_size: Maximum number of deployments to return per page. + :param order_by: Order in which to return results. + :param project_id: Filter by Project ID. + :param organization_id: Filter by Organization ID. + :param name: Filter by deployment name. + :param tags: Filter by tags. + :return: :class:`List[Deployment] ` + + Usage: + :: + + result = await api.list_deployments_all() + """ + + return await fetch_all_pages_async( + type=ListDeploymentsResponse, + key="deployments", + fetcher=self.list_deployments, + args={ + "region": region, + "page": page, + "page_size": page_size, + "order_by": order_by, + "project_id": project_id, + "organization_id": organization_id, + "name": name, + "tags": tags, + }, + ) + + async def get_deployment( + self, + *, + deployment_id: str, + region: Optional[ScwRegion] = None, + ) -> Deployment: + """ + Get a deployment. + Get the deployment for the given ID. + :param deployment_id: ID of the deployment to get. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Deployment ` + + Usage: + :: + + result = await api.get_deployment( + deployment_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_deployment_id = validate_path_param("deployment_id", deployment_id) + + res = self._request( + "GET", + f"/inference/v1/regions/{param_region}/deployments/{param_deployment_id}", + ) + + self._throw_on_error(res) + return unmarshal_Deployment(res.json()) + + async def wait_for_deployment( + self, + *, + deployment_id: str, + region: Optional[ScwRegion] = None, + options: Optional[ + WaitForOptions[Deployment, Union[bool, Awaitable[bool]]] + ] = None, + ) -> Deployment: + """ + Get a deployment. + Get the deployment for the given ID. + :param deployment_id: ID of the deployment to get. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Deployment ` + + Usage: + :: + + result = await api.get_deployment( + deployment_id="example", + ) + """ + + if not options: + options = WaitForOptions() + + if not options.stop: + options.stop = lambda res: res.status not in DEPLOYMENT_TRANSIENT_STATUSES + + return await wait_for_resource_async( + fetcher=self.get_deployment, + options=options, + args={ + "deployment_id": deployment_id, + "region": region, + }, + ) + + async def create_deployment( + self, + *, + model_id: str, + node_type_name: str, + endpoints: List[EndpointSpec], + region: Optional[ScwRegion] = None, + name: Optional[str] = None, + project_id: Optional[str] = None, + accept_eula: Optional[bool] = None, + tags: Optional[List[str]] = None, + min_size: Optional[int] = None, + max_size: Optional[int] = None, + quantization: Optional[DeploymentQuantization] = None, + ) -> Deployment: + """ + Create a deployment. + Create a new inference deployment related to a specific model. + :param model_id: ID of the model to use. + :param node_type_name: Name of the node type to use. + :param endpoints: List of endpoints to create. + :param region: Region to target. If none is passed will use default region from the config. + :param name: Name of the deployment. + :param project_id: ID of the Project to create the deployment in. + :param accept_eula: If the model has an EULA, you must accept it before proceeding. + The terms of the EULA can be retrieved using the `GetModelEula` API call. + :param tags: List of tags to apply to the deployment. + :param min_size: Defines the minimum size of the pool. + :param max_size: Defines the maximum size of the pool. + :param quantization: Quantization settings to apply to this deployment. + :return: :class:`Deployment ` + + Usage: + :: + + result = await api.create_deployment( + model_id="example", + node_type_name="example", + endpoints=[], + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "POST", + f"/inference/v1/regions/{param_region}/deployments", + body=marshal_CreateDeploymentRequest( + CreateDeploymentRequest( + model_id=model_id, + node_type_name=node_type_name, + endpoints=endpoints, + region=region, + name=name or random_name(prefix="inference"), + project_id=project_id, + accept_eula=accept_eula, + tags=tags, + min_size=min_size, + max_size=max_size, + quantization=quantization, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Deployment(res.json()) + + async def update_deployment( + self, + *, + deployment_id: str, + region: Optional[ScwRegion] = None, + name: Optional[str] = None, + tags: Optional[List[str]] = None, + min_size: Optional[int] = None, + max_size: Optional[int] = None, + ) -> Deployment: + """ + Update a deployment. + Update an existing inference deployment. + :param deployment_id: ID of the deployment to update. + :param region: Region to target. If none is passed will use default region from the config. + :param name: Name of the deployment. + :param tags: List of tags to apply to the deployment. + :param min_size: Defines the new minimum size of the pool. + :param max_size: Defines the new maximum size of the pool. + :return: :class:`Deployment ` + + Usage: + :: + + result = await api.update_deployment( + deployment_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_deployment_id = validate_path_param("deployment_id", deployment_id) + + res = self._request( + "PATCH", + f"/inference/v1/regions/{param_region}/deployments/{param_deployment_id}", + body=marshal_UpdateDeploymentRequest( + UpdateDeploymentRequest( + deployment_id=deployment_id, + region=region, + name=name, + tags=tags, + min_size=min_size, + max_size=max_size, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Deployment(res.json()) + + async def delete_deployment( + self, + *, + deployment_id: str, + region: Optional[ScwRegion] = None, + ) -> Deployment: + """ + Delete a deployment. + Delete an existing inference deployment. + :param deployment_id: ID of the deployment to delete. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Deployment ` + + Usage: + :: + + result = await api.delete_deployment( + deployment_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_deployment_id = validate_path_param("deployment_id", deployment_id) + + res = self._request( + "DELETE", + f"/inference/v1/regions/{param_region}/deployments/{param_deployment_id}", + ) + + self._throw_on_error(res) + return unmarshal_Deployment(res.json()) + + async def get_deployment_certificate( + self, + *, + deployment_id: str, + region: Optional[ScwRegion] = None, + ) -> ScwFile: + """ + Get the CA certificate. + Get the CA certificate used for the deployment of private endpoints. + The CA certificate will be returned as a PEM file. + :param deployment_id: + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`ScwFile ` + + Usage: + :: + + result = await api.get_deployment_certificate( + deployment_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_deployment_id = validate_path_param("deployment_id", deployment_id) + + res = self._request( + "GET", + f"/inference/v1/regions/{param_region}/deployments/{param_deployment_id}/certificate", + ) + + self._throw_on_error(res) + return unmarshal_ScwFile(res.json()) + + async def create_endpoint( + self, + *, + deployment_id: str, + endpoint: EndpointSpec, + region: Optional[ScwRegion] = None, + ) -> Endpoint: + """ + Create an endpoint. + Create a new Endpoint related to a specific deployment. + :param deployment_id: ID of the deployment to create the endpoint for. + :param endpoint: Specification of the endpoint. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Endpoint ` + + Usage: + :: + + result = await api.create_endpoint( + deployment_id="example", + endpoint=EndpointSpec(), + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "POST", + f"/inference/v1/regions/{param_region}/endpoints", + body=marshal_CreateEndpointRequest( + CreateEndpointRequest( + deployment_id=deployment_id, + endpoint=endpoint, + region=region, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Endpoint(res.json()) + + async def update_endpoint( + self, + *, + endpoint_id: str, + region: Optional[ScwRegion] = None, + disable_auth: Optional[bool] = None, + ) -> Endpoint: + """ + Update an endpoint. + Update an existing Endpoint. + :param endpoint_id: ID of the endpoint to update. + :param region: Region to target. If none is passed will use default region from the config. + :param disable_auth: By default, deployments are protected by IAM authentication. + When setting this field to true, the authentication will be disabled. + :return: :class:`Endpoint ` + + Usage: + :: + + result = await api.update_endpoint( + endpoint_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_endpoint_id = validate_path_param("endpoint_id", endpoint_id) + + res = self._request( + "PATCH", + f"/inference/v1/regions/{param_region}/endpoints/{param_endpoint_id}", + body=marshal_UpdateEndpointRequest( + UpdateEndpointRequest( + endpoint_id=endpoint_id, + region=region, + disable_auth=disable_auth, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Endpoint(res.json()) + + async def delete_endpoint( + self, + *, + endpoint_id: str, + region: Optional[ScwRegion] = None, + ) -> None: + """ + Delete an endpoint. + Delete an existing Endpoint. + :param endpoint_id: ID of the endpoint to delete. + :param region: Region to target. If none is passed will use default region from the config. + + Usage: + :: + + result = await api.delete_endpoint( + endpoint_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_endpoint_id = validate_path_param("endpoint_id", endpoint_id) + + res = self._request( + "DELETE", + f"/inference/v1/regions/{param_region}/endpoints/{param_endpoint_id}", + ) + + self._throw_on_error(res) + + async def list_models( + self, + *, + region: Optional[ScwRegion] = None, + order_by: Optional[ListModelsRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + project_id: Optional[str] = None, + name: Optional[str] = None, + tags: Optional[List[str]] = None, + ) -> ListModelsResponse: + """ + List models. + List all available models. + :param region: Region to target. If none is passed will use default region from the config. + :param order_by: Order in which to return results. + :param page: Page number to return. + :param page_size: Maximum number of models to return per page. + :param project_id: Filter by Project ID. + :param name: Filter by model name. + :param tags: Filter by tags. + :return: :class:`ListModelsResponse ` + + Usage: + :: + + result = await api.list_models() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/inference/v1/regions/{param_region}/models", + params={ + "name": name, + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + "project_id": project_id or self.client.default_project_id, + "tags": tags, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListModelsResponse(res.json()) + + async def list_models_all( + self, + *, + region: Optional[ScwRegion] = None, + order_by: Optional[ListModelsRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + project_id: Optional[str] = None, + name: Optional[str] = None, + tags: Optional[List[str]] = None, + ) -> List[Model]: + """ + List models. + List all available models. + :param region: Region to target. If none is passed will use default region from the config. + :param order_by: Order in which to return results. + :param page: Page number to return. + :param page_size: Maximum number of models to return per page. + :param project_id: Filter by Project ID. + :param name: Filter by model name. + :param tags: Filter by tags. + :return: :class:`List[Model] ` + + Usage: + :: + + result = await api.list_models_all() + """ + + return await fetch_all_pages_async( + type=ListModelsResponse, + key="models", + fetcher=self.list_models, + args={ + "region": region, + "order_by": order_by, + "page": page, + "page_size": page_size, + "project_id": project_id, + "name": name, + "tags": tags, + }, + ) + + async def get_model( + self, + *, + model_id: str, + region: Optional[ScwRegion] = None, + ) -> Model: + """ + Get a model. + Get the model for the given ID. + :param model_id: ID of the model to get. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Model ` + + Usage: + :: + + result = await api.get_model( + model_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_model_id = validate_path_param("model_id", model_id) + + res = self._request( + "GET", + f"/inference/v1/regions/{param_region}/models/{param_model_id}", + ) + + self._throw_on_error(res) + return unmarshal_Model(res.json()) + + async def wait_for_model( + self, + *, + model_id: str, + region: Optional[ScwRegion] = None, + options: Optional[WaitForOptions[Model, Union[bool, Awaitable[bool]]]] = None, + ) -> Model: + """ + Get a model. + Get the model for the given ID. + :param model_id: ID of the model to get. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Model ` + + Usage: + :: + + result = await api.get_model( + model_id="example", + ) + """ + + if not options: + options = WaitForOptions() + + if not options.stop: + options.stop = lambda res: res.status not in MODEL_TRANSIENT_STATUSES + + return await wait_for_resource_async( + fetcher=self.get_model, + options=options, + args={ + "model_id": model_id, + "region": region, + }, + ) + + async def create_model( + self, + *, + source: ModelSource, + region: Optional[ScwRegion] = None, + name: Optional[str] = None, + project_id: Optional[str] = None, + ) -> Model: + """ + Import a model. + Import a new model to your model library. + :param source: Where to import the model from. + :param region: Region to target. If none is passed will use default region from the config. + :param name: Name of the model. + :param project_id: ID of the Project to import the model in. + :return: :class:`Model ` + + Usage: + :: + + result = await api.create_model( + source=ModelSource(), + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "POST", + f"/inference/v1/regions/{param_region}/models", + body=marshal_CreateModelRequest( + CreateModelRequest( + source=source, + region=region, + name=name or random_name(prefix="model"), + project_id=project_id, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Model(res.json()) + + async def delete_model( + self, + *, + model_id: str, + region: Optional[ScwRegion] = None, + ) -> None: + """ + Delete a model. + Delete an existing model from your model library. + :param model_id: ID of the model to delete. + :param region: Region to target. If none is passed will use default region from the config. + + Usage: + :: + + result = await api.delete_model( + model_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_model_id = validate_path_param("model_id", model_id) + + res = self._request( + "DELETE", + f"/inference/v1/regions/{param_region}/models/{param_model_id}", + ) + + self._throw_on_error(res) + + async def list_node_types( + self, + *, + include_disabled_types: bool, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> ListNodeTypesResponse: + """ + List available node types. + List all available node types. By default, the node types returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. + :param include_disabled_types: Include disabled node types in the response. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number to return. + :param page_size: Maximum number of node types to return per page. + :return: :class:`ListNodeTypesResponse ` + + Usage: + :: + + result = await api.list_node_types( + include_disabled_types=False, + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/inference/v1/regions/{param_region}/node-types", + params={ + "include_disabled_types": include_disabled_types, + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListNodeTypesResponse(res.json()) + + async def list_node_types_all( + self, + *, + include_disabled_types: bool, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[NodeType]: + """ + List available node types. + List all available node types. By default, the node types returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. + :param include_disabled_types: Include disabled node types in the response. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number to return. + :param page_size: Maximum number of node types to return per page. + :return: :class:`List[NodeType] ` + + Usage: + :: + + result = await api.list_node_types_all( + include_disabled_types=False, + ) + """ + + return await fetch_all_pages_async( + type=ListNodeTypesResponse, + key="node_types", + fetcher=self.list_node_types, + args={ + "include_disabled_types": include_disabled_types, + "region": region, + "page": page, + "page_size": page_size, + }, + ) diff --git a/scaleway-async/scaleway_async/inference/v1/content.py b/scaleway-async/scaleway_async/inference/v1/content.py new file mode 100644 index 000000000..887e0b7ec --- /dev/null +++ b/scaleway-async/scaleway_async/inference/v1/content.py @@ -0,0 +1,24 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from typing import List + +from .types import ( + DeploymentStatus, + ModelStatus, +) + +DEPLOYMENT_TRANSIENT_STATUSES: List[DeploymentStatus] = [ + DeploymentStatus.CREATING, + DeploymentStatus.DEPLOYING, + DeploymentStatus.DELETING, +] +""" +Lists transient statutes of the enum :class:`DeploymentStatus `. +""" +MODEL_TRANSIENT_STATUSES: List[ModelStatus] = [ + ModelStatus.PREPARING, + ModelStatus.DOWNLOADING, +] +""" +Lists transient statutes of the enum :class:`ModelStatus `. +""" diff --git a/scaleway-async/scaleway_async/inference/v1/marshalling.py b/scaleway-async/scaleway_async/inference/v1/marshalling.py new file mode 100644 index 000000000..9f10b88e1 --- /dev/null +++ b/scaleway-async/scaleway_async/inference/v1/marshalling.py @@ -0,0 +1,654 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. + +from typing import Any, Dict +from dateutil import parser + +from scaleway_core.profile import ProfileDefaults +from scaleway_core.utils import ( + OneOfPossibility, + resolve_one_of, +) +from .types import ( + EndpointPrivateNetworkDetails, + EndpointPublicNetworkDetails, + Endpoint, + ModelSupportedQuantization, + ModelSupportedNode, + ModelSupportInfo, + DeploymentQuantization, + Deployment, + Model, + ListDeploymentsResponse, + ListModelsResponse, + NodeType, + ListNodeTypesResponse, + EndpointSpec, + CreateDeploymentRequest, + CreateEndpointRequest, + ModelSource, + CreateModelRequest, + UpdateDeploymentRequest, + UpdateEndpointRequest, +) + + +def unmarshal_EndpointPrivateNetworkDetails(data: Any) -> EndpointPrivateNetworkDetails: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'EndpointPrivateNetworkDetails' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("private_network_id", None) + if field is not None: + args["private_network_id"] = field + + return EndpointPrivateNetworkDetails(**args) + + +def unmarshal_EndpointPublicNetworkDetails(data: Any) -> EndpointPublicNetworkDetails: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'EndpointPublicNetworkDetails' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + return EndpointPublicNetworkDetails(**args) + + +def unmarshal_Endpoint(data: Any) -> Endpoint: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Endpoint' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("url", None) + if field is not None: + args["url"] = field + + field = data.get("disable_auth", None) + if field is not None: + args["disable_auth"] = field + + field = data.get("public_network", None) + if field is not None: + args["public_network"] = unmarshal_EndpointPublicNetworkDetails(field) + else: + args["public_network"] = None + + field = data.get("private_network", None) + if field is not None: + args["private_network"] = unmarshal_EndpointPrivateNetworkDetails(field) + else: + args["private_network"] = None + + return Endpoint(**args) + + +def unmarshal_ModelSupportedQuantization(data: Any) -> ModelSupportedQuantization: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ModelSupportedQuantization' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("quantization_bits", None) + if field is not None: + args["quantization_bits"] = field + + field = data.get("allowed", None) + if field is not None: + args["allowed"] = field + + field = data.get("max_context_size", None) + if field is not None: + args["max_context_size"] = field + + return ModelSupportedQuantization(**args) + + +def unmarshal_ModelSupportedNode(data: Any) -> ModelSupportedNode: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ModelSupportedNode' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("node_type_name", None) + if field is not None: + args["node_type_name"] = field + + field = data.get("quantizations", None) + if field is not None: + args["quantizations"] = ( + [unmarshal_ModelSupportedQuantization(v) for v in field] + if field is not None + else None + ) + + return ModelSupportedNode(**args) + + +def unmarshal_ModelSupportInfo(data: Any) -> ModelSupportInfo: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ModelSupportInfo' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("nodes", None) + if field is not None: + args["nodes"] = ( + [unmarshal_ModelSupportedNode(v) for v in field] + if field is not None + else None + ) + + return ModelSupportInfo(**args) + + +def unmarshal_DeploymentQuantization(data: Any) -> DeploymentQuantization: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'DeploymentQuantization' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("enabled", None) + if field is not None: + args["enabled"] = field + + field = data.get("bits", None) + if field is not None: + args["bits"] = field + + return DeploymentQuantization(**args) + + +def unmarshal_Deployment(data: Any) -> Deployment: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Deployment' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("name", None) + if field is not None: + args["name"] = field + + field = data.get("project_id", None) + if field is not None: + args["project_id"] = field + + field = data.get("status", None) + if field is not None: + args["status"] = field + + field = data.get("tags", None) + if field is not None: + args["tags"] = field + + field = data.get("node_type_name", None) + if field is not None: + args["node_type_name"] = field + + field = data.get("endpoints", None) + if field is not None: + args["endpoints"] = ( + [unmarshal_Endpoint(v) for v in field] if field is not None else None + ) + + field = data.get("size", None) + if field is not None: + args["size"] = field + + field = data.get("min_size", None) + if field is not None: + args["min_size"] = field + + field = data.get("max_size", None) + if field is not None: + args["max_size"] = field + + field = data.get("model_id", None) + if field is not None: + args["model_id"] = field + + field = data.get("model_name", None) + if field is not None: + args["model_name"] = field + + field = data.get("region", None) + if field is not None: + args["region"] = field + + field = data.get("error_message", None) + if field is not None: + args["error_message"] = field + else: + args["error_message"] = None + + field = data.get("quantization", None) + if field is not None: + args["quantization"] = unmarshal_DeploymentQuantization(field) + else: + args["quantization"] = None + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + return Deployment(**args) + + +def unmarshal_Model(data: Any) -> Model: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Model' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("name", None) + if field is not None: + args["name"] = field + + field = data.get("project_id", None) + if field is not None: + args["project_id"] = field + + field = data.get("tags", None) + if field is not None: + args["tags"] = field + + field = data.get("status", None) + if field is not None: + args["status"] = field + + field = data.get("description", None) + if field is not None: + args["description"] = field + + field = data.get("has_eula", None) + if field is not None: + args["has_eula"] = field + + field = data.get("region", None) + if field is not None: + args["region"] = field + + field = data.get("nodes_support", None) + if field is not None: + args["nodes_support"] = ( + [unmarshal_ModelSupportInfo(v) for v in field] + if field is not None + else None + ) + + field = data.get("parameter_size_bits", None) + if field is not None: + args["parameter_size_bits"] = field + + field = data.get("size_bytes", None) + if field is not None: + args["size_bytes"] = field + + field = data.get("error_message", None) + if field is not None: + args["error_message"] = field + else: + args["error_message"] = None + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + return Model(**args) + + +def unmarshal_ListDeploymentsResponse(data: Any) -> ListDeploymentsResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListDeploymentsResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("deployments", None) + if field is not None: + args["deployments"] = ( + [unmarshal_Deployment(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListDeploymentsResponse(**args) + + +def unmarshal_ListModelsResponse(data: Any) -> ListModelsResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListModelsResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("models", None) + if field is not None: + args["models"] = ( + [unmarshal_Model(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListModelsResponse(**args) + + +def unmarshal_NodeType(data: Any) -> NodeType: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'NodeType' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("name", None) + if field is not None: + args["name"] = field + + field = data.get("stock_status", None) + if field is not None: + args["stock_status"] = field + + field = data.get("description", None) + if field is not None: + args["description"] = field + + field = data.get("vcpus", None) + if field is not None: + args["vcpus"] = field + + field = data.get("memory", None) + if field is not None: + args["memory"] = field + + field = data.get("vram", None) + if field is not None: + args["vram"] = field + + field = data.get("disabled", None) + if field is not None: + args["disabled"] = field + + field = data.get("beta", None) + if field is not None: + args["beta"] = field + + field = data.get("gpus", None) + if field is not None: + args["gpus"] = field + + field = data.get("region", None) + if field is not None: + args["region"] = field + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + return NodeType(**args) + + +def unmarshal_ListNodeTypesResponse(data: Any) -> ListNodeTypesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListNodeTypesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("node_types", None) + if field is not None: + args["node_types"] = ( + [unmarshal_NodeType(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListNodeTypesResponse(**args) + + +def marshal_EndpointPrivateNetworkDetails( + request: EndpointPrivateNetworkDetails, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.private_network_id is not None: + output["private_network_id"] = request.private_network_id + + return output + + +def marshal_EndpointPublicNetworkDetails( + request: EndpointPublicNetworkDetails, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + return output + + +def marshal_DeploymentQuantization( + request: DeploymentQuantization, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.enabled is not None: + output["enabled"] = request.enabled + + if request.bits is not None: + output["bits"] = request.bits + + return output + + +def marshal_EndpointSpec( + request: EndpointSpec, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("public_network", request.public_network), + OneOfPossibility("private_network", request.private_network), + ] + ), + ) + + if request.disable_auth is not None: + output["disable_auth"] = request.disable_auth + + return output + + +def marshal_CreateDeploymentRequest( + request: CreateDeploymentRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.model_id is not None: + output["model_id"] = request.model_id + + if request.node_type_name is not None: + output["node_type_name"] = request.node_type_name + + if request.endpoints is not None: + output["endpoints"] = [ + marshal_EndpointSpec(item, defaults) for item in request.endpoints + ] + + if request.name is not None: + output["name"] = request.name + + if request.project_id is not None: + output["project_id"] = request.project_id or defaults.default_project_id + + if request.accept_eula is not None: + output["accept_eula"] = request.accept_eula + + if request.tags is not None: + output["tags"] = request.tags + + if request.min_size is not None: + output["min_size"] = request.min_size + + if request.max_size is not None: + output["max_size"] = request.max_size + + if request.quantization is not None: + output["quantization"] = marshal_DeploymentQuantization( + request.quantization, defaults + ) + + return output + + +def marshal_CreateEndpointRequest( + request: CreateEndpointRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.deployment_id is not None: + output["deployment_id"] = request.deployment_id + + if request.endpoint is not None: + output["endpoint"] = marshal_EndpointSpec(request.endpoint, defaults) + + return output + + +def marshal_ModelSource( + request: ModelSource, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("secret", request.secret), + ] + ), + ) + + if request.url is not None: + output["url"] = request.url + + return output + + +def marshal_CreateModelRequest( + request: CreateModelRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.source is not None: + output["source"] = marshal_ModelSource(request.source, defaults) + + if request.name is not None: + output["name"] = request.name + + if request.project_id is not None: + output["project_id"] = request.project_id or defaults.default_project_id + + return output + + +def marshal_UpdateDeploymentRequest( + request: UpdateDeploymentRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.name is not None: + output["name"] = request.name + + if request.tags is not None: + output["tags"] = request.tags + + if request.min_size is not None: + output["min_size"] = request.min_size + + if request.max_size is not None: + output["max_size"] = request.max_size + + return output + + +def marshal_UpdateEndpointRequest( + request: UpdateEndpointRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.disable_auth is not None: + output["disable_auth"] = request.disable_auth + + return output diff --git a/scaleway-async/scaleway_async/inference/v1/types.py b/scaleway-async/scaleway_async/inference/v1/types.py new file mode 100644 index 000000000..9dd6fce4b --- /dev/null +++ b/scaleway-async/scaleway_async/inference/v1/types.py @@ -0,0 +1,770 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from __future__ import annotations + +from dataclasses import dataclass +from datetime import datetime +from enum import Enum +from typing import List, Optional + +from scaleway_core.bridge import ( + Region as ScwRegion, +) +from scaleway_core.utils import ( + StrEnumMeta, +) + + +class DeploymentStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + CREATING = "creating" + DEPLOYING = "deploying" + READY = "ready" + ERROR = "error" + DELETING = "deleting" + LOCKED = "locked" + + def __str__(self) -> str: + return str(self.value) + + +class ListDeploymentsRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_DESC = "created_at_desc" + CREATED_AT_ASC = "created_at_asc" + NAME_ASC = "name_asc" + NAME_DESC = "name_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ListModelsRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + DISPLAY_RANK_ASC = "display_rank_asc" + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + NAME_ASC = "name_asc" + NAME_DESC = "name_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ModelStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + PREPARING = "preparing" + DOWNLOADING = "downloading" + READY = "ready" + ERROR = "error" + + def __str__(self) -> str: + return str(self.value) + + +class NodeTypeStock(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STOCK = "unknown_stock" + LOW_STOCK = "low_stock" + OUT_OF_STOCK = "out_of_stock" + AVAILABLE = "available" + + def __str__(self) -> str: + return str(self.value) + + +@dataclass +class ModelSupportedQuantization: + quantization_bits: int + """ + Number of bits for this supported quantization. + """ + + allowed: bool + """ + Tells whether this quantization is allowed for this node type. + """ + + max_context_size: int + """ + Maximum inference context size available for this node type and quantization. + """ + + +@dataclass +class EndpointPrivateNetworkDetails: + private_network_id: str + + +@dataclass +class EndpointPublicNetworkDetails: + pass + + +@dataclass +class ModelSupportedNode: + node_type_name: str + """ + Supported node type. + """ + + quantizations: List[ModelSupportedQuantization] + """ + Supported quantizations. + """ + + +@dataclass +class DeploymentQuantization: + enabled: bool + """ + Whether to enable quantization for this deployment. + """ + + bits: int + """ + The number of bits each model parameter should be quantized to. The quantization method is chosen based on this value. + """ + + +@dataclass +class Endpoint: + id: str + """ + Unique identifier. + """ + + url: str + """ + For private endpoints, the URL will be accessible only from the Private Network. +In addition, private endpoints will expose a CA certificate that can be used to verify the server's identity. +This CA certificate can be retrieved using the `GetDeploymentCertificate` API call. + """ + + disable_auth: bool + """ + Defines whether the authentication is disabled. + """ + + public_network: Optional[EndpointPublicNetworkDetails] + + private_network: Optional[EndpointPrivateNetworkDetails] + + +@dataclass +class ModelSupportInfo: + nodes: List[ModelSupportedNode] + """ + List of supported node types. + """ + + +@dataclass +class EndpointSpec: + disable_auth: bool + """ + By default, deployments are protected by IAM authentication. +When setting this field to true, the authentication will be disabled. + """ + + public_network: Optional[EndpointPublicNetworkDetails] + + private_network: Optional[EndpointPrivateNetworkDetails] + + +@dataclass +class ModelSource: + url: str + + secret: Optional[str] + + +@dataclass +class Deployment: + id: str + """ + Unique identifier. + """ + + name: str + """ + Name of the deployment. + """ + + project_id: str + """ + Project ID. + """ + + status: DeploymentStatus + """ + Status of the deployment. + """ + + tags: List[str] + """ + List of tags applied to the deployment. + """ + + node_type_name: str + """ + Node type of the deployment. + """ + + endpoints: List[Endpoint] + """ + List of endpoints. + """ + + size: int + """ + Current size of the pool. + """ + + min_size: int + """ + Defines the minimum size of the pool. + """ + + max_size: int + """ + Defines the maximum size of the pool. + """ + + model_id: str + """ + ID of the model used for the deployment. + """ + + model_name: str + """ + Name of the deployed model. + """ + + region: ScwRegion + """ + Region of the deployment. + """ + + error_message: Optional[str] + """ + Displays information if your deployment is in error state. + """ + + quantization: Optional[DeploymentQuantization] + """ + Quantization parameters for this deployment. + """ + + created_at: Optional[datetime] + """ + Creation date of the deployment. + """ + + updated_at: Optional[datetime] + """ + Last modification date of the deployment. + """ + + +@dataclass +class Model: + id: str + """ + Unique identifier. + """ + + name: str + """ + Unique Name identifier. + """ + + project_id: str + """ + Project ID. + """ + + tags: List[str] + """ + List of tags applied to the model. + """ + + status: ModelStatus + """ + Status of the model. + """ + + description: str + """ + Purpose of the model. + """ + + has_eula: bool + """ + Defines whether the model has an end user license agreement. + """ + + region: ScwRegion + """ + Region of the model. + """ + + nodes_support: List[ModelSupportInfo] + """ + Supported nodes types with quantization options and context lengths. + """ + + parameter_size_bits: int + """ + Size, in bits, of the model parameters. + """ + + size_bytes: int + """ + Total size, in bytes, of the model files. + """ + + error_message: Optional[str] + """ + Displays information if your model is in error state. + """ + + created_at: Optional[datetime] + """ + Creation date of the model. + """ + + updated_at: Optional[datetime] + """ + Last modification date of the model. + """ + + +@dataclass +class NodeType: + name: str + """ + Name of the node type. + """ + + stock_status: NodeTypeStock + """ + Current stock status for the node type. + """ + + description: str + """ + Current specs of the offer. + """ + + vcpus: int + """ + Number of virtual CPUs. + """ + + memory: int + """ + Quantity of RAM. + """ + + vram: int + """ + Quantity of GPU RAM. + """ + + disabled: bool + """ + The node type is currently disabled. + """ + + beta: bool + """ + The node type is currently in beta. + """ + + gpus: int + """ + Number of GPUs. + """ + + region: ScwRegion + """ + Region of the node type. + """ + + created_at: Optional[datetime] + """ + Creation date of the node type. + """ + + updated_at: Optional[datetime] + """ + Last modification date of the node type. + """ + + +@dataclass +class CreateDeploymentRequest: + model_id: str + """ + ID of the model to use. + """ + + node_type_name: str + """ + Name of the node type to use. + """ + + endpoints: List[EndpointSpec] + """ + List of endpoints to create. + """ + + region: Optional[ScwRegion] + """ + Region to target. If none is passed will use default region from the config. + """ + + name: Optional[str] + """ + Name of the deployment. + """ + + project_id: Optional[str] + """ + ID of the Project to create the deployment in. + """ + + accept_eula: Optional[bool] + """ + If the model has an EULA, you must accept it before proceeding. +The terms of the EULA can be retrieved using the `GetModelEula` API call. + """ + + tags: Optional[List[str]] + """ + List of tags to apply to the deployment. + """ + + min_size: Optional[int] + """ + Defines the minimum size of the pool. + """ + + max_size: Optional[int] + """ + Defines the maximum size of the pool. + """ + + quantization: Optional[DeploymentQuantization] + """ + Quantization settings to apply to this deployment. + """ + + +@dataclass +class CreateEndpointRequest: + deployment_id: str + """ + ID of the deployment to create the endpoint for. + """ + + endpoint: EndpointSpec + """ + Specification of the endpoint. + """ + + region: Optional[ScwRegion] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class CreateModelRequest: + source: ModelSource + """ + Where to import the model from. + """ + + region: Optional[ScwRegion] + """ + Region to target. If none is passed will use default region from the config. + """ + + name: Optional[str] + """ + Name of the model. + """ + + project_id: Optional[str] + """ + ID of the Project to import the model in. + """ + + +@dataclass +class DeleteDeploymentRequest: + deployment_id: str + """ + ID of the deployment to delete. + """ + + region: Optional[ScwRegion] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DeleteEndpointRequest: + endpoint_id: str + """ + ID of the endpoint to delete. + """ + + region: Optional[ScwRegion] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DeleteModelRequest: + model_id: str + """ + ID of the model to delete. + """ + + region: Optional[ScwRegion] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class GetDeploymentCertificateRequest: + deployment_id: str + + region: Optional[ScwRegion] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class GetDeploymentRequest: + deployment_id: str + """ + ID of the deployment to get. + """ + + region: Optional[ScwRegion] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class GetModelRequest: + model_id: str + """ + ID of the model to get. + """ + + region: Optional[ScwRegion] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class ListDeploymentsRequest: + region: Optional[ScwRegion] + """ + Region to target. If none is passed will use default region from the config. + """ + + page: Optional[int] + """ + Page number to return. + """ + + page_size: Optional[int] + """ + Maximum number of deployments to return per page. + """ + + order_by: Optional[ListDeploymentsRequestOrderBy] + """ + Order in which to return results. + """ + + project_id: Optional[str] + """ + Filter by Project ID. + """ + + organization_id: Optional[str] + """ + Filter by Organization ID. + """ + + name: Optional[str] + """ + Filter by deployment name. + """ + + tags: Optional[List[str]] + """ + Filter by tags. + """ + + +@dataclass +class ListDeploymentsResponse: + deployments: List[Deployment] + """ + List of deployments on the current page. + """ + + total_count: int + """ + Total number of deployments. + """ + + +@dataclass +class ListModelsRequest: + region: Optional[ScwRegion] + """ + Region to target. If none is passed will use default region from the config. + """ + + order_by: Optional[ListModelsRequestOrderBy] + """ + Order in which to return results. + """ + + page: Optional[int] + """ + Page number to return. + """ + + page_size: Optional[int] + """ + Maximum number of models to return per page. + """ + + project_id: Optional[str] + """ + Filter by Project ID. + """ + + name: Optional[str] + """ + Filter by model name. + """ + + tags: Optional[List[str]] + """ + Filter by tags. + """ + + +@dataclass +class ListModelsResponse: + models: List[Model] + """ + List of models on the current page. + """ + + total_count: int + """ + Total number of models. + """ + + +@dataclass +class ListNodeTypesRequest: + include_disabled_types: bool + """ + Include disabled node types in the response. + """ + + region: Optional[ScwRegion] + """ + Region to target. If none is passed will use default region from the config. + """ + + page: Optional[int] + """ + Page number to return. + """ + + page_size: Optional[int] + """ + Maximum number of node types to return per page. + """ + + +@dataclass +class ListNodeTypesResponse: + node_types: List[NodeType] + """ + List of node types. + """ + + total_count: int + """ + Total number of node types. + """ + + +@dataclass +class UpdateDeploymentRequest: + deployment_id: str + """ + ID of the deployment to update. + """ + + region: Optional[ScwRegion] + """ + Region to target. If none is passed will use default region from the config. + """ + + name: Optional[str] + """ + Name of the deployment. + """ + + tags: Optional[List[str]] + """ + List of tags to apply to the deployment. + """ + + min_size: Optional[int] + """ + Defines the new minimum size of the pool. + """ + + max_size: Optional[int] + """ + Defines the new maximum size of the pool. + """ + + +@dataclass +class UpdateEndpointRequest: + endpoint_id: str + """ + ID of the endpoint to update. + """ + + region: Optional[ScwRegion] + """ + Region to target. If none is passed will use default region from the config. + """ + + disable_auth: Optional[bool] + """ + By default, deployments are protected by IAM authentication. +When setting this field to true, the authentication will be disabled. + """ diff --git a/scaleway/scaleway/inference/v1/__init__.py b/scaleway/scaleway/inference/v1/__init__.py new file mode 100644 index 000000000..526e0c63a --- /dev/null +++ b/scaleway/scaleway/inference/v1/__init__.py @@ -0,0 +1,79 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from .types import DeploymentStatus +from .content import DEPLOYMENT_TRANSIENT_STATUSES +from .types import ListDeploymentsRequestOrderBy +from .types import ListModelsRequestOrderBy +from .types import ModelStatus +from .content import MODEL_TRANSIENT_STATUSES +from .types import NodeTypeStock +from .types import ModelSupportedQuantization +from .types import EndpointPrivateNetworkDetails +from .types import EndpointPublicNetworkDetails +from .types import ModelSupportedNode +from .types import DeploymentQuantization +from .types import Endpoint +from .types import ModelSupportInfo +from .types import EndpointSpec +from .types import ModelSource +from .types import Deployment +from .types import Model +from .types import NodeType +from .types import CreateDeploymentRequest +from .types import CreateEndpointRequest +from .types import CreateModelRequest +from .types import DeleteDeploymentRequest +from .types import DeleteEndpointRequest +from .types import DeleteModelRequest +from .types import GetDeploymentCertificateRequest +from .types import GetDeploymentRequest +from .types import GetModelRequest +from .types import ListDeploymentsRequest +from .types import ListDeploymentsResponse +from .types import ListModelsRequest +from .types import ListModelsResponse +from .types import ListNodeTypesRequest +from .types import ListNodeTypesResponse +from .types import UpdateDeploymentRequest +from .types import UpdateEndpointRequest +from .api import InferenceV1API + +__all__ = [ + "DeploymentStatus", + "DEPLOYMENT_TRANSIENT_STATUSES", + "ListDeploymentsRequestOrderBy", + "ListModelsRequestOrderBy", + "ModelStatus", + "MODEL_TRANSIENT_STATUSES", + "NodeTypeStock", + "ModelSupportedQuantization", + "EndpointPrivateNetworkDetails", + "EndpointPublicNetworkDetails", + "ModelSupportedNode", + "DeploymentQuantization", + "Endpoint", + "ModelSupportInfo", + "EndpointSpec", + "ModelSource", + "Deployment", + "Model", + "NodeType", + "CreateDeploymentRequest", + "CreateEndpointRequest", + "CreateModelRequest", + "DeleteDeploymentRequest", + "DeleteEndpointRequest", + "DeleteModelRequest", + "GetDeploymentCertificateRequest", + "GetDeploymentRequest", + "GetModelRequest", + "ListDeploymentsRequest", + "ListDeploymentsResponse", + "ListModelsRequest", + "ListModelsResponse", + "ListNodeTypesRequest", + "ListNodeTypesResponse", + "UpdateDeploymentRequest", + "UpdateEndpointRequest", + "InferenceV1API", +] diff --git a/scaleway/scaleway/inference/v1/api.py b/scaleway/scaleway/inference/v1/api.py new file mode 100644 index 000000000..4cecd31cd --- /dev/null +++ b/scaleway/scaleway/inference/v1/api.py @@ -0,0 +1,865 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. + +from typing import List, Optional + +from scaleway_core.api import API +from scaleway_core.bridge import ( + Region as ScwRegion, + ScwFile, + unmarshal_ScwFile, +) +from scaleway_core.utils import ( + WaitForOptions, + random_name, + validate_path_param, + fetch_all_pages, + wait_for_resource, +) +from .types import ( + ListDeploymentsRequestOrderBy, + ListModelsRequestOrderBy, + CreateDeploymentRequest, + CreateEndpointRequest, + CreateModelRequest, + Deployment, + DeploymentQuantization, + Endpoint, + EndpointSpec, + ListDeploymentsResponse, + ListModelsResponse, + ListNodeTypesResponse, + Model, + ModelSource, + NodeType, + UpdateDeploymentRequest, + UpdateEndpointRequest, +) +from .content import ( + DEPLOYMENT_TRANSIENT_STATUSES, + MODEL_TRANSIENT_STATUSES, +) +from .marshalling import ( + unmarshal_Endpoint, + unmarshal_Deployment, + unmarshal_Model, + unmarshal_ListDeploymentsResponse, + unmarshal_ListModelsResponse, + unmarshal_ListNodeTypesResponse, + marshal_CreateDeploymentRequest, + marshal_CreateEndpointRequest, + marshal_CreateModelRequest, + marshal_UpdateDeploymentRequest, + marshal_UpdateEndpointRequest, +) + + +class InferenceV1API(API): + """ + This API allows you to handle your Managed Inference services. + """ + + def list_deployments( + self, + *, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListDeploymentsRequestOrderBy] = None, + project_id: Optional[str] = None, + organization_id: Optional[str] = None, + name: Optional[str] = None, + tags: Optional[List[str]] = None, + ) -> ListDeploymentsResponse: + """ + List inference deployments. + List all your inference deployments. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number to return. + :param page_size: Maximum number of deployments to return per page. + :param order_by: Order in which to return results. + :param project_id: Filter by Project ID. + :param organization_id: Filter by Organization ID. + :param name: Filter by deployment name. + :param tags: Filter by tags. + :return: :class:`ListDeploymentsResponse ` + + Usage: + :: + + result = api.list_deployments() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/inference/v1/regions/{param_region}/deployments", + params={ + "name": name, + "order_by": order_by, + "organization_id": organization_id + or self.client.default_organization_id, + "page": page, + "page_size": page_size or self.client.default_page_size, + "project_id": project_id or self.client.default_project_id, + "tags": tags, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListDeploymentsResponse(res.json()) + + def list_deployments_all( + self, + *, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListDeploymentsRequestOrderBy] = None, + project_id: Optional[str] = None, + organization_id: Optional[str] = None, + name: Optional[str] = None, + tags: Optional[List[str]] = None, + ) -> List[Deployment]: + """ + List inference deployments. + List all your inference deployments. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number to return. + :param page_size: Maximum number of deployments to return per page. + :param order_by: Order in which to return results. + :param project_id: Filter by Project ID. + :param organization_id: Filter by Organization ID. + :param name: Filter by deployment name. + :param tags: Filter by tags. + :return: :class:`List[Deployment] ` + + Usage: + :: + + result = api.list_deployments_all() + """ + + return fetch_all_pages( + type=ListDeploymentsResponse, + key="deployments", + fetcher=self.list_deployments, + args={ + "region": region, + "page": page, + "page_size": page_size, + "order_by": order_by, + "project_id": project_id, + "organization_id": organization_id, + "name": name, + "tags": tags, + }, + ) + + def get_deployment( + self, + *, + deployment_id: str, + region: Optional[ScwRegion] = None, + ) -> Deployment: + """ + Get a deployment. + Get the deployment for the given ID. + :param deployment_id: ID of the deployment to get. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Deployment ` + + Usage: + :: + + result = api.get_deployment( + deployment_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_deployment_id = validate_path_param("deployment_id", deployment_id) + + res = self._request( + "GET", + f"/inference/v1/regions/{param_region}/deployments/{param_deployment_id}", + ) + + self._throw_on_error(res) + return unmarshal_Deployment(res.json()) + + def wait_for_deployment( + self, + *, + deployment_id: str, + region: Optional[ScwRegion] = None, + options: Optional[WaitForOptions[Deployment, bool]] = None, + ) -> Deployment: + """ + Get a deployment. + Get the deployment for the given ID. + :param deployment_id: ID of the deployment to get. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Deployment ` + + Usage: + :: + + result = api.get_deployment( + deployment_id="example", + ) + """ + + if not options: + options = WaitForOptions() + + if not options.stop: + options.stop = lambda res: res.status not in DEPLOYMENT_TRANSIENT_STATUSES + + return wait_for_resource( + fetcher=self.get_deployment, + options=options, + args={ + "deployment_id": deployment_id, + "region": region, + }, + ) + + def create_deployment( + self, + *, + model_id: str, + node_type_name: str, + endpoints: List[EndpointSpec], + region: Optional[ScwRegion] = None, + name: Optional[str] = None, + project_id: Optional[str] = None, + accept_eula: Optional[bool] = None, + tags: Optional[List[str]] = None, + min_size: Optional[int] = None, + max_size: Optional[int] = None, + quantization: Optional[DeploymentQuantization] = None, + ) -> Deployment: + """ + Create a deployment. + Create a new inference deployment related to a specific model. + :param model_id: ID of the model to use. + :param node_type_name: Name of the node type to use. + :param endpoints: List of endpoints to create. + :param region: Region to target. If none is passed will use default region from the config. + :param name: Name of the deployment. + :param project_id: ID of the Project to create the deployment in. + :param accept_eula: If the model has an EULA, you must accept it before proceeding. + The terms of the EULA can be retrieved using the `GetModelEula` API call. + :param tags: List of tags to apply to the deployment. + :param min_size: Defines the minimum size of the pool. + :param max_size: Defines the maximum size of the pool. + :param quantization: Quantization settings to apply to this deployment. + :return: :class:`Deployment ` + + Usage: + :: + + result = api.create_deployment( + model_id="example", + node_type_name="example", + endpoints=[], + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "POST", + f"/inference/v1/regions/{param_region}/deployments", + body=marshal_CreateDeploymentRequest( + CreateDeploymentRequest( + model_id=model_id, + node_type_name=node_type_name, + endpoints=endpoints, + region=region, + name=name or random_name(prefix="inference"), + project_id=project_id, + accept_eula=accept_eula, + tags=tags, + min_size=min_size, + max_size=max_size, + quantization=quantization, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Deployment(res.json()) + + def update_deployment( + self, + *, + deployment_id: str, + region: Optional[ScwRegion] = None, + name: Optional[str] = None, + tags: Optional[List[str]] = None, + min_size: Optional[int] = None, + max_size: Optional[int] = None, + ) -> Deployment: + """ + Update a deployment. + Update an existing inference deployment. + :param deployment_id: ID of the deployment to update. + :param region: Region to target. If none is passed will use default region from the config. + :param name: Name of the deployment. + :param tags: List of tags to apply to the deployment. + :param min_size: Defines the new minimum size of the pool. + :param max_size: Defines the new maximum size of the pool. + :return: :class:`Deployment ` + + Usage: + :: + + result = api.update_deployment( + deployment_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_deployment_id = validate_path_param("deployment_id", deployment_id) + + res = self._request( + "PATCH", + f"/inference/v1/regions/{param_region}/deployments/{param_deployment_id}", + body=marshal_UpdateDeploymentRequest( + UpdateDeploymentRequest( + deployment_id=deployment_id, + region=region, + name=name, + tags=tags, + min_size=min_size, + max_size=max_size, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Deployment(res.json()) + + def delete_deployment( + self, + *, + deployment_id: str, + region: Optional[ScwRegion] = None, + ) -> Deployment: + """ + Delete a deployment. + Delete an existing inference deployment. + :param deployment_id: ID of the deployment to delete. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Deployment ` + + Usage: + :: + + result = api.delete_deployment( + deployment_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_deployment_id = validate_path_param("deployment_id", deployment_id) + + res = self._request( + "DELETE", + f"/inference/v1/regions/{param_region}/deployments/{param_deployment_id}", + ) + + self._throw_on_error(res) + return unmarshal_Deployment(res.json()) + + def get_deployment_certificate( + self, + *, + deployment_id: str, + region: Optional[ScwRegion] = None, + ) -> ScwFile: + """ + Get the CA certificate. + Get the CA certificate used for the deployment of private endpoints. + The CA certificate will be returned as a PEM file. + :param deployment_id: + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`ScwFile ` + + Usage: + :: + + result = api.get_deployment_certificate( + deployment_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_deployment_id = validate_path_param("deployment_id", deployment_id) + + res = self._request( + "GET", + f"/inference/v1/regions/{param_region}/deployments/{param_deployment_id}/certificate", + ) + + self._throw_on_error(res) + return unmarshal_ScwFile(res.json()) + + def create_endpoint( + self, + *, + deployment_id: str, + endpoint: EndpointSpec, + region: Optional[ScwRegion] = None, + ) -> Endpoint: + """ + Create an endpoint. + Create a new Endpoint related to a specific deployment. + :param deployment_id: ID of the deployment to create the endpoint for. + :param endpoint: Specification of the endpoint. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Endpoint ` + + Usage: + :: + + result = api.create_endpoint( + deployment_id="example", + endpoint=EndpointSpec(), + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "POST", + f"/inference/v1/regions/{param_region}/endpoints", + body=marshal_CreateEndpointRequest( + CreateEndpointRequest( + deployment_id=deployment_id, + endpoint=endpoint, + region=region, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Endpoint(res.json()) + + def update_endpoint( + self, + *, + endpoint_id: str, + region: Optional[ScwRegion] = None, + disable_auth: Optional[bool] = None, + ) -> Endpoint: + """ + Update an endpoint. + Update an existing Endpoint. + :param endpoint_id: ID of the endpoint to update. + :param region: Region to target. If none is passed will use default region from the config. + :param disable_auth: By default, deployments are protected by IAM authentication. + When setting this field to true, the authentication will be disabled. + :return: :class:`Endpoint ` + + Usage: + :: + + result = api.update_endpoint( + endpoint_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_endpoint_id = validate_path_param("endpoint_id", endpoint_id) + + res = self._request( + "PATCH", + f"/inference/v1/regions/{param_region}/endpoints/{param_endpoint_id}", + body=marshal_UpdateEndpointRequest( + UpdateEndpointRequest( + endpoint_id=endpoint_id, + region=region, + disable_auth=disable_auth, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Endpoint(res.json()) + + def delete_endpoint( + self, + *, + endpoint_id: str, + region: Optional[ScwRegion] = None, + ) -> None: + """ + Delete an endpoint. + Delete an existing Endpoint. + :param endpoint_id: ID of the endpoint to delete. + :param region: Region to target. If none is passed will use default region from the config. + + Usage: + :: + + result = api.delete_endpoint( + endpoint_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_endpoint_id = validate_path_param("endpoint_id", endpoint_id) + + res = self._request( + "DELETE", + f"/inference/v1/regions/{param_region}/endpoints/{param_endpoint_id}", + ) + + self._throw_on_error(res) + + def list_models( + self, + *, + region: Optional[ScwRegion] = None, + order_by: Optional[ListModelsRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + project_id: Optional[str] = None, + name: Optional[str] = None, + tags: Optional[List[str]] = None, + ) -> ListModelsResponse: + """ + List models. + List all available models. + :param region: Region to target. If none is passed will use default region from the config. + :param order_by: Order in which to return results. + :param page: Page number to return. + :param page_size: Maximum number of models to return per page. + :param project_id: Filter by Project ID. + :param name: Filter by model name. + :param tags: Filter by tags. + :return: :class:`ListModelsResponse ` + + Usage: + :: + + result = api.list_models() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/inference/v1/regions/{param_region}/models", + params={ + "name": name, + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + "project_id": project_id or self.client.default_project_id, + "tags": tags, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListModelsResponse(res.json()) + + def list_models_all( + self, + *, + region: Optional[ScwRegion] = None, + order_by: Optional[ListModelsRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + project_id: Optional[str] = None, + name: Optional[str] = None, + tags: Optional[List[str]] = None, + ) -> List[Model]: + """ + List models. + List all available models. + :param region: Region to target. If none is passed will use default region from the config. + :param order_by: Order in which to return results. + :param page: Page number to return. + :param page_size: Maximum number of models to return per page. + :param project_id: Filter by Project ID. + :param name: Filter by model name. + :param tags: Filter by tags. + :return: :class:`List[Model] ` + + Usage: + :: + + result = api.list_models_all() + """ + + return fetch_all_pages( + type=ListModelsResponse, + key="models", + fetcher=self.list_models, + args={ + "region": region, + "order_by": order_by, + "page": page, + "page_size": page_size, + "project_id": project_id, + "name": name, + "tags": tags, + }, + ) + + def get_model( + self, + *, + model_id: str, + region: Optional[ScwRegion] = None, + ) -> Model: + """ + Get a model. + Get the model for the given ID. + :param model_id: ID of the model to get. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Model ` + + Usage: + :: + + result = api.get_model( + model_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_model_id = validate_path_param("model_id", model_id) + + res = self._request( + "GET", + f"/inference/v1/regions/{param_region}/models/{param_model_id}", + ) + + self._throw_on_error(res) + return unmarshal_Model(res.json()) + + def wait_for_model( + self, + *, + model_id: str, + region: Optional[ScwRegion] = None, + options: Optional[WaitForOptions[Model, bool]] = None, + ) -> Model: + """ + Get a model. + Get the model for the given ID. + :param model_id: ID of the model to get. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Model ` + + Usage: + :: + + result = api.get_model( + model_id="example", + ) + """ + + if not options: + options = WaitForOptions() + + if not options.stop: + options.stop = lambda res: res.status not in MODEL_TRANSIENT_STATUSES + + return wait_for_resource( + fetcher=self.get_model, + options=options, + args={ + "model_id": model_id, + "region": region, + }, + ) + + def create_model( + self, + *, + source: ModelSource, + region: Optional[ScwRegion] = None, + name: Optional[str] = None, + project_id: Optional[str] = None, + ) -> Model: + """ + Import a model. + Import a new model to your model library. + :param source: Where to import the model from. + :param region: Region to target. If none is passed will use default region from the config. + :param name: Name of the model. + :param project_id: ID of the Project to import the model in. + :return: :class:`Model ` + + Usage: + :: + + result = api.create_model( + source=ModelSource(), + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "POST", + f"/inference/v1/regions/{param_region}/models", + body=marshal_CreateModelRequest( + CreateModelRequest( + source=source, + region=region, + name=name or random_name(prefix="model"), + project_id=project_id, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Model(res.json()) + + def delete_model( + self, + *, + model_id: str, + region: Optional[ScwRegion] = None, + ) -> None: + """ + Delete a model. + Delete an existing model from your model library. + :param model_id: ID of the model to delete. + :param region: Region to target. If none is passed will use default region from the config. + + Usage: + :: + + result = api.delete_model( + model_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_model_id = validate_path_param("model_id", model_id) + + res = self._request( + "DELETE", + f"/inference/v1/regions/{param_region}/models/{param_model_id}", + ) + + self._throw_on_error(res) + + def list_node_types( + self, + *, + include_disabled_types: bool, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> ListNodeTypesResponse: + """ + List available node types. + List all available node types. By default, the node types returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. + :param include_disabled_types: Include disabled node types in the response. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number to return. + :param page_size: Maximum number of node types to return per page. + :return: :class:`ListNodeTypesResponse ` + + Usage: + :: + + result = api.list_node_types( + include_disabled_types=False, + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/inference/v1/regions/{param_region}/node-types", + params={ + "include_disabled_types": include_disabled_types, + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListNodeTypesResponse(res.json()) + + def list_node_types_all( + self, + *, + include_disabled_types: bool, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[NodeType]: + """ + List available node types. + List all available node types. By default, the node types returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. + :param include_disabled_types: Include disabled node types in the response. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number to return. + :param page_size: Maximum number of node types to return per page. + :return: :class:`List[NodeType] ` + + Usage: + :: + + result = api.list_node_types_all( + include_disabled_types=False, + ) + """ + + return fetch_all_pages( + type=ListNodeTypesResponse, + key="node_types", + fetcher=self.list_node_types, + args={ + "include_disabled_types": include_disabled_types, + "region": region, + "page": page, + "page_size": page_size, + }, + ) diff --git a/scaleway/scaleway/inference/v1/content.py b/scaleway/scaleway/inference/v1/content.py new file mode 100644 index 000000000..887e0b7ec --- /dev/null +++ b/scaleway/scaleway/inference/v1/content.py @@ -0,0 +1,24 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from typing import List + +from .types import ( + DeploymentStatus, + ModelStatus, +) + +DEPLOYMENT_TRANSIENT_STATUSES: List[DeploymentStatus] = [ + DeploymentStatus.CREATING, + DeploymentStatus.DEPLOYING, + DeploymentStatus.DELETING, +] +""" +Lists transient statutes of the enum :class:`DeploymentStatus `. +""" +MODEL_TRANSIENT_STATUSES: List[ModelStatus] = [ + ModelStatus.PREPARING, + ModelStatus.DOWNLOADING, +] +""" +Lists transient statutes of the enum :class:`ModelStatus `. +""" diff --git a/scaleway/scaleway/inference/v1/marshalling.py b/scaleway/scaleway/inference/v1/marshalling.py new file mode 100644 index 000000000..9f10b88e1 --- /dev/null +++ b/scaleway/scaleway/inference/v1/marshalling.py @@ -0,0 +1,654 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. + +from typing import Any, Dict +from dateutil import parser + +from scaleway_core.profile import ProfileDefaults +from scaleway_core.utils import ( + OneOfPossibility, + resolve_one_of, +) +from .types import ( + EndpointPrivateNetworkDetails, + EndpointPublicNetworkDetails, + Endpoint, + ModelSupportedQuantization, + ModelSupportedNode, + ModelSupportInfo, + DeploymentQuantization, + Deployment, + Model, + ListDeploymentsResponse, + ListModelsResponse, + NodeType, + ListNodeTypesResponse, + EndpointSpec, + CreateDeploymentRequest, + CreateEndpointRequest, + ModelSource, + CreateModelRequest, + UpdateDeploymentRequest, + UpdateEndpointRequest, +) + + +def unmarshal_EndpointPrivateNetworkDetails(data: Any) -> EndpointPrivateNetworkDetails: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'EndpointPrivateNetworkDetails' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("private_network_id", None) + if field is not None: + args["private_network_id"] = field + + return EndpointPrivateNetworkDetails(**args) + + +def unmarshal_EndpointPublicNetworkDetails(data: Any) -> EndpointPublicNetworkDetails: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'EndpointPublicNetworkDetails' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + return EndpointPublicNetworkDetails(**args) + + +def unmarshal_Endpoint(data: Any) -> Endpoint: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Endpoint' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("url", None) + if field is not None: + args["url"] = field + + field = data.get("disable_auth", None) + if field is not None: + args["disable_auth"] = field + + field = data.get("public_network", None) + if field is not None: + args["public_network"] = unmarshal_EndpointPublicNetworkDetails(field) + else: + args["public_network"] = None + + field = data.get("private_network", None) + if field is not None: + args["private_network"] = unmarshal_EndpointPrivateNetworkDetails(field) + else: + args["private_network"] = None + + return Endpoint(**args) + + +def unmarshal_ModelSupportedQuantization(data: Any) -> ModelSupportedQuantization: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ModelSupportedQuantization' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("quantization_bits", None) + if field is not None: + args["quantization_bits"] = field + + field = data.get("allowed", None) + if field is not None: + args["allowed"] = field + + field = data.get("max_context_size", None) + if field is not None: + args["max_context_size"] = field + + return ModelSupportedQuantization(**args) + + +def unmarshal_ModelSupportedNode(data: Any) -> ModelSupportedNode: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ModelSupportedNode' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("node_type_name", None) + if field is not None: + args["node_type_name"] = field + + field = data.get("quantizations", None) + if field is not None: + args["quantizations"] = ( + [unmarshal_ModelSupportedQuantization(v) for v in field] + if field is not None + else None + ) + + return ModelSupportedNode(**args) + + +def unmarshal_ModelSupportInfo(data: Any) -> ModelSupportInfo: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ModelSupportInfo' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("nodes", None) + if field is not None: + args["nodes"] = ( + [unmarshal_ModelSupportedNode(v) for v in field] + if field is not None + else None + ) + + return ModelSupportInfo(**args) + + +def unmarshal_DeploymentQuantization(data: Any) -> DeploymentQuantization: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'DeploymentQuantization' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("enabled", None) + if field is not None: + args["enabled"] = field + + field = data.get("bits", None) + if field is not None: + args["bits"] = field + + return DeploymentQuantization(**args) + + +def unmarshal_Deployment(data: Any) -> Deployment: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Deployment' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("name", None) + if field is not None: + args["name"] = field + + field = data.get("project_id", None) + if field is not None: + args["project_id"] = field + + field = data.get("status", None) + if field is not None: + args["status"] = field + + field = data.get("tags", None) + if field is not None: + args["tags"] = field + + field = data.get("node_type_name", None) + if field is not None: + args["node_type_name"] = field + + field = data.get("endpoints", None) + if field is not None: + args["endpoints"] = ( + [unmarshal_Endpoint(v) for v in field] if field is not None else None + ) + + field = data.get("size", None) + if field is not None: + args["size"] = field + + field = data.get("min_size", None) + if field is not None: + args["min_size"] = field + + field = data.get("max_size", None) + if field is not None: + args["max_size"] = field + + field = data.get("model_id", None) + if field is not None: + args["model_id"] = field + + field = data.get("model_name", None) + if field is not None: + args["model_name"] = field + + field = data.get("region", None) + if field is not None: + args["region"] = field + + field = data.get("error_message", None) + if field is not None: + args["error_message"] = field + else: + args["error_message"] = None + + field = data.get("quantization", None) + if field is not None: + args["quantization"] = unmarshal_DeploymentQuantization(field) + else: + args["quantization"] = None + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + return Deployment(**args) + + +def unmarshal_Model(data: Any) -> Model: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Model' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("name", None) + if field is not None: + args["name"] = field + + field = data.get("project_id", None) + if field is not None: + args["project_id"] = field + + field = data.get("tags", None) + if field is not None: + args["tags"] = field + + field = data.get("status", None) + if field is not None: + args["status"] = field + + field = data.get("description", None) + if field is not None: + args["description"] = field + + field = data.get("has_eula", None) + if field is not None: + args["has_eula"] = field + + field = data.get("region", None) + if field is not None: + args["region"] = field + + field = data.get("nodes_support", None) + if field is not None: + args["nodes_support"] = ( + [unmarshal_ModelSupportInfo(v) for v in field] + if field is not None + else None + ) + + field = data.get("parameter_size_bits", None) + if field is not None: + args["parameter_size_bits"] = field + + field = data.get("size_bytes", None) + if field is not None: + args["size_bytes"] = field + + field = data.get("error_message", None) + if field is not None: + args["error_message"] = field + else: + args["error_message"] = None + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + return Model(**args) + + +def unmarshal_ListDeploymentsResponse(data: Any) -> ListDeploymentsResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListDeploymentsResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("deployments", None) + if field is not None: + args["deployments"] = ( + [unmarshal_Deployment(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListDeploymentsResponse(**args) + + +def unmarshal_ListModelsResponse(data: Any) -> ListModelsResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListModelsResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("models", None) + if field is not None: + args["models"] = ( + [unmarshal_Model(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListModelsResponse(**args) + + +def unmarshal_NodeType(data: Any) -> NodeType: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'NodeType' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("name", None) + if field is not None: + args["name"] = field + + field = data.get("stock_status", None) + if field is not None: + args["stock_status"] = field + + field = data.get("description", None) + if field is not None: + args["description"] = field + + field = data.get("vcpus", None) + if field is not None: + args["vcpus"] = field + + field = data.get("memory", None) + if field is not None: + args["memory"] = field + + field = data.get("vram", None) + if field is not None: + args["vram"] = field + + field = data.get("disabled", None) + if field is not None: + args["disabled"] = field + + field = data.get("beta", None) + if field is not None: + args["beta"] = field + + field = data.get("gpus", None) + if field is not None: + args["gpus"] = field + + field = data.get("region", None) + if field is not None: + args["region"] = field + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + return NodeType(**args) + + +def unmarshal_ListNodeTypesResponse(data: Any) -> ListNodeTypesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListNodeTypesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("node_types", None) + if field is not None: + args["node_types"] = ( + [unmarshal_NodeType(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListNodeTypesResponse(**args) + + +def marshal_EndpointPrivateNetworkDetails( + request: EndpointPrivateNetworkDetails, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.private_network_id is not None: + output["private_network_id"] = request.private_network_id + + return output + + +def marshal_EndpointPublicNetworkDetails( + request: EndpointPublicNetworkDetails, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + return output + + +def marshal_DeploymentQuantization( + request: DeploymentQuantization, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.enabled is not None: + output["enabled"] = request.enabled + + if request.bits is not None: + output["bits"] = request.bits + + return output + + +def marshal_EndpointSpec( + request: EndpointSpec, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("public_network", request.public_network), + OneOfPossibility("private_network", request.private_network), + ] + ), + ) + + if request.disable_auth is not None: + output["disable_auth"] = request.disable_auth + + return output + + +def marshal_CreateDeploymentRequest( + request: CreateDeploymentRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.model_id is not None: + output["model_id"] = request.model_id + + if request.node_type_name is not None: + output["node_type_name"] = request.node_type_name + + if request.endpoints is not None: + output["endpoints"] = [ + marshal_EndpointSpec(item, defaults) for item in request.endpoints + ] + + if request.name is not None: + output["name"] = request.name + + if request.project_id is not None: + output["project_id"] = request.project_id or defaults.default_project_id + + if request.accept_eula is not None: + output["accept_eula"] = request.accept_eula + + if request.tags is not None: + output["tags"] = request.tags + + if request.min_size is not None: + output["min_size"] = request.min_size + + if request.max_size is not None: + output["max_size"] = request.max_size + + if request.quantization is not None: + output["quantization"] = marshal_DeploymentQuantization( + request.quantization, defaults + ) + + return output + + +def marshal_CreateEndpointRequest( + request: CreateEndpointRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.deployment_id is not None: + output["deployment_id"] = request.deployment_id + + if request.endpoint is not None: + output["endpoint"] = marshal_EndpointSpec(request.endpoint, defaults) + + return output + + +def marshal_ModelSource( + request: ModelSource, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("secret", request.secret), + ] + ), + ) + + if request.url is not None: + output["url"] = request.url + + return output + + +def marshal_CreateModelRequest( + request: CreateModelRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.source is not None: + output["source"] = marshal_ModelSource(request.source, defaults) + + if request.name is not None: + output["name"] = request.name + + if request.project_id is not None: + output["project_id"] = request.project_id or defaults.default_project_id + + return output + + +def marshal_UpdateDeploymentRequest( + request: UpdateDeploymentRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.name is not None: + output["name"] = request.name + + if request.tags is not None: + output["tags"] = request.tags + + if request.min_size is not None: + output["min_size"] = request.min_size + + if request.max_size is not None: + output["max_size"] = request.max_size + + return output + + +def marshal_UpdateEndpointRequest( + request: UpdateEndpointRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.disable_auth is not None: + output["disable_auth"] = request.disable_auth + + return output diff --git a/scaleway/scaleway/inference/v1/types.py b/scaleway/scaleway/inference/v1/types.py new file mode 100644 index 000000000..9dd6fce4b --- /dev/null +++ b/scaleway/scaleway/inference/v1/types.py @@ -0,0 +1,770 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from __future__ import annotations + +from dataclasses import dataclass +from datetime import datetime +from enum import Enum +from typing import List, Optional + +from scaleway_core.bridge import ( + Region as ScwRegion, +) +from scaleway_core.utils import ( + StrEnumMeta, +) + + +class DeploymentStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + CREATING = "creating" + DEPLOYING = "deploying" + READY = "ready" + ERROR = "error" + DELETING = "deleting" + LOCKED = "locked" + + def __str__(self) -> str: + return str(self.value) + + +class ListDeploymentsRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_DESC = "created_at_desc" + CREATED_AT_ASC = "created_at_asc" + NAME_ASC = "name_asc" + NAME_DESC = "name_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ListModelsRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + DISPLAY_RANK_ASC = "display_rank_asc" + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + NAME_ASC = "name_asc" + NAME_DESC = "name_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ModelStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + PREPARING = "preparing" + DOWNLOADING = "downloading" + READY = "ready" + ERROR = "error" + + def __str__(self) -> str: + return str(self.value) + + +class NodeTypeStock(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STOCK = "unknown_stock" + LOW_STOCK = "low_stock" + OUT_OF_STOCK = "out_of_stock" + AVAILABLE = "available" + + def __str__(self) -> str: + return str(self.value) + + +@dataclass +class ModelSupportedQuantization: + quantization_bits: int + """ + Number of bits for this supported quantization. + """ + + allowed: bool + """ + Tells whether this quantization is allowed for this node type. + """ + + max_context_size: int + """ + Maximum inference context size available for this node type and quantization. + """ + + +@dataclass +class EndpointPrivateNetworkDetails: + private_network_id: str + + +@dataclass +class EndpointPublicNetworkDetails: + pass + + +@dataclass +class ModelSupportedNode: + node_type_name: str + """ + Supported node type. + """ + + quantizations: List[ModelSupportedQuantization] + """ + Supported quantizations. + """ + + +@dataclass +class DeploymentQuantization: + enabled: bool + """ + Whether to enable quantization for this deployment. + """ + + bits: int + """ + The number of bits each model parameter should be quantized to. The quantization method is chosen based on this value. + """ + + +@dataclass +class Endpoint: + id: str + """ + Unique identifier. + """ + + url: str + """ + For private endpoints, the URL will be accessible only from the Private Network. +In addition, private endpoints will expose a CA certificate that can be used to verify the server's identity. +This CA certificate can be retrieved using the `GetDeploymentCertificate` API call. + """ + + disable_auth: bool + """ + Defines whether the authentication is disabled. + """ + + public_network: Optional[EndpointPublicNetworkDetails] + + private_network: Optional[EndpointPrivateNetworkDetails] + + +@dataclass +class ModelSupportInfo: + nodes: List[ModelSupportedNode] + """ + List of supported node types. + """ + + +@dataclass +class EndpointSpec: + disable_auth: bool + """ + By default, deployments are protected by IAM authentication. +When setting this field to true, the authentication will be disabled. + """ + + public_network: Optional[EndpointPublicNetworkDetails] + + private_network: Optional[EndpointPrivateNetworkDetails] + + +@dataclass +class ModelSource: + url: str + + secret: Optional[str] + + +@dataclass +class Deployment: + id: str + """ + Unique identifier. + """ + + name: str + """ + Name of the deployment. + """ + + project_id: str + """ + Project ID. + """ + + status: DeploymentStatus + """ + Status of the deployment. + """ + + tags: List[str] + """ + List of tags applied to the deployment. + """ + + node_type_name: str + """ + Node type of the deployment. + """ + + endpoints: List[Endpoint] + """ + List of endpoints. + """ + + size: int + """ + Current size of the pool. + """ + + min_size: int + """ + Defines the minimum size of the pool. + """ + + max_size: int + """ + Defines the maximum size of the pool. + """ + + model_id: str + """ + ID of the model used for the deployment. + """ + + model_name: str + """ + Name of the deployed model. + """ + + region: ScwRegion + """ + Region of the deployment. + """ + + error_message: Optional[str] + """ + Displays information if your deployment is in error state. + """ + + quantization: Optional[DeploymentQuantization] + """ + Quantization parameters for this deployment. + """ + + created_at: Optional[datetime] + """ + Creation date of the deployment. + """ + + updated_at: Optional[datetime] + """ + Last modification date of the deployment. + """ + + +@dataclass +class Model: + id: str + """ + Unique identifier. + """ + + name: str + """ + Unique Name identifier. + """ + + project_id: str + """ + Project ID. + """ + + tags: List[str] + """ + List of tags applied to the model. + """ + + status: ModelStatus + """ + Status of the model. + """ + + description: str + """ + Purpose of the model. + """ + + has_eula: bool + """ + Defines whether the model has an end user license agreement. + """ + + region: ScwRegion + """ + Region of the model. + """ + + nodes_support: List[ModelSupportInfo] + """ + Supported nodes types with quantization options and context lengths. + """ + + parameter_size_bits: int + """ + Size, in bits, of the model parameters. + """ + + size_bytes: int + """ + Total size, in bytes, of the model files. + """ + + error_message: Optional[str] + """ + Displays information if your model is in error state. + """ + + created_at: Optional[datetime] + """ + Creation date of the model. + """ + + updated_at: Optional[datetime] + """ + Last modification date of the model. + """ + + +@dataclass +class NodeType: + name: str + """ + Name of the node type. + """ + + stock_status: NodeTypeStock + """ + Current stock status for the node type. + """ + + description: str + """ + Current specs of the offer. + """ + + vcpus: int + """ + Number of virtual CPUs. + """ + + memory: int + """ + Quantity of RAM. + """ + + vram: int + """ + Quantity of GPU RAM. + """ + + disabled: bool + """ + The node type is currently disabled. + """ + + beta: bool + """ + The node type is currently in beta. + """ + + gpus: int + """ + Number of GPUs. + """ + + region: ScwRegion + """ + Region of the node type. + """ + + created_at: Optional[datetime] + """ + Creation date of the node type. + """ + + updated_at: Optional[datetime] + """ + Last modification date of the node type. + """ + + +@dataclass +class CreateDeploymentRequest: + model_id: str + """ + ID of the model to use. + """ + + node_type_name: str + """ + Name of the node type to use. + """ + + endpoints: List[EndpointSpec] + """ + List of endpoints to create. + """ + + region: Optional[ScwRegion] + """ + Region to target. If none is passed will use default region from the config. + """ + + name: Optional[str] + """ + Name of the deployment. + """ + + project_id: Optional[str] + """ + ID of the Project to create the deployment in. + """ + + accept_eula: Optional[bool] + """ + If the model has an EULA, you must accept it before proceeding. +The terms of the EULA can be retrieved using the `GetModelEula` API call. + """ + + tags: Optional[List[str]] + """ + List of tags to apply to the deployment. + """ + + min_size: Optional[int] + """ + Defines the minimum size of the pool. + """ + + max_size: Optional[int] + """ + Defines the maximum size of the pool. + """ + + quantization: Optional[DeploymentQuantization] + """ + Quantization settings to apply to this deployment. + """ + + +@dataclass +class CreateEndpointRequest: + deployment_id: str + """ + ID of the deployment to create the endpoint for. + """ + + endpoint: EndpointSpec + """ + Specification of the endpoint. + """ + + region: Optional[ScwRegion] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class CreateModelRequest: + source: ModelSource + """ + Where to import the model from. + """ + + region: Optional[ScwRegion] + """ + Region to target. If none is passed will use default region from the config. + """ + + name: Optional[str] + """ + Name of the model. + """ + + project_id: Optional[str] + """ + ID of the Project to import the model in. + """ + + +@dataclass +class DeleteDeploymentRequest: + deployment_id: str + """ + ID of the deployment to delete. + """ + + region: Optional[ScwRegion] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DeleteEndpointRequest: + endpoint_id: str + """ + ID of the endpoint to delete. + """ + + region: Optional[ScwRegion] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DeleteModelRequest: + model_id: str + """ + ID of the model to delete. + """ + + region: Optional[ScwRegion] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class GetDeploymentCertificateRequest: + deployment_id: str + + region: Optional[ScwRegion] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class GetDeploymentRequest: + deployment_id: str + """ + ID of the deployment to get. + """ + + region: Optional[ScwRegion] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class GetModelRequest: + model_id: str + """ + ID of the model to get. + """ + + region: Optional[ScwRegion] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class ListDeploymentsRequest: + region: Optional[ScwRegion] + """ + Region to target. If none is passed will use default region from the config. + """ + + page: Optional[int] + """ + Page number to return. + """ + + page_size: Optional[int] + """ + Maximum number of deployments to return per page. + """ + + order_by: Optional[ListDeploymentsRequestOrderBy] + """ + Order in which to return results. + """ + + project_id: Optional[str] + """ + Filter by Project ID. + """ + + organization_id: Optional[str] + """ + Filter by Organization ID. + """ + + name: Optional[str] + """ + Filter by deployment name. + """ + + tags: Optional[List[str]] + """ + Filter by tags. + """ + + +@dataclass +class ListDeploymentsResponse: + deployments: List[Deployment] + """ + List of deployments on the current page. + """ + + total_count: int + """ + Total number of deployments. + """ + + +@dataclass +class ListModelsRequest: + region: Optional[ScwRegion] + """ + Region to target. If none is passed will use default region from the config. + """ + + order_by: Optional[ListModelsRequestOrderBy] + """ + Order in which to return results. + """ + + page: Optional[int] + """ + Page number to return. + """ + + page_size: Optional[int] + """ + Maximum number of models to return per page. + """ + + project_id: Optional[str] + """ + Filter by Project ID. + """ + + name: Optional[str] + """ + Filter by model name. + """ + + tags: Optional[List[str]] + """ + Filter by tags. + """ + + +@dataclass +class ListModelsResponse: + models: List[Model] + """ + List of models on the current page. + """ + + total_count: int + """ + Total number of models. + """ + + +@dataclass +class ListNodeTypesRequest: + include_disabled_types: bool + """ + Include disabled node types in the response. + """ + + region: Optional[ScwRegion] + """ + Region to target. If none is passed will use default region from the config. + """ + + page: Optional[int] + """ + Page number to return. + """ + + page_size: Optional[int] + """ + Maximum number of node types to return per page. + """ + + +@dataclass +class ListNodeTypesResponse: + node_types: List[NodeType] + """ + List of node types. + """ + + total_count: int + """ + Total number of node types. + """ + + +@dataclass +class UpdateDeploymentRequest: + deployment_id: str + """ + ID of the deployment to update. + """ + + region: Optional[ScwRegion] + """ + Region to target. If none is passed will use default region from the config. + """ + + name: Optional[str] + """ + Name of the deployment. + """ + + tags: Optional[List[str]] + """ + List of tags to apply to the deployment. + """ + + min_size: Optional[int] + """ + Defines the new minimum size of the pool. + """ + + max_size: Optional[int] + """ + Defines the new maximum size of the pool. + """ + + +@dataclass +class UpdateEndpointRequest: + endpoint_id: str + """ + ID of the endpoint to update. + """ + + region: Optional[ScwRegion] + """ + Region to target. If none is passed will use default region from the config. + """ + + disable_auth: Optional[bool] + """ + By default, deployments are protected by IAM authentication. +When setting this field to true, the authentication will be disabled. + """