diff --git a/backend/src/jobs_server/models.py b/backend/src/jobs_server/models.py index df4147fe..cb891dc7 100644 --- a/backend/src/jobs_server/models.py +++ b/backend/src/jobs_server/models.py @@ -1,9 +1,9 @@ +import json import re from enum import StrEnum -from typing import Annotated, Any, TypeAlias +from typing import Annotated, Any, Self, TypeAlias from jobs import JobOptions -from jobs.types import ExecutionMode from pydantic import UUID4, AfterValidator, BaseModel, Field, StrictStr @@ -32,6 +32,26 @@ def validate_image_ref(ref: str) -> str: SubmissionContext: TypeAlias = dict[str, Any] +class ExecutionMode(StrEnum): + """ + ExecutionMode + """ + + """ + allowed enum values + """ + LOCAL = "local" + DOCKER = "docker" + KUEUE = "kueue" + RAYCLUSTER = "raycluster" + RAYJOB = "rayjob" + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of ExecutionMode from a JSON string""" + return cls(json.loads(json_str)) + + class CreateJobModel(BaseModel): name: str file: str diff --git a/backend/src/jobs_server/runner/base.py b/backend/src/jobs_server/runner/base.py index 388de86a..e43afaf2 100644 --- a/backend/src/jobs_server/runner/base.py +++ b/backend/src/jobs_server/runner/base.py @@ -2,9 +2,8 @@ from typing import ClassVar, Self from jobs import Image, Job -from jobs.types import ExecutionMode -from jobs_server.models import SubmissionContext, WorkloadIdentifier +from jobs_server.models import ExecutionMode, SubmissionContext, WorkloadIdentifier class Runner(abc.ABC): diff --git a/backend/src/jobs_server/runner/docker.py b/backend/src/jobs_server/runner/docker.py index bb5b0512..24ad60ab 100644 --- a/backend/src/jobs_server/runner/docker.py +++ b/backend/src/jobs_server/runner/docker.py @@ -5,8 +5,8 @@ from jobs import Image, Job from jobs.job import DockerResourceOptions -from jobs_server.models import SubmissionContext -from jobs_server.runner.base import ExecutionMode, Runner, _make_executor_command +from jobs_server.models import ExecutionMode, SubmissionContext +from jobs_server.runner.base import Runner, _make_executor_command from jobs_server.utils.helpers import remove_none_values diff --git a/backend/src/jobs_server/runner/kueue.py b/backend/src/jobs_server/runner/kueue.py index 839950bb..81b13804 100644 --- a/backend/src/jobs_server/runner/kueue.py +++ b/backend/src/jobs_server/runner/kueue.py @@ -5,8 +5,8 @@ from jobs.types import K8sResourceKind from kubernetes import client -from jobs_server.models import SubmissionContext, WorkloadIdentifier -from jobs_server.runner.base import ExecutionMode, Runner, _make_executor_command +from jobs_server.models import ExecutionMode, SubmissionContext, WorkloadIdentifier +from jobs_server.runner.base import Runner, _make_executor_command from jobs_server.utils.k8s import ( KubernetesNamespaceMixin, gvk, diff --git a/backend/src/jobs_server/runner/ray.py b/backend/src/jobs_server/runner/ray.py index 85ec9aa5..1efb95e0 100644 --- a/backend/src/jobs_server/runner/ray.py +++ b/backend/src/jobs_server/runner/ray.py @@ -18,8 +18,8 @@ from ray.dashboard.modules.job.common import JobStatus from ray.dashboard.modules.job.sdk import JobSubmissionClient -from jobs_server.models import SubmissionContext, WorkloadIdentifier -from jobs_server.runner.base import ExecutionMode, Runner, _make_executor_command +from jobs_server.models import ExecutionMode, SubmissionContext, WorkloadIdentifier +from jobs_server.runner.base import Runner, _make_executor_command from jobs_server.utils.k8s import ( KubernetesNamespaceMixin, gvk, diff --git a/backend/src/jobs_server/services/k8s.py b/backend/src/jobs_server/services/k8s.py index 7b63ef99..8f65912b 100644 --- a/backend/src/jobs_server/services/k8s.py +++ b/backend/src/jobs_server/services/k8s.py @@ -18,7 +18,6 @@ def __init__(self): except config.ConfigException: logging.warning( "Could not load in-cluster config, attempting to load Kubeconfig", - exc_info=True, ) config.load_kube_config() self._in_cluster = False diff --git a/client/hack/openapi-regen.sh b/client/hack/openapi-regen.sh new file mode 100755 index 00000000..7e46a660 --- /dev/null +++ b/client/hack/openapi-regen.sh @@ -0,0 +1,21 @@ +#!/bin/bash -eux + +REPO_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd ../.. && pwd )" +fname=openapi-$(date +%s).json +curl -o "$REPO_ROOT/$fname" http://localhost:8000/openapi.json + +docker run --rm \ + -v "$REPO_ROOT":/local \ + openapitools/openapi-generator-cli \ + generate \ + -i /local/"$fname" \ + -g python \ + -o /local/openapi-client \ + --additional-properties=generateSourceCodeOnly=true,packageName=openapi_client + +cp -af "$REPO_ROOT"/openapi-client/openapi_client "$REPO_ROOT"/client/src + +ruff format "$REPO_ROOT"/client/src/openapi_client/ +ruff check --fix --unsafe-fixes "$REPO_ROOT"/client/src/openapi_client/ +rm -rf "$REPO_ROOT"/openapi-client +rm "$REPO_ROOT/$fname" diff --git a/client/pyproject.toml b/client/pyproject.toml index 50d642d6..a8854abd 100644 --- a/client/pyproject.toml +++ b/client/pyproject.toml @@ -55,8 +55,11 @@ fallback_version = "0.0.0" extend = "../pyproject.toml" src = ["src"] -[tool.ruff.lint] -exclude = ["src/openapi_client/**"] +[tool.ruff.lint.per-file-ignores] +"src/openapi_client/**" = [ + "B904", # raise-without-from-inside-except + "E721", # type-comparison +] [tool.mypy] ignore_missing_imports = true diff --git a/client/src/jobs/cli.py b/client/src/jobs/cli.py index 2cc65c77..a6ac7b85 100644 --- a/client/src/jobs/cli.py +++ b/client/src/jobs/cli.py @@ -10,22 +10,49 @@ import openapi_client.configuration from jobs import Image, Job from jobs.submission_context import SubmissionContext -from jobs.types import ExecutionMode +from openapi_client import ExecutionMode + + +def submit(args: argparse.Namespace) -> None: + job = discover_job(args) + + submit_job(job, args) + + +def status(args: argparse.Namespace) -> None: + api_config = openapi_client.Configuration(host="http://localhost:8000") + + with openapi_client.ApiClient(api_config) as api: + client = openapi_client.JobManagementApi(api) + + resp = client.status_jobs_uid_status_get( + uid=args.uid, + namespace=args.namespace, + ) + pp(resp) def _make_argparser() -> argparse.ArgumentParser: parser = argparse.ArgumentParser( - description="Run an example job either locally, or on a container execution platform", + description="The jobby command-line interface", formatter_class=argparse.ArgumentDefaultsHelpFormatter, ) - parser.add_argument( + subparsers = parser.add_subparsers(required=True) + + # jobby submit, the job submission command + submission = subparsers.add_parser( + "submit", + description="Run an example job either locally, or on a container execution platform", + ) + + submission.add_argument( "--image-name", help="Image name to use when building a container image", default="example:latest", ) - parser.add_argument( + submission.add_argument( "--mode", help="Job execution mode", default="local", @@ -33,24 +60,39 @@ def _make_argparser() -> argparse.ArgumentParser: type=ExecutionMode, ) - parser.add_argument( + submission.add_argument( "--kueue-local-queue", help="Name of the Kueue LocalQueue to submit the workload to", default="user-queue", ) - parser.add_argument( + submission.add_argument( "--ray-head-url", help="URL of the Ray cluster head node", default="http://localhost:8265", ) - parser.add_argument( + submission.add_argument( "--namespace", help="Kubernetes namespace to create resources in, defaults to currently active namespace", ) - parser.add_argument("entrypoint") + submission.add_argument("entrypoint") + submission.set_defaults(func=submit) + + # jobby status, the status querying command + status_query = subparsers.add_parser( + "status", description="Query the status of a previously dispatched job" + ) + + # unique identifier of the job + status_query.add_argument("uid", metavar="") + + status_query.add_argument( + "--namespace", + help="Kubernetes namespace the job was created in, defaults to currently active namespace", + ) + status_query.set_defaults(func=status) return parser @@ -74,7 +116,7 @@ def _build_image(job: Job) -> Image: host="http://localhost:8000", ) with openapi_client.ApiClient(api_config) as api: - client = openapi_client.DefaultApi(api) + client = openapi_client.JobManagementApi(api) # Job options sent to server do not need image options opts = openapi_client.CreateJobModel( @@ -82,7 +124,11 @@ def _build_image(job: Job) -> Image: file=job.file, image_ref=_build_image(job).tag, mode=mode, - options=job.options, + options=openapi_client.JobOptions.model_validate( + job.options.model_dump() + ) + if job.options + else None, submission_context=SubmissionContext().to_dict(), ) resp = client.submit_job_jobs_post(opts) @@ -132,6 +178,4 @@ def main(): logging.getLogger("urllib3.connectionpool").setLevel(logging.INFO) args = _make_argparser().parse_args() - job = discover_job(args) - - submit_job(job, args) + args.func(args) diff --git a/client/src/jobs/types.py b/client/src/jobs/types.py index 0cea8712..317bea48 100644 --- a/client/src/jobs/types.py +++ b/client/src/jobs/types.py @@ -1,4 +1,3 @@ -import json import os from enum import Enum from pathlib import Path @@ -15,26 +14,6 @@ class K8sResourceKind(Enum): LIMITS = "limits" -class ExecutionMode(str, Enum): - """ - ExecutionMode - """ - - """ - allowed enum values - """ - LOCAL = "local" - DOCKER = "docker" - KUEUE = "kueue" - RAYCLUSTER = "raycluster" - RAYJOB = "rayjob" - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of ExecutionMode from a JSON string""" - return cls(json.loads(json_str)) - - class NoOptions(TypedDict, total=True): pass diff --git a/client/src/openapi_client/__init__.py b/client/src/openapi_client/__init__.py index f7f21ea4..21f9cda2 100644 --- a/client/src/openapi_client/__init__.py +++ b/client/src/openapi_client/__init__.py @@ -16,7 +16,7 @@ __version__ = "1.0.0" # import apis into sdk package -from openapi_client.api.default_api import DefaultApi +from openapi_client.api.job_management_api import JobManagementApi # import ApiClient from openapi_client.api_response import ApiResponse @@ -31,6 +31,11 @@ # import models into sdk package from openapi_client.models.create_job_model import CreateJobModel +from openapi_client.models.execution_mode import ExecutionMode from openapi_client.models.http_validation_error import HTTPValidationError +from openapi_client.models.job_options import JobOptions +from openapi_client.models.resource_options import ResourceOptions +from openapi_client.models.scheduling_options import SchedulingOptions from openapi_client.models.validation_error import ValidationError from openapi_client.models.validation_error_loc_inner import ValidationErrorLocInner +from openapi_client.models.workload_identifier import WorkloadIdentifier diff --git a/client/src/openapi_client/api/__init__.py b/client/src/openapi_client/api/__init__.py index 1d1c51ff..73d05f48 100644 --- a/client/src/openapi_client/api/__init__.py +++ b/client/src/openapi_client/api/__init__.py @@ -1,4 +1,4 @@ # flake8: noqa # import apis into api package -from openapi_client.api.default_api import DefaultApi +from openapi_client.api.job_management_api import JobManagementApi diff --git a/client/src/openapi_client/api/default_api.py b/client/src/openapi_client/api/default_api.py deleted file mode 100644 index f38ab0ec..00000000 --- a/client/src/openapi_client/api/default_api.py +++ /dev/null @@ -1,285 +0,0 @@ -# coding: utf-8 - -""" -infrastructure-product API - -Backend service for the appliedAI infrastructure product - -The version of the OpenAPI document: 0.1.0 -Generated by OpenAPI Generator (https://openapi-generator.tech) - -Do not edit the class manually. -""" # noqa: E501 - -from typing import Any, Dict, List, Optional, Tuple, Union - -from pydantic import Field, StrictFloat, StrictInt, StrictStr, validate_call -from typing_extensions import Annotated - -from openapi_client.api_client import ApiClient, RequestSerialized -from openapi_client.api_response import ApiResponse -from openapi_client.models.create_job_model import CreateJobModel -from openapi_client.models.workload_identifier import WorkloadIdentifier -from openapi_client.rest import RESTResponseType - - -class DefaultApi: - """NOTE: This class is auto generated by OpenAPI Generator - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - def __init__(self, api_client=None) -> None: - if api_client is None: - api_client = ApiClient.get_default() - self.api_client = api_client - - @validate_call - def submit_job_jobs_post( - self, - create_job_model: CreateJobModel, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] - ], - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, - _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, - _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> WorkloadIdentifier: - """Submit Job - - - :param create_job_model: (required) - :type create_job_model: CreateJobModel - :param _request_timeout: timeout setting for this request. If one - number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :type _request_timeout: int, tuple(int, int), optional - :param _request_auth: set to override the auth_settings for an a single - request; this effectively ignores the - authentication in the spec for a single request. - :type _request_auth: dict, optional - :param _content_type: force content-type for the request. - :type _content_type: str, Optional - :param _headers: set to override the headers for a single - request; this effectively ignores the headers - in the spec for a single request. - :type _headers: dict, optional - :param _host_index: set to override the host_index for a single - request; this effectively ignores the host_index - in the spec for a single request. - :type _host_index: int, optional - :return: Returns the result object. - """ # noqa: E501 - - _param = self._submit_job_jobs_post_serialize( - create_job_model=create_job_model, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index, - ) - - _response_types_map: Dict[str, Optional[str]] = { - "200": "WorkloadIdentifier", - "422": "HTTPValidationError", - } - response_data = self.api_client.call_api( - *_param, _request_timeout=_request_timeout - ) - response_data.read() - return self.api_client.response_deserialize( - response_data=response_data, - response_types_map=_response_types_map, - ).data - - @validate_call - def submit_job_jobs_post_with_http_info( - self, - create_job_model: CreateJobModel, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] - ], - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, - _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, - _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ApiResponse[WorkloadIdentifier]: - """Submit Job - - - :param create_job_model: (required) - :type create_job_model: CreateJobModel - :param _request_timeout: timeout setting for this request. If one - number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :type _request_timeout: int, tuple(int, int), optional - :param _request_auth: set to override the auth_settings for an a single - request; this effectively ignores the - authentication in the spec for a single request. - :type _request_auth: dict, optional - :param _content_type: force content-type for the request. - :type _content_type: str, Optional - :param _headers: set to override the headers for a single - request; this effectively ignores the headers - in the spec for a single request. - :type _headers: dict, optional - :param _host_index: set to override the host_index for a single - request; this effectively ignores the host_index - in the spec for a single request. - :type _host_index: int, optional - :return: Returns the result object. - """ # noqa: E501 - - _param = self._submit_job_jobs_post_serialize( - create_job_model=create_job_model, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index, - ) - - _response_types_map: Dict[str, Optional[str]] = { - "200": "WorkloadIdentifier", - "422": "HTTPValidationError", - } - response_data = self.api_client.call_api( - *_param, _request_timeout=_request_timeout - ) - response_data.read() - return self.api_client.response_deserialize( - response_data=response_data, - response_types_map=_response_types_map, - ) - - @validate_call - def submit_job_jobs_post_without_preload_content( - self, - create_job_model: CreateJobModel, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] - ], - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, - _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, - _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> RESTResponseType: - """Submit Job - - - :param create_job_model: (required) - :type create_job_model: CreateJobModel - :param _request_timeout: timeout setting for this request. If one - number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :type _request_timeout: int, tuple(int, int), optional - :param _request_auth: set to override the auth_settings for an a single - request; this effectively ignores the - authentication in the spec for a single request. - :type _request_auth: dict, optional - :param _content_type: force content-type for the request. - :type _content_type: str, Optional - :param _headers: set to override the headers for a single - request; this effectively ignores the headers - in the spec for a single request. - :type _headers: dict, optional - :param _host_index: set to override the host_index for a single - request; this effectively ignores the host_index - in the spec for a single request. - :type _host_index: int, optional - :return: Returns the result object. - """ # noqa: E501 - - _param = self._submit_job_jobs_post_serialize( - create_job_model=create_job_model, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index, - ) - - _response_types_map: Dict[str, Optional[str]] = { - "200": "WorkloadIdentifier", - "422": "HTTPValidationError", - } - response_data = self.api_client.call_api( - *_param, _request_timeout=_request_timeout - ) - return response_data.response - - def _submit_job_jobs_post_serialize( - self, - create_job_model, - _request_auth, - _content_type, - _headers, - _host_index, - ) -> RequestSerialized: - _host = None - - _collection_formats: Dict[str, str] = {} - - _path_params: Dict[str, str] = {} - _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} - _form_params: List[Tuple[str, str]] = [] - _files: Dict[str, Union[str, bytes]] = {} - _body_params: Optional[bytes] = None - - # process the path parameters - # process the query parameters - # process the header parameters - # process the form parameters - # process the body parameter - if create_job_model is not None: - _body_params = create_job_model - - # set the HTTP header `Accept` - if "Accept" not in _header_params: - _header_params["Accept"] = self.api_client.select_header_accept([ - "application/json" - ]) - - # set the HTTP header `Content-Type` - if _content_type: - _header_params["Content-Type"] = _content_type - else: - _default_content_type = self.api_client.select_header_content_type([ - "application/json" - ]) - if _default_content_type is not None: - _header_params["Content-Type"] = _default_content_type - - # authentication setting - _auth_settings: List[str] = [] - - return self.api_client.param_serialize( - method="POST", - resource_path="/jobs", - path_params=_path_params, - query_params=_query_params, - header_params=_header_params, - body=_body_params, - post_params=_form_params, - files=_files, - auth_settings=_auth_settings, - collection_formats=_collection_formats, - _host=_host, - _request_auth=_request_auth, - ) diff --git a/client/src/openapi_client/api/job_management_api.py b/client/src/openapi_client/api/job_management_api.py new file mode 100644 index 00000000..5c5f845f --- /dev/null +++ b/client/src/openapi_client/api/job_management_api.py @@ -0,0 +1,812 @@ +""" +infrastructure-product API + +Backend service for the appliedAI infrastructure product + +The version of the OpenAPI document: 0.1.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from typing import Annotated, Any + +from pydantic import Field, StrictBool, StrictFloat, StrictInt, StrictStr, validate_call + +from openapi_client.api_client import ApiClient, RequestSerialized +from openapi_client.api_response import ApiResponse +from openapi_client.models.create_job_model import CreateJobModel +from openapi_client.models.workload_identifier import WorkloadIdentifier +from openapi_client.rest import RESTResponseType + + +class JobManagementApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + @validate_call + def logs_jobs_uid_logs_get( + self, + uid: StrictStr, + stream: StrictBool | None = None, + tail: StrictInt | None = None, + namespace: StrictStr | None = None, + _request_timeout: None + | Annotated[StrictFloat, Field(gt=0)] + | tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ] = None, + _request_auth: dict[StrictStr, Any] | None = None, + _content_type: StrictStr | None = None, + _headers: dict[StrictStr, Any] | None = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> object: + """Logs + + + :param uid: (required) + :type uid: str + :param stream: + :type stream: bool + :param tail: + :type tail: int + :param namespace: + :type namespace: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._logs_jobs_uid_logs_get_serialize( + uid=uid, + stream=stream, + tail=tail, + namespace=namespace, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: dict[str, str | None] = { + "200": "object", + "422": "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def logs_jobs_uid_logs_get_with_http_info( + self, + uid: StrictStr, + stream: StrictBool | None = None, + tail: StrictInt | None = None, + namespace: StrictStr | None = None, + _request_timeout: None + | Annotated[StrictFloat, Field(gt=0)] + | tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ] = None, + _request_auth: dict[StrictStr, Any] | None = None, + _content_type: StrictStr | None = None, + _headers: dict[StrictStr, Any] | None = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[object]: + """Logs + + + :param uid: (required) + :type uid: str + :param stream: + :type stream: bool + :param tail: + :type tail: int + :param namespace: + :type namespace: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._logs_jobs_uid_logs_get_serialize( + uid=uid, + stream=stream, + tail=tail, + namespace=namespace, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: dict[str, str | None] = { + "200": "object", + "422": "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def logs_jobs_uid_logs_get_without_preload_content( + self, + uid: StrictStr, + stream: StrictBool | None = None, + tail: StrictInt | None = None, + namespace: StrictStr | None = None, + _request_timeout: None + | Annotated[StrictFloat, Field(gt=0)] + | tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ] = None, + _request_auth: dict[StrictStr, Any] | None = None, + _content_type: StrictStr | None = None, + _headers: dict[StrictStr, Any] | None = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Logs + + + :param uid: (required) + :type uid: str + :param stream: + :type stream: bool + :param tail: + :type tail: int + :param namespace: + :type namespace: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._logs_jobs_uid_logs_get_serialize( + uid=uid, + stream=stream, + tail=tail, + namespace=namespace, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: dict[str, str | None] = { + "200": "object", + "422": "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _logs_jobs_uid_logs_get_serialize( + self, + uid, + stream, + tail, + namespace, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: dict[str, str] = {} + + _path_params: dict[str, str] = {} + _query_params: list[tuple[str, str]] = [] + _header_params: dict[str, str | None] = _headers or {} + _form_params: list[tuple[str, str]] = [] + _files: dict[ + str, str | bytes | list[str] | list[bytes] | list[tuple[str, bytes]] + ] = {} + _body_params: bytes | None = None + + # process the path parameters + if uid is not None: + _path_params["uid"] = uid + # process the query parameters + if stream is not None: + _query_params.append(("stream", stream)) + + if tail is not None: + _query_params.append(("tail", tail)) + + if namespace is not None: + _query_params.append(("namespace", namespace)) + + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept([ + "application/json" + ]) + + # authentication setting + _auth_settings: list[str] = [] + + return self.api_client.param_serialize( + method="GET", + resource_path="/jobs/{uid}/logs", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def status_jobs_uid_status_get( + self, + uid: StrictStr, + namespace: StrictStr | None = None, + _request_timeout: None + | Annotated[StrictFloat, Field(gt=0)] + | tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ] = None, + _request_auth: dict[StrictStr, Any] | None = None, + _content_type: StrictStr | None = None, + _headers: dict[StrictStr, Any] | None = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> object: + """Status + + + :param uid: (required) + :type uid: str + :param namespace: + :type namespace: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._status_jobs_uid_status_get_serialize( + uid=uid, + namespace=namespace, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: dict[str, str | None] = { + "200": "object", + "422": "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def status_jobs_uid_status_get_with_http_info( + self, + uid: StrictStr, + namespace: StrictStr | None = None, + _request_timeout: None + | Annotated[StrictFloat, Field(gt=0)] + | tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ] = None, + _request_auth: dict[StrictStr, Any] | None = None, + _content_type: StrictStr | None = None, + _headers: dict[StrictStr, Any] | None = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[object]: + """Status + + + :param uid: (required) + :type uid: str + :param namespace: + :type namespace: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._status_jobs_uid_status_get_serialize( + uid=uid, + namespace=namespace, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: dict[str, str | None] = { + "200": "object", + "422": "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def status_jobs_uid_status_get_without_preload_content( + self, + uid: StrictStr, + namespace: StrictStr | None = None, + _request_timeout: None + | Annotated[StrictFloat, Field(gt=0)] + | tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ] = None, + _request_auth: dict[StrictStr, Any] | None = None, + _content_type: StrictStr | None = None, + _headers: dict[StrictStr, Any] | None = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Status + + + :param uid: (required) + :type uid: str + :param namespace: + :type namespace: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._status_jobs_uid_status_get_serialize( + uid=uid, + namespace=namespace, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: dict[str, str | None] = { + "200": "object", + "422": "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _status_jobs_uid_status_get_serialize( + self, + uid, + namespace, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: dict[str, str] = {} + + _path_params: dict[str, str] = {} + _query_params: list[tuple[str, str]] = [] + _header_params: dict[str, str | None] = _headers or {} + _form_params: list[tuple[str, str]] = [] + _files: dict[ + str, str | bytes | list[str] | list[bytes] | list[tuple[str, bytes]] + ] = {} + _body_params: bytes | None = None + + # process the path parameters + if uid is not None: + _path_params["uid"] = uid + # process the query parameters + if namespace is not None: + _query_params.append(("namespace", namespace)) + + # process the header parameters + # process the form parameters + # process the body parameter + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept([ + "application/json" + ]) + + # authentication setting + _auth_settings: list[str] = [] + + return self.api_client.param_serialize( + method="GET", + resource_path="/jobs/{uid}/status", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) + + @validate_call + def submit_job_jobs_post( + self, + create_job_model: CreateJobModel, + _request_timeout: None + | Annotated[StrictFloat, Field(gt=0)] + | tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ] = None, + _request_auth: dict[StrictStr, Any] | None = None, + _content_type: StrictStr | None = None, + _headers: dict[StrictStr, Any] | None = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> WorkloadIdentifier: + """Submit Job + + + :param create_job_model: (required) + :type create_job_model: CreateJobModel + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._submit_job_jobs_post_serialize( + create_job_model=create_job_model, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: dict[str, str | None] = { + "200": "WorkloadIdentifier", + "422": "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + @validate_call + def submit_job_jobs_post_with_http_info( + self, + create_job_model: CreateJobModel, + _request_timeout: None + | Annotated[StrictFloat, Field(gt=0)] + | tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ] = None, + _request_auth: dict[StrictStr, Any] | None = None, + _content_type: StrictStr | None = None, + _headers: dict[StrictStr, Any] | None = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[WorkloadIdentifier]: + """Submit Job + + + :param create_job_model: (required) + :type create_job_model: CreateJobModel + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._submit_job_jobs_post_serialize( + create_job_model=create_job_model, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: dict[str, str | None] = { + "200": "WorkloadIdentifier", + "422": "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + @validate_call + def submit_job_jobs_post_without_preload_content( + self, + create_job_model: CreateJobModel, + _request_timeout: None + | Annotated[StrictFloat, Field(gt=0)] + | tuple[ + Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)] + ] = None, + _request_auth: dict[StrictStr, Any] | None = None, + _content_type: StrictStr | None = None, + _headers: dict[StrictStr, Any] | None = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Submit Job + + + :param create_job_model: (required) + :type create_job_model: CreateJobModel + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._submit_job_jobs_post_serialize( + create_job_model=create_job_model, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + + _response_types_map: dict[str, str | None] = { + "200": "WorkloadIdentifier", + "422": "HTTPValidationError", + } + response_data = self.api_client.call_api( + *_param, _request_timeout=_request_timeout + ) + return response_data.response + + def _submit_job_jobs_post_serialize( + self, + create_job_model, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + _host = None + + _collection_formats: dict[str, str] = {} + + _path_params: dict[str, str] = {} + _query_params: list[tuple[str, str]] = [] + _header_params: dict[str, str | None] = _headers or {} + _form_params: list[tuple[str, str]] = [] + _files: dict[ + str, str | bytes | list[str] | list[bytes] | list[tuple[str, bytes]] + ] = {} + _body_params: bytes | None = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if create_job_model is not None: + _body_params = create_job_model + + # set the HTTP header `Accept` + if "Accept" not in _header_params: + _header_params["Accept"] = self.api_client.select_header_accept([ + "application/json" + ]) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params["Content-Type"] = _content_type + else: + _default_content_type = self.api_client.select_header_content_type([ + "application/json" + ]) + if _default_content_type is not None: + _header_params["Content-Type"] = _default_content_type + + # authentication setting + _auth_settings: list[str] = [] + + return self.api_client.param_serialize( + method="POST", + resource_path="/jobs", + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth, + ) diff --git a/client/src/openapi_client/api_client.py b/client/src/openapi_client/api_client.py index 2f942d1b..a1734496 100644 --- a/client/src/openapi_client/api_client.py +++ b/client/src/openapi_client/api_client.py @@ -1,5 +1,3 @@ -# coding: utf-8 - """ infrastructure-product API @@ -19,7 +17,6 @@ import re import tempfile from enum import Enum -from typing import Dict, List, Optional, Tuple, Union from urllib.parse import quote from dateutil.parser import parse @@ -35,7 +32,7 @@ ApiValueError, ) -RequestSerialized = Tuple[str, str, Dict[str, str], Optional[str], List[str]] +RequestSerialized = tuple[str, str, dict[str, str], str | None, list[str]] class ApiClient: @@ -186,7 +183,7 @@ def param_serialize( for k, v in path_params: # specified safe chars, encode everything resource_path = resource_path.replace( - "{%s}" % k, quote(str(v), safe=config.safe_chars_for_path_param) + f"{{{k}}}", quote(str(v), safe=config.safe_chars_for_path_param) ) # post parameters @@ -267,7 +264,7 @@ def call_api( def response_deserialize( self, response_data: rest.RESTResponse, - response_types_map: Optional[Dict[str, ApiResponseT]] = None, + response_types_map: dict[str, ApiResponseT] | None = None, ) -> ApiResponse[ApiResponseT]: """Deserializes response into an object. :param response_data: RESTResponse object to be deserialized. @@ -350,7 +347,7 @@ def sanitize_for_serialization(self, obj): return [self.sanitize_for_serialization(sub_obj) for sub_obj in obj] elif isinstance(obj, tuple): return tuple(self.sanitize_for_serialization(sub_obj) for sub_obj in obj) - elif isinstance(obj, (datetime.datetime, datetime.date)): + elif isinstance(obj, datetime.datetime | datetime.date): return obj.isoformat() elif isinstance(obj, decimal.Decimal): return str(obj) @@ -363,7 +360,7 @@ def sanitize_for_serialization(self, obj): # and attributes which value is not None. # Convert attribute name to json key in # model definition for request. - if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")): + if hasattr(obj, "to_dict") and callable(obj.to_dict): obj_dict = obj.to_dict() else: obj_dict = obj.__dict__ @@ -373,7 +370,7 @@ def sanitize_for_serialization(self, obj): } def deserialize( - self, response_text: str, response_type: str, content_type: Optional[str] + self, response_text: str, response_type: str, content_type: str | None ): """Deserializes response into an object. @@ -400,7 +397,7 @@ def deserialize( data = response_text else: raise ApiException( - status=0, reason="Unsupported content type: {0}".format(content_type) + status=0, reason=f"Unsupported content type: {content_type}" ) return self.__deserialize(data, response_type) @@ -437,13 +434,13 @@ def __deserialize(self, data, klass): if klass in self.PRIMITIVE_TYPES: return self.__deserialize_primitive(data, klass) - elif klass is object: + elif klass == object: return self.__deserialize_object(data) - elif klass is datetime.date: + elif klass == datetime.date: return self.__deserialize_date(data) - elif klass is datetime.datetime: + elif klass == datetime.datetime: return self.__deserialize_datetime(data) - elif klass is decimal.Decimal: + elif klass == decimal.Decimal: return decimal.Decimal(data) elif issubclass(klass, Enum): return self.__deserialize_enum(data, klass) @@ -457,7 +454,7 @@ def parameters_to_tuples(self, params, collection_formats): :param dict collection_formats: Parameter collection formats :return: Parameters as list of tuples, collections formatted """ - new_params: List[Tuple[str, str]] = [] + new_params: list[tuple[str, str]] = [] if collection_formats is None: collection_formats = {} for k, v in params.items() if isinstance(params, dict) else params: @@ -486,13 +483,13 @@ def parameters_to_url_query(self, params, collection_formats): :param dict collection_formats: Parameter collection formats :return: URL query string (e.g. a=Hello%20World&b=123) """ - new_params: List[Tuple[str, str]] = [] + new_params: list[tuple[str, str]] = [] if collection_formats is None: collection_formats = {} for k, v in params.items() if isinstance(params, dict) else params: if isinstance(v, bool): v = str(v).lower() - if isinstance(v, (int, float)): + if isinstance(v, int | float): v = str(v) if isinstance(v, dict): v = json.dumps(v) @@ -519,7 +516,10 @@ def parameters_to_url_query(self, params, collection_formats): return "&".join(["=".join(map(str, item)) for item in new_params]) - def files_parameters(self, files: Dict[str, Union[str, bytes]]): + def files_parameters( + self, + files: dict[str, str | bytes | list[str] | list[bytes] | tuple[str, bytes]], + ): """Builds form parameters. :param files: File parameters. @@ -534,13 +534,19 @@ def files_parameters(self, files: Dict[str, Union[str, bytes]]): elif isinstance(v, bytes): filename = k filedata = v + elif isinstance(v, tuple): + filename, filedata = v + elif isinstance(v, list): + for file_param in v: + params.extend(self.files_parameters({k: file_param})) + continue else: raise ValueError("Unsupported file value") mimetype = mimetypes.guess_type(filename)[0] or "application/octet-stream" - params.append(tuple([k, tuple([filename, filedata, mimetype])])) + params.append((k, (filename, filedata, mimetype))) return params - def select_header_accept(self, accepts: List[str]) -> Optional[str]: + def select_header_accept(self, accepts: list[str]) -> str | None: """Returns `Accept` based on an array of accepts provided. :param accepts: List of headers. @@ -692,7 +698,7 @@ def __deserialize_date(self, string): return string except ValueError: raise rest.ApiException( - status=0, reason="Failed to parse `{0}` as date object".format(string) + status=0, reason=f"Failed to parse `{string}` as date object" ) def __deserialize_datetime(self, string): @@ -710,7 +716,7 @@ def __deserialize_datetime(self, string): except ValueError: raise rest.ApiException( status=0, - reason=("Failed to parse `{0}` as datetime object".format(string)), + reason=(f"Failed to parse `{string}` as datetime object"), ) def __deserialize_enum(self, data, klass): @@ -724,7 +730,7 @@ def __deserialize_enum(self, data, klass): return klass(data) except ValueError: raise rest.ApiException( - status=0, reason=("Failed to parse `{0}` as `{1}`".format(data, klass)) + status=0, reason=(f"Failed to parse `{data}` as `{klass}`") ) def __deserialize_model(self, data, klass): diff --git a/client/src/openapi_client/api_response.py b/client/src/openapi_client/api_response.py index ca801da0..7cec3605 100644 --- a/client/src/openapi_client/api_response.py +++ b/client/src/openapi_client/api_response.py @@ -2,7 +2,8 @@ from __future__ import annotations -from typing import Generic, Mapping, Optional, TypeVar +from collections.abc import Mapping +from typing import Generic, TypeVar from pydantic import BaseModel, Field, StrictBytes, StrictInt @@ -15,7 +16,7 @@ class ApiResponse(BaseModel, Generic[T]): """ status_code: StrictInt = Field(description="HTTP status code") - headers: Optional[Mapping[str, str]] = Field(None, description="HTTP headers") + headers: Mapping[str, str] | None = Field(None, description="HTTP headers") data: T = Field(description="Deserialized data given the data type") raw_data: StrictBytes = Field(description="Raw data (HTTP response body)") diff --git a/client/src/openapi_client/configuration.py b/client/src/openapi_client/configuration.py index bcf4bc82..66b1617c 100644 --- a/client/src/openapi_client/configuration.py +++ b/client/src/openapi_client/configuration.py @@ -1,5 +1,3 @@ -# coding: utf-8 - """ infrastructure-product API @@ -17,7 +15,6 @@ import multiprocessing import sys from logging import FileHandler -from typing import Optional import urllib3 @@ -86,7 +83,7 @@ def __init__( ssl_ca_cert=None, retries=None, *, - debug: Optional[bool] = None, + debug: bool | None = None, ) -> None: """Constructor""" self._base_path = "http://localhost" if host is None else host @@ -140,7 +137,7 @@ def __init__( self.logger_stream_handler = None """Log stream handler """ - self.logger_file_handler: Optional[FileHandler] = None + self.logger_file_handler: FileHandler | None = None """Log file handler """ self.logger_file = None @@ -183,7 +180,7 @@ def __init__( cpu_count * 5 is used as default value to increase performance. """ - self.proxy: Optional[str] = None + self.proxy: str | None = None """Proxy URL """ self.proxy_headers = None @@ -362,7 +359,7 @@ def get_api_key_with_prefix(self, identifier, alias=None): if key: prefix = self.api_key_prefix.get(identifier) if prefix: - return "%s %s" % (prefix, key) + return f"{prefix} {key}" else: return key @@ -396,10 +393,10 @@ def to_debug_report(self): """ return ( "Python SDK Debug Report:\n" - "OS: {env}\n" - "Python Version: {pyversion}\n" + f"OS: {sys.platform}\n" + f"Python Version: {sys.version}\n" "Version of the API: 0.1.0\n" - "SDK Package Version: 1.0.0".format(env=sys.platform, pyversion=sys.version) + "SDK Package Version: 1.0.0" ) def get_host_settings(self): @@ -431,8 +428,8 @@ def get_host_from_settings(self, index, variables=None, servers=None): server = servers[index] except IndexError: raise ValueError( - "Invalid index {0} when selecting the host settings. " - "Must be less than {1}".format(index, len(servers)) + f"Invalid index {index} when selecting the host settings. " + f"Must be less than {len(servers)}" ) url = server["url"] @@ -443,8 +440,8 @@ def get_host_from_settings(self, index, variables=None, servers=None): if "enum_values" in variable and used_value not in variable["enum_values"]: raise ValueError( - "The variable `{0}` in the host URL has invalid value " - "{1}. Must be {2}.".format( + "The variable `{}` in the host URL has invalid value " + "{}. Must be {}.".format( variable_name, variables[variable_name], variable["enum_values"] ) ) diff --git a/client/src/openapi_client/docs/CreateJobModel.md b/client/src/openapi_client/docs/CreateJobModel.md new file mode 100644 index 00000000..bf7eddb0 --- /dev/null +++ b/client/src/openapi_client/docs/CreateJobModel.md @@ -0,0 +1,32 @@ +# CreateJobModel + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **str** | | +**file** | **str** | | +**image_ref** | **str** | | +**mode** | [**ExecutionMode**](ExecutionMode.md) | | +**options** | [**JobOptions**](JobOptions.md) | | +**submission_context** | **object** | | [optional] + +## Example + +```python +from openapi_client.models.create_job_model import CreateJobModel + +# TODO update the JSON string below +json = "{}" +# create an instance of CreateJobModel from a JSON string +create_job_model_instance = CreateJobModel.from_json(json) +# print the JSON string representation of the object +print(CreateJobModel.to_json()) + +# convert the object into a dict +create_job_model_dict = create_job_model_instance.to_dict() +# create an instance of CreateJobModel from a dict +create_job_model_from_dict = CreateJobModel.from_dict(create_job_model_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/client/src/openapi_client/docs/ExecutionMode.md b/client/src/openapi_client/docs/ExecutionMode.md new file mode 100644 index 00000000..dc02404d --- /dev/null +++ b/client/src/openapi_client/docs/ExecutionMode.md @@ -0,0 +1,17 @@ +# ExecutionMode + +ExecutionMode + +## Enum + +* `LOCAL` (value: `'local'`) + +* `DOCKER` (value: `'docker'`) + +* `KUEUE` (value: `'kueue'`) + +* `RAYCLUSTER` (value: `'raycluster'`) + +* `RAYJOB` (value: `'rayjob'`) + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/client/src/openapi_client/docs/HTTPValidationError.md b/client/src/openapi_client/docs/HTTPValidationError.md new file mode 100644 index 00000000..3ef436b7 --- /dev/null +++ b/client/src/openapi_client/docs/HTTPValidationError.md @@ -0,0 +1,27 @@ +# HTTPValidationError + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**detail** | [**List[ValidationError]**](ValidationError.md) | | [optional] + +## Example + +```python +from openapi_client.models.http_validation_error import HTTPValidationError + +# TODO update the JSON string below +json = "{}" +# create an instance of HTTPValidationError from a JSON string +http_validation_error_instance = HTTPValidationError.from_json(json) +# print the JSON string representation of the object +print(HTTPValidationError.to_json()) + +# convert the object into a dict +http_validation_error_dict = http_validation_error_instance.to_dict() +# create an instance of HTTPValidationError from a dict +http_validation_error_from_dict = HTTPValidationError.from_dict(http_validation_error_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/client/src/openapi_client/docs/JobManagementApi.md b/client/src/openapi_client/docs/JobManagementApi.md new file mode 100644 index 00000000..f0063a83 --- /dev/null +++ b/client/src/openapi_client/docs/JobManagementApi.md @@ -0,0 +1,218 @@ +# openapi_client.JobManagementApi + +All URIs are relative to *http://localhost* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**logs_jobs_uid_logs_get**](JobManagementApi.md#logs_jobs_uid_logs_get) | **GET** /jobs/{uid}/logs | Logs +[**status_jobs_uid_status_get**](JobManagementApi.md#status_jobs_uid_status_get) | **GET** /jobs/{uid}/status | Status +[**submit_job_jobs_post**](JobManagementApi.md#submit_job_jobs_post) | **POST** /jobs | Submit Job + + +# **logs_jobs_uid_logs_get** +> object logs_jobs_uid_logs_get(uid, stream=stream, tail=tail, namespace=namespace) + +Logs + +### Example + + +```python +import openapi_client +from openapi_client.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://localhost +# See configuration.py for a list of all supported configuration parameters. +configuration = openapi_client.Configuration( + host = "http://localhost" +) + + +# Enter a context with an instance of the API client +with openapi_client.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = openapi_client.JobManagementApi(api_client) + uid = 'uid_example' # str | + stream = False # bool | (optional) (default to False) + tail = 100 # int | (optional) (default to 100) + namespace = 'default' # str | (optional) (default to 'default') + + try: + # Logs + api_response = api_instance.logs_jobs_uid_logs_get(uid, stream=stream, tail=tail, namespace=namespace) + print("The response of JobManagementApi->logs_jobs_uid_logs_get:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling JobManagementApi->logs_jobs_uid_logs_get: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **uid** | **str**| | + **stream** | **bool**| | [optional] [default to False] + **tail** | **int**| | [optional] [default to 100] + **namespace** | **str**| | [optional] [default to 'default'] + +### Return type + +**object** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **status_jobs_uid_status_get** +> object status_jobs_uid_status_get(uid, namespace=namespace) + +Status + +### Example + + +```python +import openapi_client +from openapi_client.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://localhost +# See configuration.py for a list of all supported configuration parameters. +configuration = openapi_client.Configuration( + host = "http://localhost" +) + + +# Enter a context with an instance of the API client +with openapi_client.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = openapi_client.JobManagementApi(api_client) + uid = 'uid_example' # str | + namespace = 'default' # str | (optional) (default to 'default') + + try: + # Status + api_response = api_instance.status_jobs_uid_status_get(uid, namespace=namespace) + print("The response of JobManagementApi->status_jobs_uid_status_get:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling JobManagementApi->status_jobs_uid_status_get: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **uid** | **str**| | + **namespace** | **str**| | [optional] [default to 'default'] + +### Return type + +**object** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **submit_job_jobs_post** +> WorkloadIdentifier submit_job_jobs_post(create_job_model) + +Submit Job + +### Example + + +```python +import openapi_client +from openapi_client.models.create_job_model import CreateJobModel +from openapi_client.models.workload_identifier import WorkloadIdentifier +from openapi_client.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://localhost +# See configuration.py for a list of all supported configuration parameters. +configuration = openapi_client.Configuration( + host = "http://localhost" +) + + +# Enter a context with an instance of the API client +with openapi_client.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = openapi_client.JobManagementApi(api_client) + create_job_model = openapi_client.CreateJobModel() # CreateJobModel | + + try: + # Submit Job + api_response = api_instance.submit_job_jobs_post(create_job_model) + print("The response of JobManagementApi->submit_job_jobs_post:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling JobManagementApi->submit_job_jobs_post: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **create_job_model** | [**CreateJobModel**](CreateJobModel.md)| | + +### Return type + +[**WorkloadIdentifier**](WorkloadIdentifier.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful Response | - | +**422** | Validation Error | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) diff --git a/client/src/openapi_client/docs/JobOptions.md b/client/src/openapi_client/docs/JobOptions.md new file mode 100644 index 00000000..d9137743 --- /dev/null +++ b/client/src/openapi_client/docs/JobOptions.md @@ -0,0 +1,30 @@ +# JobOptions + +JobOptions + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**resources** | [**ResourceOptions**](ResourceOptions.md) | | [optional] +**scheduling** | [**SchedulingOptions**](SchedulingOptions.md) | | [optional] +**labels** | **Dict[str, str]** | | [optional] + +## Example + +```python +from openapi_client.models.job_options import JobOptions + +# TODO update the JSON string below +json = "{}" +# create an instance of JobOptions from a JSON string +job_options_instance = JobOptions.from_json(json) +# print the JSON string representation of the object +print(JobOptions.to_json()) + +# convert the object into a dict +job_options_dict = job_options_instance.to_dict() +# create an instance of JobOptions from a dict +job_options_from_dict = JobOptions.from_dict(job_options_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/client/src/openapi_client/docs/ResourceOptions.md b/client/src/openapi_client/docs/ResourceOptions.md new file mode 100644 index 00000000..15b7a082 --- /dev/null +++ b/client/src/openapi_client/docs/ResourceOptions.md @@ -0,0 +1,30 @@ +# ResourceOptions + +ResourceOptions + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**memory** | **str** | | [optional] +**cpu** | **str** | | [optional] +**gpu** | **int** | | [optional] + +## Example + +```python +from openapi_client.models.resource_options import ResourceOptions + +# TODO update the JSON string below +json = "{}" +# create an instance of ResourceOptions from a JSON string +resource_options_instance = ResourceOptions.from_json(json) +# print the JSON string representation of the object +print(ResourceOptions.to_json()) + +# convert the object into a dict +resource_options_dict = resource_options_instance.to_dict() +# create an instance of ResourceOptions from a dict +resource_options_from_dict = ResourceOptions.from_dict(resource_options_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/client/src/openapi_client/docs/SchedulingOptions.md b/client/src/openapi_client/docs/SchedulingOptions.md new file mode 100644 index 00000000..35e7b846 --- /dev/null +++ b/client/src/openapi_client/docs/SchedulingOptions.md @@ -0,0 +1,29 @@ +# SchedulingOptions + +SchedulingOptions + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**priority_class** | **str** | | [optional] +**queue_name** | **str** | | [optional] + +## Example + +```python +from openapi_client.models.scheduling_options import SchedulingOptions + +# TODO update the JSON string below +json = "{}" +# create an instance of SchedulingOptions from a JSON string +scheduling_options_instance = SchedulingOptions.from_json(json) +# print the JSON string representation of the object +print(SchedulingOptions.to_json()) + +# convert the object into a dict +scheduling_options_dict = scheduling_options_instance.to_dict() +# create an instance of SchedulingOptions from a dict +scheduling_options_from_dict = SchedulingOptions.from_dict(scheduling_options_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/client/src/openapi_client/docs/ValidationError.md b/client/src/openapi_client/docs/ValidationError.md new file mode 100644 index 00000000..4504a7ba --- /dev/null +++ b/client/src/openapi_client/docs/ValidationError.md @@ -0,0 +1,29 @@ +# ValidationError + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**loc** | [**List[ValidationErrorLocInner]**](ValidationErrorLocInner.md) | | +**msg** | **str** | | +**type** | **str** | | + +## Example + +```python +from openapi_client.models.validation_error import ValidationError + +# TODO update the JSON string below +json = "{}" +# create an instance of ValidationError from a JSON string +validation_error_instance = ValidationError.from_json(json) +# print the JSON string representation of the object +print(ValidationError.to_json()) + +# convert the object into a dict +validation_error_dict = validation_error_instance.to_dict() +# create an instance of ValidationError from a dict +validation_error_from_dict = ValidationError.from_dict(validation_error_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/client/src/openapi_client/docs/ValidationErrorLocInner.md b/client/src/openapi_client/docs/ValidationErrorLocInner.md new file mode 100644 index 00000000..997cbe99 --- /dev/null +++ b/client/src/openapi_client/docs/ValidationErrorLocInner.md @@ -0,0 +1,26 @@ +# ValidationErrorLocInner + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +## Example + +```python +from openapi_client.models.validation_error_loc_inner import ValidationErrorLocInner + +# TODO update the JSON string below +json = "{}" +# create an instance of ValidationErrorLocInner from a JSON string +validation_error_loc_inner_instance = ValidationErrorLocInner.from_json(json) +# print the JSON string representation of the object +print(ValidationErrorLocInner.to_json()) + +# convert the object into a dict +validation_error_loc_inner_dict = validation_error_loc_inner_instance.to_dict() +# create an instance of ValidationErrorLocInner from a dict +validation_error_loc_inner_from_dict = ValidationErrorLocInner.from_dict(validation_error_loc_inner_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/client/src/openapi_client/docs/WorkloadIdentifier.md b/client/src/openapi_client/docs/WorkloadIdentifier.md new file mode 100644 index 00000000..fa038530 --- /dev/null +++ b/client/src/openapi_client/docs/WorkloadIdentifier.md @@ -0,0 +1,32 @@ +# WorkloadIdentifier + +Identifier for a workload in a Kubernetes cluster + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**group** | **str** | | +**version** | **str** | | +**kind** | **str** | | +**namespace** | **str** | | +**uid** | **str** | | + +## Example + +```python +from openapi_client.models.workload_identifier import WorkloadIdentifier + +# TODO update the JSON string below +json = "{}" +# create an instance of WorkloadIdentifier from a JSON string +workload_identifier_instance = WorkloadIdentifier.from_json(json) +# print the JSON string representation of the object +print(WorkloadIdentifier.to_json()) + +# convert the object into a dict +workload_identifier_dict = workload_identifier_instance.to_dict() +# create an instance of WorkloadIdentifier from a dict +workload_identifier_from_dict = WorkloadIdentifier.from_dict(workload_identifier_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/client/src/openapi_client/exceptions.py b/client/src/openapi_client/exceptions.py index fab86a46..ae5075fb 100644 --- a/client/src/openapi_client/exceptions.py +++ b/client/src/openapi_client/exceptions.py @@ -1,5 +1,3 @@ -# coding: utf-8 - """ infrastructure-product API @@ -11,7 +9,7 @@ Do not edit the class manually. """ # noqa: E501 -from typing import Any, Optional +from typing import Any from typing_extensions import Self @@ -46,8 +44,8 @@ def __init__( self.key_type = key_type full_msg = msg if path_to_item: - full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) - super(ApiTypeError, self).__init__(full_msg) + full_msg = f"{msg} at {render_path(path_to_item)}" + super().__init__(full_msg) class ApiValueError(OpenApiException, ValueError): @@ -64,8 +62,8 @@ def __init__(self, msg, path_to_item=None) -> None: self.path_to_item = path_to_item full_msg = msg if path_to_item: - full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) - super(ApiValueError, self).__init__(full_msg) + full_msg = f"{msg} at {render_path(path_to_item)}" + super().__init__(full_msg) class ApiAttributeError(OpenApiException, AttributeError): @@ -83,8 +81,8 @@ def __init__(self, msg, path_to_item=None) -> None: self.path_to_item = path_to_item full_msg = msg if path_to_item: - full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) - super(ApiAttributeError, self).__init__(full_msg) + full_msg = f"{msg} at {render_path(path_to_item)}" + super().__init__(full_msg) class ApiKeyError(OpenApiException, KeyError): @@ -100,8 +98,8 @@ def __init__(self, msg, path_to_item=None) -> None: self.path_to_item = path_to_item full_msg = msg if path_to_item: - full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) - super(ApiKeyError, self).__init__(full_msg) + full_msg = f"{msg} at {render_path(path_to_item)}" + super().__init__(full_msg) class ApiException(OpenApiException): @@ -111,8 +109,8 @@ def __init__( reason=None, http_resp=None, *, - body: Optional[str] = None, - data: Optional[Any] = None, + body: str | None = None, + data: Any | None = None, ) -> None: self.status = status self.reason = reason @@ -137,8 +135,8 @@ def from_response( cls, *, http_resp, - body: Optional[str], - data: Optional[Any], + body: str | None, + data: Any | None, ) -> Self: if http_resp.status == 400: raise BadRequestException(http_resp=http_resp, body=body, data=data) @@ -158,12 +156,12 @@ def from_response( def __str__(self): """Custom error messages for exception""" - error_message = "({0})\n" "Reason: {1}\n".format(self.status, self.reason) + error_message = f"({self.status})\n" f"Reason: {self.reason}\n" if self.headers: - error_message += "HTTP response headers: {0}\n".format(self.headers) + error_message += f"HTTP response headers: {self.headers}\n" if self.data or self.body: - error_message += "HTTP response body: {0}\n".format(self.data or self.body) + error_message += f"HTTP response body: {self.data or self.body}\n" return error_message @@ -193,7 +191,7 @@ def render_path(path_to_item): result = "" for pth in path_to_item: if isinstance(pth, int): - result += "[{0}]".format(pth) + result += f"[{pth}]" else: - result += "['{0}']".format(pth) + result += f"['{pth}']" return result diff --git a/client/src/openapi_client/models/__init__.py b/client/src/openapi_client/models/__init__.py index 12091294..ad791377 100644 --- a/client/src/openapi_client/models/__init__.py +++ b/client/src/openapi_client/models/__init__.py @@ -13,8 +13,12 @@ """ # noqa: E501 # import models into model package -from openapi_client.models.workload_identifier import WorkloadIdentifier from openapi_client.models.create_job_model import CreateJobModel +from openapi_client.models.execution_mode import ExecutionMode from openapi_client.models.http_validation_error import HTTPValidationError +from openapi_client.models.job_options import JobOptions +from openapi_client.models.resource_options import ResourceOptions +from openapi_client.models.scheduling_options import SchedulingOptions from openapi_client.models.validation_error import ValidationError from openapi_client.models.validation_error_loc_inner import ValidationErrorLocInner +from openapi_client.models.workload_identifier import WorkloadIdentifier diff --git a/client/src/openapi_client/models/create_job_model.py b/client/src/openapi_client/models/create_job_model.py index d3eea26f..c70734b5 100644 --- a/client/src/openapi_client/models/create_job_model.py +++ b/client/src/openapi_client/models/create_job_model.py @@ -1,5 +1,3 @@ -# coding: utf-8 - """ infrastructure-product API @@ -16,16 +14,16 @@ import json import pprint import re # noqa: F401 -from typing import Any, ClassVar, Dict, List, Optional, Set +from typing import Any, ClassVar from pydantic import BaseModel, ConfigDict, StrictStr from typing_extensions import Self -from jobs import JobOptions -from jobs.types import DictSerializable, ExecutionMode, JsonSerializable +from openapi_client.models.execution_mode import ExecutionMode +from openapi_client.models.job_options import JobOptions -class CreateJobModel(DictSerializable, JsonSerializable, BaseModel): +class CreateJobModel(BaseModel): """ CreateJobModel """ # noqa: E501 @@ -35,8 +33,8 @@ class CreateJobModel(DictSerializable, JsonSerializable, BaseModel): image_ref: StrictStr mode: ExecutionMode options: JobOptions - submission_context: Optional[Dict[str, Any]] = None - __properties: ClassVar[List[str]] = [ + submission_context: dict[str, Any] | None = None + __properties: ClassVar[list[str]] = [ "name", "file", "image_ref", @@ -54,3 +52,56 @@ class CreateJobModel(DictSerializable, JsonSerializable, BaseModel): def to_str(self) -> str: """Returns the string representation of the model using alias""" return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Self | None: + """Create an instance of CreateJobModel from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: set[str] = set() + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of options + if self.options: + _dict["options"] = self.options.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: + """Create an instance of CreateJobModel from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "name": obj.get("name"), + "file": obj.get("file"), + "image_ref": obj.get("image_ref"), + "mode": obj.get("mode"), + "options": JobOptions.from_dict(obj["options"]) + if obj.get("options") is not None + else None, + "submission_context": obj.get("submission_context"), + }) + return _obj diff --git a/client/src/openapi_client/models/execution_mode.py b/client/src/openapi_client/models/execution_mode.py new file mode 100644 index 00000000..e0cf4864 --- /dev/null +++ b/client/src/openapi_client/models/execution_mode.py @@ -0,0 +1,37 @@ +""" +infrastructure-product API + +Backend service for the appliedAI infrastructure product + +The version of the OpenAPI document: 0.1.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations + +import json +from enum import Enum + +from typing_extensions import Self + + +class ExecutionMode(str, Enum): + """ + ExecutionMode + """ + + """ + allowed enum values + """ + LOCAL = "local" + DOCKER = "docker" + KUEUE = "kueue" + RAYCLUSTER = "raycluster" + RAYJOB = "rayjob" + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of ExecutionMode from a JSON string""" + return cls(json.loads(json_str)) diff --git a/client/src/openapi_client/models/http_validation_error.py b/client/src/openapi_client/models/http_validation_error.py index 240f2b5d..7912162c 100644 --- a/client/src/openapi_client/models/http_validation_error.py +++ b/client/src/openapi_client/models/http_validation_error.py @@ -1,5 +1,3 @@ -# coding: utf-8 - """ infrastructure-product API @@ -16,7 +14,7 @@ import json import pprint import re # noqa: F401 -from typing import Any, ClassVar, Dict, List, Optional, Set +from typing import Any, ClassVar from pydantic import BaseModel, ConfigDict from typing_extensions import Self @@ -29,8 +27,8 @@ class HTTPValidationError(BaseModel): HTTPValidationError """ # noqa: E501 - detail: Optional[List[ValidationError]] = None - __properties: ClassVar[List[str]] = ["detail"] + detail: list[ValidationError] | None = None + __properties: ClassVar[list[str]] = ["detail"] model_config = ConfigDict( populate_by_name=True, @@ -48,11 +46,11 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of HTTPValidationError from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -62,7 +60,7 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([]) + excluded_fields: set[str] = set() _dict = self.model_dump( by_alias=True, @@ -79,7 +77,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of HTTPValidationError from a dict""" if obj is None: return None diff --git a/client/src/openapi_client/models/job_options.py b/client/src/openapi_client/models/job_options.py new file mode 100644 index 00000000..b55387b6 --- /dev/null +++ b/client/src/openapi_client/models/job_options.py @@ -0,0 +1,109 @@ +""" +infrastructure-product API + +Backend service for the appliedAI infrastructure product + +The version of the OpenAPI document: 0.1.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations + +import json +import pprint +import re # noqa: F401 +from typing import Any, ClassVar + +from pydantic import BaseModel, ConfigDict, StrictStr +from typing_extensions import Self + +from openapi_client.models.resource_options import ResourceOptions +from openapi_client.models.scheduling_options import SchedulingOptions + + +class JobOptions(BaseModel): + """ + JobOptions + """ # noqa: E501 + + resources: ResourceOptions | None = None + scheduling: SchedulingOptions | None = None + labels: dict[str, StrictStr] | None = None + __properties: ClassVar[list[str]] = ["resources", "scheduling", "labels"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Self | None: + """Create an instance of JobOptions from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: set[str] = set() + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of resources + if self.resources: + _dict["resources"] = self.resources.to_dict() + # override the default output from pydantic by calling `to_dict()` of scheduling + if self.scheduling: + _dict["scheduling"] = self.scheduling.to_dict() + # set to None if resources (nullable) is None + # and model_fields_set contains the field + if self.resources is None and "resources" in self.model_fields_set: + _dict["resources"] = None + + # set to None if scheduling (nullable) is None + # and model_fields_set contains the field + if self.scheduling is None and "scheduling" in self.model_fields_set: + _dict["scheduling"] = None + + return _dict + + @classmethod + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: + """Create an instance of JobOptions from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "resources": ResourceOptions.from_dict(obj["resources"]) + if obj.get("resources") is not None + else None, + "scheduling": SchedulingOptions.from_dict(obj["scheduling"]) + if obj.get("scheduling") is not None + else None, + "labels": obj.get("labels"), + }) + return _obj diff --git a/client/src/openapi_client/models/resource_options.py b/client/src/openapi_client/models/resource_options.py new file mode 100644 index 00000000..eb2301cc --- /dev/null +++ b/client/src/openapi_client/models/resource_options.py @@ -0,0 +1,101 @@ +""" +infrastructure-product API + +Backend service for the appliedAI infrastructure product + +The version of the OpenAPI document: 0.1.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations + +import json +import pprint +import re # noqa: F401 +from typing import Any, ClassVar + +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from typing_extensions import Self + + +class ResourceOptions(BaseModel): + """ + ResourceOptions + """ # noqa: E501 + + memory: StrictStr | None = None + cpu: StrictStr | None = None + gpu: StrictInt | None = None + __properties: ClassVar[list[str]] = ["memory", "cpu", "gpu"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Self | None: + """Create an instance of ResourceOptions from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: set[str] = set() + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # set to None if memory (nullable) is None + # and model_fields_set contains the field + if self.memory is None and "memory" in self.model_fields_set: + _dict["memory"] = None + + # set to None if cpu (nullable) is None + # and model_fields_set contains the field + if self.cpu is None and "cpu" in self.model_fields_set: + _dict["cpu"] = None + + # set to None if gpu (nullable) is None + # and model_fields_set contains the field + if self.gpu is None and "gpu" in self.model_fields_set: + _dict["gpu"] = None + + return _dict + + @classmethod + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: + """Create an instance of ResourceOptions from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "memory": obj.get("memory"), + "cpu": obj.get("cpu"), + "gpu": obj.get("gpu"), + }) + return _obj diff --git a/client/src/openapi_client/models/scheduling_options.py b/client/src/openapi_client/models/scheduling_options.py new file mode 100644 index 00000000..7d016cb9 --- /dev/null +++ b/client/src/openapi_client/models/scheduling_options.py @@ -0,0 +1,94 @@ +""" +infrastructure-product API + +Backend service for the appliedAI infrastructure product + +The version of the OpenAPI document: 0.1.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations + +import json +import pprint +import re # noqa: F401 +from typing import Any, ClassVar + +from pydantic import BaseModel, ConfigDict, StrictStr +from typing_extensions import Self + + +class SchedulingOptions(BaseModel): + """ + SchedulingOptions + """ # noqa: E501 + + priority_class: StrictStr | None = None + queue_name: StrictStr | None = None + __properties: ClassVar[list[str]] = ["priority_class", "queue_name"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Self | None: + """Create an instance of SchedulingOptions from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: set[str] = set() + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # set to None if priority_class (nullable) is None + # and model_fields_set contains the field + if self.priority_class is None and "priority_class" in self.model_fields_set: + _dict["priority_class"] = None + + # set to None if queue_name (nullable) is None + # and model_fields_set contains the field + if self.queue_name is None and "queue_name" in self.model_fields_set: + _dict["queue_name"] = None + + return _dict + + @classmethod + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: + """Create an instance of SchedulingOptions from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "priority_class": obj.get("priority_class"), + "queue_name": obj.get("queue_name"), + }) + return _obj diff --git a/client/src/openapi_client/models/validation_error.py b/client/src/openapi_client/models/validation_error.py index 435d4eff..4d04ab53 100644 --- a/client/src/openapi_client/models/validation_error.py +++ b/client/src/openapi_client/models/validation_error.py @@ -1,5 +1,3 @@ -# coding: utf-8 - """ infrastructure-product API @@ -16,7 +14,7 @@ import json import pprint import re # noqa: F401 -from typing import Any, ClassVar, Dict, List, Optional, Set +from typing import Any, ClassVar from pydantic import BaseModel, ConfigDict, StrictStr from typing_extensions import Self @@ -29,10 +27,10 @@ class ValidationError(BaseModel): ValidationError """ # noqa: E501 - loc: List[ValidationErrorLocInner] + loc: list[ValidationErrorLocInner] msg: StrictStr type: StrictStr - __properties: ClassVar[List[str]] = ["loc", "msg", "type"] + __properties: ClassVar[list[str]] = ["loc", "msg", "type"] model_config = ConfigDict( populate_by_name=True, @@ -50,11 +48,11 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of ValidationError from a JSON string""" return cls.from_dict(json.loads(json_str)) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: """Return the dictionary representation of the model using alias. This has the following differences from calling pydantic's @@ -64,7 +62,7 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ - excluded_fields: Set[str] = set([]) + excluded_fields: set[str] = set() _dict = self.model_dump( by_alias=True, @@ -81,7 +79,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: """Create an instance of ValidationError from a dict""" if obj is None: return None diff --git a/client/src/openapi_client/models/validation_error_loc_inner.py b/client/src/openapi_client/models/validation_error_loc_inner.py index d8885dbd..fda75509 100644 --- a/client/src/openapi_client/models/validation_error_loc_inner.py +++ b/client/src/openapi_client/models/validation_error_loc_inner.py @@ -1,5 +1,3 @@ -# coding: utf-8 - """ infrastructure-product API @@ -16,7 +14,7 @@ import json import pprint import re # noqa: F401 -from typing import TYPE_CHECKING, Any, Dict, Optional, Set, Union +from typing import TYPE_CHECKING, Any from pydantic import ( BaseModel, @@ -36,14 +34,14 @@ class ValidationErrorLocInner(BaseModel): """ # data type: str - anyof_schema_1_validator: Optional[StrictStr] = None + anyof_schema_1_validator: StrictStr | None = None # data type: int - anyof_schema_2_validator: Optional[StrictInt] = None + anyof_schema_2_validator: StrictInt | None = None if TYPE_CHECKING: - actual_instance: Optional[Union[int, str]] = None + actual_instance: int | str | None = None else: actual_instance: Any = None - any_of_schemas: Set[str] = {"int", "str"} + any_of_schemas: set[str] = {"int", "str"} model_config = { "validate_assignment": True, @@ -90,7 +88,7 @@ def actual_instance_must_validate_anyof(cls, v): return v @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Self: + def from_dict(cls, obj: dict[str, Any]) -> Self: return cls.from_json(json.dumps(obj)) @classmethod @@ -138,7 +136,7 @@ def to_json(self) -> str: else: return json.dumps(self.actual_instance) - def to_dict(self) -> Optional[Union[Dict[str, Any], int, str]]: + def to_dict(self) -> dict[str, Any] | int | str | None: """Returns the dict representation of the actual instance""" if self.actual_instance is None: return None diff --git a/client/src/openapi_client/models/workload_identifier.py b/client/src/openapi_client/models/workload_identifier.py index 972be5d3..5c1c099b 100644 --- a/client/src/openapi_client/models/workload_identifier.py +++ b/client/src/openapi_client/models/workload_identifier.py @@ -1,18 +1,36 @@ +""" +infrastructure-product API + +Backend service for the appliedAI infrastructure product + +The version of the OpenAPI document: 0.1.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations + +import json import pprint -from pydantic import BaseModel, ConfigDict, StrictStr +import re # noqa: F401 +from typing import Any, ClassVar -from jobs.types import DictSerializable, JsonSerializable +from pydantic import BaseModel, ConfigDict, StrictStr +from typing_extensions import Self -class WorkloadIdentifier(DictSerializable, JsonSerializable, BaseModel): - """Identifier for a workload in a Kubernetes cluster""" +class WorkloadIdentifier(BaseModel): + """ + Identifier for a workload in a Kubernetes cluster + """ # noqa: E501 group: StrictStr version: StrictStr kind: StrictStr - namespace: StrictStr uid: StrictStr + __properties: ClassVar[list[str]] = ["group", "version", "kind", "namespace", "uid"] model_config = ConfigDict( populate_by_name=True, @@ -23,3 +41,50 @@ class WorkloadIdentifier(DictSerializable, JsonSerializable, BaseModel): def to_str(self) -> str: """Returns the string representation of the model using alias""" return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Self | None: + """Create an instance of WorkloadIdentifier from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: set[str] = set() + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: dict[str, Any] | None) -> Self | None: + """Create an instance of WorkloadIdentifier from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "group": obj.get("group"), + "version": obj.get("version"), + "kind": obj.get("kind"), + "namespace": obj.get("namespace"), + "uid": obj.get("uid"), + }) + return _obj diff --git a/client/src/openapi_client/rest.py b/client/src/openapi_client/rest.py index cdaeefb4..2ccf1b00 100644 --- a/client/src/openapi_client/rest.py +++ b/client/src/openapi_client/rest.py @@ -1,5 +1,3 @@ -# coding: utf-8 - """ infrastructure-product API @@ -142,7 +140,7 @@ def request( timeout = None if _request_timeout: - if isinstance(_request_timeout, (int, float)): + if isinstance(_request_timeout, int | float): timeout = urllib3.Timeout(total=_request_timeout) elif isinstance(_request_timeout, tuple) and len(_request_timeout) == 2: timeout = urllib3.Timeout( diff --git a/client/src/openapi_client/test/__init__.py b/client/src/openapi_client/test/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/client/src/openapi_client/test/test_create_job_model.py b/client/src/openapi_client/test/test_create_job_model.py new file mode 100644 index 00000000..f2eccfad --- /dev/null +++ b/client/src/openapi_client/test/test_create_job_model.py @@ -0,0 +1,80 @@ +""" +infrastructure-product API + +Backend service for the appliedAI infrastructure product + +The version of the OpenAPI document: 0.1.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +import unittest + +from openapi_client.models.create_job_model import CreateJobModel + + +class TestCreateJobModel(unittest.TestCase): + """CreateJobModel unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> CreateJobModel: + """Test CreateJobModel + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included""" + # uncomment below to create an instance of `CreateJobModel` + """ + model = CreateJobModel() + if include_optional: + return CreateJobModel( + name = '', + file = '', + image_ref = '', + mode = 'local', + options = openapi_client.models.job_options.JobOptions( + resources = openapi_client.models.resource_options.ResourceOptions( + memory = '', + cpu = '', + gpu = 56, ), + scheduling = openapi_client.models.scheduling_options.SchedulingOptions( + priority_class = '', + queue_name = '', ), + labels = { + 'key' : '' + }, ), + submission_context = openapi_client.models.submission_context.Submission Context() + ) + else: + return CreateJobModel( + name = '', + file = '', + image_ref = '', + mode = 'local', + options = openapi_client.models.job_options.JobOptions( + resources = openapi_client.models.resource_options.ResourceOptions( + memory = '', + cpu = '', + gpu = 56, ), + scheduling = openapi_client.models.scheduling_options.SchedulingOptions( + priority_class = '', + queue_name = '', ), + labels = { + 'key' : '' + }, ), + ) + """ + + def testCreateJobModel(self): + """Test CreateJobModel""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + + +if __name__ == "__main__": + unittest.main() diff --git a/client/src/openapi_client/test/test_execution_mode.py b/client/src/openapi_client/test/test_execution_mode.py new file mode 100644 index 00000000..5a74460a --- /dev/null +++ b/client/src/openapi_client/test/test_execution_mode.py @@ -0,0 +1,30 @@ +""" +infrastructure-product API + +Backend service for the appliedAI infrastructure product + +The version of the OpenAPI document: 0.1.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +import unittest + + +class TestExecutionMode(unittest.TestCase): + """ExecutionMode unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testExecutionMode(self): + """Test ExecutionMode""" + # inst = ExecutionMode() + + +if __name__ == "__main__": + unittest.main() diff --git a/client/src/openapi_client/test/test_http_validation_error.py b/client/src/openapi_client/test/test_http_validation_error.py new file mode 100644 index 00000000..6312fd53 --- /dev/null +++ b/client/src/openapi_client/test/test_http_validation_error.py @@ -0,0 +1,57 @@ +""" +infrastructure-product API + +Backend service for the appliedAI infrastructure product + +The version of the OpenAPI document: 0.1.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +import unittest + +from openapi_client.models.http_validation_error import HTTPValidationError + + +class TestHTTPValidationError(unittest.TestCase): + """HTTPValidationError unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> HTTPValidationError: + """Test HTTPValidationError + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included""" + # uncomment below to create an instance of `HTTPValidationError` + """ + model = HTTPValidationError() + if include_optional: + return HTTPValidationError( + detail = [ + openapi_client.models.validation_error.ValidationError( + loc = [ + null + ], + msg = '', + type = '', ) + ] + ) + else: + return HTTPValidationError( + ) + """ + + def testHTTPValidationError(self): + """Test HTTPValidationError""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + + +if __name__ == "__main__": + unittest.main() diff --git a/client/src/openapi_client/test/test_job_management_api.py b/client/src/openapi_client/test/test_job_management_api.py new file mode 100644 index 00000000..51af5b35 --- /dev/null +++ b/client/src/openapi_client/test/test_job_management_api.py @@ -0,0 +1,49 @@ +""" +infrastructure-product API + +Backend service for the appliedAI infrastructure product + +The version of the OpenAPI document: 0.1.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +import unittest + +from openapi_client.api.job_management_api import JobManagementApi + + +class TestJobManagementApi(unittest.TestCase): + """JobManagementApi unit test stubs""" + + def setUp(self) -> None: + self.api = JobManagementApi() + + def tearDown(self) -> None: + pass + + def test_logs_jobs_uid_logs_get(self) -> None: + """Test case for logs_jobs_uid_logs_get + + Logs + """ + pass + + def test_status_jobs_uid_status_get(self) -> None: + """Test case for status_jobs_uid_status_get + + Status + """ + pass + + def test_submit_job_jobs_post(self) -> None: + """Test case for submit_job_jobs_post + + Submit Job + """ + pass + + +if __name__ == "__main__": + unittest.main() diff --git a/client/src/openapi_client/test/test_job_options.py b/client/src/openapi_client/test/test_job_options.py new file mode 100644 index 00000000..c11060ae --- /dev/null +++ b/client/src/openapi_client/test/test_job_options.py @@ -0,0 +1,59 @@ +""" +infrastructure-product API + +Backend service for the appliedAI infrastructure product + +The version of the OpenAPI document: 0.1.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +import unittest + +from openapi_client.models.job_options import JobOptions + + +class TestJobOptions(unittest.TestCase): + """JobOptions unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> JobOptions: + """Test JobOptions + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included""" + # uncomment below to create an instance of `JobOptions` + """ + model = JobOptions() + if include_optional: + return JobOptions( + resources = openapi_client.models.resource_options.ResourceOptions( + memory = '', + cpu = '', + gpu = 56, ), + scheduling = openapi_client.models.scheduling_options.SchedulingOptions( + priority_class = '', + queue_name = '', ), + labels = { + 'key' : '' + } + ) + else: + return JobOptions( + ) + """ + + def testJobOptions(self): + """Test JobOptions""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + + +if __name__ == "__main__": + unittest.main() diff --git a/client/src/openapi_client/test/test_resource_options.py b/client/src/openapi_client/test/test_resource_options.py new file mode 100644 index 00000000..695f5983 --- /dev/null +++ b/client/src/openapi_client/test/test_resource_options.py @@ -0,0 +1,52 @@ +""" +infrastructure-product API + +Backend service for the appliedAI infrastructure product + +The version of the OpenAPI document: 0.1.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +import unittest + +from openapi_client.models.resource_options import ResourceOptions + + +class TestResourceOptions(unittest.TestCase): + """ResourceOptions unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> ResourceOptions: + """Test ResourceOptions + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included""" + # uncomment below to create an instance of `ResourceOptions` + """ + model = ResourceOptions() + if include_optional: + return ResourceOptions( + memory = '', + cpu = '', + gpu = 56 + ) + else: + return ResourceOptions( + ) + """ + + def testResourceOptions(self): + """Test ResourceOptions""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + + +if __name__ == "__main__": + unittest.main() diff --git a/client/src/openapi_client/test/test_scheduling_options.py b/client/src/openapi_client/test/test_scheduling_options.py new file mode 100644 index 00000000..d3ff8f79 --- /dev/null +++ b/client/src/openapi_client/test/test_scheduling_options.py @@ -0,0 +1,51 @@ +""" +infrastructure-product API + +Backend service for the appliedAI infrastructure product + +The version of the OpenAPI document: 0.1.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +import unittest + +from openapi_client.models.scheduling_options import SchedulingOptions + + +class TestSchedulingOptions(unittest.TestCase): + """SchedulingOptions unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> SchedulingOptions: + """Test SchedulingOptions + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included""" + # uncomment below to create an instance of `SchedulingOptions` + """ + model = SchedulingOptions() + if include_optional: + return SchedulingOptions( + priority_class = '', + queue_name = '' + ) + else: + return SchedulingOptions( + ) + """ + + def testSchedulingOptions(self): + """Test SchedulingOptions""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + + +if __name__ == "__main__": + unittest.main() diff --git a/client/src/openapi_client/test/test_validation_error.py b/client/src/openapi_client/test/test_validation_error.py new file mode 100644 index 00000000..b4bc174b --- /dev/null +++ b/client/src/openapi_client/test/test_validation_error.py @@ -0,0 +1,59 @@ +""" +infrastructure-product API + +Backend service for the appliedAI infrastructure product + +The version of the OpenAPI document: 0.1.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +import unittest + +from openapi_client.models.validation_error import ValidationError + + +class TestValidationError(unittest.TestCase): + """ValidationError unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> ValidationError: + """Test ValidationError + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included""" + # uncomment below to create an instance of `ValidationError` + """ + model = ValidationError() + if include_optional: + return ValidationError( + loc = [ + null + ], + msg = '', + type = '' + ) + else: + return ValidationError( + loc = [ + null + ], + msg = '', + type = '', + ) + """ + + def testValidationError(self): + """Test ValidationError""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + + +if __name__ == "__main__": + unittest.main() diff --git a/client/src/openapi_client/test/test_validation_error_loc_inner.py b/client/src/openapi_client/test/test_validation_error_loc_inner.py new file mode 100644 index 00000000..73961f3d --- /dev/null +++ b/client/src/openapi_client/test/test_validation_error_loc_inner.py @@ -0,0 +1,49 @@ +""" +infrastructure-product API + +Backend service for the appliedAI infrastructure product + +The version of the OpenAPI document: 0.1.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +import unittest + +from openapi_client.models.validation_error_loc_inner import ValidationErrorLocInner + + +class TestValidationErrorLocInner(unittest.TestCase): + """ValidationErrorLocInner unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> ValidationErrorLocInner: + """Test ValidationErrorLocInner + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included""" + # uncomment below to create an instance of `ValidationErrorLocInner` + """ + model = ValidationErrorLocInner() + if include_optional: + return ValidationErrorLocInner( + ) + else: + return ValidationErrorLocInner( + ) + """ + + def testValidationErrorLocInner(self): + """Test ValidationErrorLocInner""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + + +if __name__ == "__main__": + unittest.main() diff --git a/client/src/openapi_client/test/test_workload_identifier.py b/client/src/openapi_client/test/test_workload_identifier.py new file mode 100644 index 00000000..38730c8d --- /dev/null +++ b/client/src/openapi_client/test/test_workload_identifier.py @@ -0,0 +1,59 @@ +""" +infrastructure-product API + +Backend service for the appliedAI infrastructure product + +The version of the OpenAPI document: 0.1.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +import unittest + +from openapi_client.models.workload_identifier import WorkloadIdentifier + + +class TestWorkloadIdentifier(unittest.TestCase): + """WorkloadIdentifier unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> WorkloadIdentifier: + """Test WorkloadIdentifier + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included""" + # uncomment below to create an instance of `WorkloadIdentifier` + """ + model = WorkloadIdentifier() + if include_optional: + return WorkloadIdentifier( + group = '', + version = '', + kind = '', + namespace = '', + uid = '' + ) + else: + return WorkloadIdentifier( + group = '', + version = '', + kind = '', + namespace = '', + uid = '', + ) + """ + + def testWorkloadIdentifier(self): + """Test WorkloadIdentifier""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + + +if __name__ == "__main__": + unittest.main()