From 82d0535fe9a3568a35be4d71947a4b9d7e703dbf Mon Sep 17 00:00:00 2001 From: Andrey Velichkevich Date: Sun, 27 Oct 2024 17:58:08 +0000 Subject: [PATCH] KEP-2170: Generate Python SDK for Kubeflow Training V2 (#2310) * Generate SDK models for the Training V2 APIs Signed-off-by: Andrey Velichkevich * Create pyproject.toml config Signed-off-by: Andrey Velichkevich * Remove comments Signed-off-by: Andrey Velichkevich * Fix pre-commit Signed-off-by: Andrey Velichkevich --------- Signed-off-by: Andrey Velichkevich Signed-off-by: sailesh duddupudi --- .gitignore | 1 + .pre-commit-config.yaml | 28 +- Makefile | 1 + api.v2/openapi-spec/README.md | 4 + api.v2/openapi-spec/swagger.json | 749 ++++++++++++++++++ hack/python-sdk-v2/gen-sdk.sh | 57 ++ hack/python-sdk-v2/swagger_config.json | 6 + hack/swagger-v2/main.go | 74 ++ hack/update-codegen.sh | 19 +- sdk_v2/README.md | 3 + ...beflowOrgV2alpha1ClusterTrainingRuntime.md | 14 + ...owOrgV2alpha1ClusterTrainingRuntimeList.md | 14 + .../KubeflowOrgV2alpha1ContainerOverride.md | 16 + ...2alpha1CoschedulingPodGroupPolicySource.md | 11 + .../docs/KubeflowOrgV2alpha1DatasetConfig.md | 13 + sdk_v2/docs/KubeflowOrgV2alpha1InputModel.md | 13 + .../KubeflowOrgV2alpha1JobSetTemplateSpec.md | 12 + sdk_v2/docs/KubeflowOrgV2alpha1JobStatus.md | 15 + sdk_v2/docs/KubeflowOrgV2alpha1MLPolicy.md | 13 + .../docs/KubeflowOrgV2alpha1MLPolicySource.md | 12 + .../KubeflowOrgV2alpha1MPIMLPolicySource.md | 14 + sdk_v2/docs/KubeflowOrgV2alpha1ModelConfig.md | 12 + sdk_v2/docs/KubeflowOrgV2alpha1OutputModel.md | 13 + .../docs/KubeflowOrgV2alpha1PodGroupPolicy.md | 11 + ...KubeflowOrgV2alpha1PodGroupPolicySource.md | 11 + .../KubeflowOrgV2alpha1PodSpecOverride.md | 17 + ...flowOrgV2alpha1PodSpecOverrideTargetJob.md | 10 + sdk_v2/docs/KubeflowOrgV2alpha1RuntimeRef.md | 13 + .../KubeflowOrgV2alpha1TorchElasticPolicy.md | 14 + .../KubeflowOrgV2alpha1TorchMLPolicySource.md | 12 + sdk_v2/docs/KubeflowOrgV2alpha1TrainJob.md | 15 + .../docs/KubeflowOrgV2alpha1TrainJobList.md | 14 + .../docs/KubeflowOrgV2alpha1TrainJobSpec.md | 19 + .../docs/KubeflowOrgV2alpha1TrainJobStatus.md | 12 + sdk_v2/docs/KubeflowOrgV2alpha1Trainer.md | 17 + .../KubeflowOrgV2alpha1TrainingRuntime.md | 14 + .../KubeflowOrgV2alpha1TrainingRuntimeList.md | 14 + .../KubeflowOrgV2alpha1TrainingRuntimeSpec.md | 13 + sdk_v2/kubeflow/__init__.py | 0 sdk_v2/kubeflow/training/__init__.py | 58 ++ sdk_v2/kubeflow/training/api/__init__.py | 5 + .../kubeflow/training/api/training_client.py | 18 + sdk_v2/kubeflow/training/api_client.py | 666 ++++++++++++++++ sdk_v2/kubeflow/training/configuration.py | 376 +++++++++ sdk_v2/kubeflow/training/exceptions.py | 120 +++ sdk_v2/kubeflow/training/models/__init__.py | 44 + ...w_org_v2alpha1_cluster_training_runtime.py | 202 +++++ ..._v2alpha1_cluster_training_runtime_list.py | 205 +++++ ...ubeflow_org_v2alpha1_container_override.py | 263 ++++++ ...a1_coscheduling_pod_group_policy_source.py | 122 +++ .../kubeflow_org_v2alpha1_dataset_config.py | 176 ++++ .../kubeflow_org_v2alpha1_input_model.py | 176 ++++ ...flow_org_v2alpha1_job_set_template_spec.py | 146 ++++ .../kubeflow_org_v2alpha1_job_status.py | 268 +++++++ .../models/kubeflow_org_v2alpha1_ml_policy.py | 174 ++++ .../kubeflow_org_v2alpha1_ml_policy_source.py | 146 ++++ .../kubeflow_org_v2alpha1_model_config.py | 146 ++++ ...beflow_org_v2alpha1_mpiml_policy_source.py | 206 +++++ .../kubeflow_org_v2alpha1_output_model.py | 176 ++++ .../kubeflow_org_v2alpha1_pod_group_policy.py | 120 +++ ...ow_org_v2alpha1_pod_group_policy_source.py | 120 +++ ...kubeflow_org_v2alpha1_pod_spec_override.py | 291 +++++++ ...g_v2alpha1_pod_spec_override_target_job.py | 123 +++ .../kubeflow_org_v2alpha1_runtime_ref.py | 179 +++++ ...eflow_org_v2alpha1_torch_elastic_policy.py | 206 +++++ ...low_org_v2alpha1_torch_ml_policy_source.py | 148 ++++ .../models/kubeflow_org_v2alpha1_train_job.py | 228 ++++++ .../kubeflow_org_v2alpha1_train_job_list.py | 205 +++++ .../kubeflow_org_v2alpha1_train_job_spec.py | 339 ++++++++ .../kubeflow_org_v2alpha1_train_job_status.py | 150 ++++ .../models/kubeflow_org_v2alpha1_trainer.py | 288 +++++++ .../kubeflow_org_v2alpha1_training_runtime.py | 202 +++++ ...flow_org_v2alpha1_training_runtime_list.py | 205 +++++ ...flow_org_v2alpha1_training_runtime_spec.py | 173 ++++ sdk_v2/kubeflow/training/rest.py | 291 +++++++ sdk_v2/pyproject.toml | 44 + 76 files changed, 8295 insertions(+), 30 deletions(-) create mode 100644 api.v2/openapi-spec/README.md create mode 100644 api.v2/openapi-spec/swagger.json create mode 100755 hack/python-sdk-v2/gen-sdk.sh create mode 100644 hack/python-sdk-v2/swagger_config.json create mode 100644 hack/swagger-v2/main.go create mode 100644 sdk_v2/README.md create mode 100644 sdk_v2/docs/KubeflowOrgV2alpha1ClusterTrainingRuntime.md create mode 100644 sdk_v2/docs/KubeflowOrgV2alpha1ClusterTrainingRuntimeList.md create mode 100644 sdk_v2/docs/KubeflowOrgV2alpha1ContainerOverride.md create mode 100644 sdk_v2/docs/KubeflowOrgV2alpha1CoschedulingPodGroupPolicySource.md create mode 100644 sdk_v2/docs/KubeflowOrgV2alpha1DatasetConfig.md create mode 100644 sdk_v2/docs/KubeflowOrgV2alpha1InputModel.md create mode 100644 sdk_v2/docs/KubeflowOrgV2alpha1JobSetTemplateSpec.md create mode 100644 sdk_v2/docs/KubeflowOrgV2alpha1JobStatus.md create mode 100644 sdk_v2/docs/KubeflowOrgV2alpha1MLPolicy.md create mode 100644 sdk_v2/docs/KubeflowOrgV2alpha1MLPolicySource.md create mode 100644 sdk_v2/docs/KubeflowOrgV2alpha1MPIMLPolicySource.md create mode 100644 sdk_v2/docs/KubeflowOrgV2alpha1ModelConfig.md create mode 100644 sdk_v2/docs/KubeflowOrgV2alpha1OutputModel.md create mode 100644 sdk_v2/docs/KubeflowOrgV2alpha1PodGroupPolicy.md create mode 100644 sdk_v2/docs/KubeflowOrgV2alpha1PodGroupPolicySource.md create mode 100644 sdk_v2/docs/KubeflowOrgV2alpha1PodSpecOverride.md create mode 100644 sdk_v2/docs/KubeflowOrgV2alpha1PodSpecOverrideTargetJob.md create mode 100644 sdk_v2/docs/KubeflowOrgV2alpha1RuntimeRef.md create mode 100644 sdk_v2/docs/KubeflowOrgV2alpha1TorchElasticPolicy.md create mode 100644 sdk_v2/docs/KubeflowOrgV2alpha1TorchMLPolicySource.md create mode 100644 sdk_v2/docs/KubeflowOrgV2alpha1TrainJob.md create mode 100644 sdk_v2/docs/KubeflowOrgV2alpha1TrainJobList.md create mode 100644 sdk_v2/docs/KubeflowOrgV2alpha1TrainJobSpec.md create mode 100644 sdk_v2/docs/KubeflowOrgV2alpha1TrainJobStatus.md create mode 100644 sdk_v2/docs/KubeflowOrgV2alpha1Trainer.md create mode 100644 sdk_v2/docs/KubeflowOrgV2alpha1TrainingRuntime.md create mode 100644 sdk_v2/docs/KubeflowOrgV2alpha1TrainingRuntimeList.md create mode 100644 sdk_v2/docs/KubeflowOrgV2alpha1TrainingRuntimeSpec.md create mode 100644 sdk_v2/kubeflow/__init__.py create mode 100644 sdk_v2/kubeflow/training/__init__.py create mode 100644 sdk_v2/kubeflow/training/api/__init__.py create mode 100644 sdk_v2/kubeflow/training/api/training_client.py create mode 100644 sdk_v2/kubeflow/training/api_client.py create mode 100644 sdk_v2/kubeflow/training/configuration.py create mode 100644 sdk_v2/kubeflow/training/exceptions.py create mode 100644 sdk_v2/kubeflow/training/models/__init__.py create mode 100644 sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_cluster_training_runtime.py create mode 100644 sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_cluster_training_runtime_list.py create mode 100644 sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_container_override.py create mode 100644 sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_coscheduling_pod_group_policy_source.py create mode 100644 sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_dataset_config.py create mode 100644 sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_input_model.py create mode 100644 sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_job_set_template_spec.py create mode 100644 sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_job_status.py create mode 100644 sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_ml_policy.py create mode 100644 sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_ml_policy_source.py create mode 100644 sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_model_config.py create mode 100644 sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_mpiml_policy_source.py create mode 100644 sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_output_model.py create mode 100644 sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_pod_group_policy.py create mode 100644 sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_pod_group_policy_source.py create mode 100644 sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_pod_spec_override.py create mode 100644 sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_pod_spec_override_target_job.py create mode 100644 sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_runtime_ref.py create mode 100644 sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_torch_elastic_policy.py create mode 100644 sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_torch_ml_policy_source.py create mode 100644 sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_train_job.py create mode 100644 sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_train_job_list.py create mode 100644 sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_train_job_spec.py create mode 100644 sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_train_job_status.py create mode 100644 sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_trainer.py create mode 100644 sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_training_runtime.py create mode 100644 sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_training_runtime_list.py create mode 100644 sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_training_runtime_spec.py create mode 100644 sdk_v2/kubeflow/training/rest.py create mode 100644 sdk_v2/pyproject.toml diff --git a/.gitignore b/.gitignore index a839c138ce..4caea5b1f6 100644 --- a/.gitignore +++ b/.gitignore @@ -42,6 +42,7 @@ examples/.ipynb_checkpoints/ # openapi-codegen tools and auto generated files but useless hack/python-sdk/openapi-generator-cli.jar +hack/python-sdk-v2/openapi-generator-cli.jar # Coverage cover.out diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d45329b3d4..9eaa555f74 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,30 +17,10 @@ repos: rev: 24.2.0 hooks: - id: black - files: (sdk|examples)/.* - exclude: | - (?x)^( - /*kubeflow_org_v1*| - __init__.py| - api_client.py| - configuration.py| - exceptions.py| - rest.py - )$ - repo: https://github.com/pycqa/flake8 rev: 7.1.1 hooks: - id: flake8 - files: ^(sdk|examples)/.*$ - exclude: | - (?x)^( - .*kubeflow_org_v1.*| - __init__\.py| - api_client\.py| - configuration\.py| - exceptions\.py| - rest\.py - )$ exclude: | (?x)^( pkg/apis/kubeflow.org/v1/openapi_generated.go| @@ -48,11 +28,15 @@ exclude: | pkg/client/.*| test_job/apis/test_job/v1/.*generated.*.go| test_job/client/.*| + docs/api/.*| + hack/python-sdk/post_gen.py| sdk/python/kubeflow/training/[^/]*.py| sdk/python/kubeflow/training/models/.*| sdk/python/test/.*| - docs/api/.*| sdk/python/docs/.*| sdk/python/.openapi-generator/VERSION| - sdk/python/kubeflow/__init__.py + sdk/python/kubeflow/__init__.py| + sdk_v2/kubeflow/training/[^/]*.py| + sdk_v2/kubeflow/training/models/.*| + sdk_v2/docs/.* )$ diff --git a/Makefile b/Makefile index e90eecd410..df7f4969fa 100644 --- a/Makefile +++ b/Makefile @@ -51,6 +51,7 @@ generate: controller-gen ## Generate apidoc, sdk and code containing DeepCopy, D $(CONTROLLER_GEN) object:headerFile="hack/boilerplate/boilerplate.go.txt" paths="./pkg/apis/..." hack/update-codegen.sh hack/python-sdk/gen-sdk.sh + hack/python-sdk-v2/gen-sdk.sh $(MAKE) apidoc apidoc: diff --git a/api.v2/openapi-spec/README.md b/api.v2/openapi-spec/README.md new file mode 100644 index 0000000000..c116d0004c --- /dev/null +++ b/api.v2/openapi-spec/README.md @@ -0,0 +1,4 @@ +# Kubeflow Training V2 OpenAPI Specification + +This folder contains an [OpenAPI specification](https://github.com/OAI/OpenAPI-Specification) +for Training V2 API. diff --git a/api.v2/openapi-spec/swagger.json b/api.v2/openapi-spec/swagger.json new file mode 100644 index 0000000000..eadb6bfc06 --- /dev/null +++ b/api.v2/openapi-spec/swagger.json @@ -0,0 +1,749 @@ +{ + "swagger": "2.0", + "info": { + "title": "Kubeflow Training OpenAPI Spec" + }, + "paths": {}, + "definitions": { + "kubeflow.org.v2alpha1.ClusterTrainingRuntime": { + "description": "ClusterTrainingRuntime represents a training runtime which can be referenced as part of `runtimeRef` API in TrainJob. This resource is a cluster-scoped and can be referenced by TrainJob that created in *any* namespace.", + "type": "object", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard object's metadata.", + "default": {}, + "$ref": "#/definitions/v1.ObjectMeta" + }, + "spec": { + "description": "Specification of the desired ClusterTrainingRuntime.", + "default": {}, + "$ref": "#/definitions/kubeflow.org.v2alpha1.TrainingRuntimeSpec" + } + } + }, + "kubeflow.org.v2alpha1.ClusterTrainingRuntimeList": { + "description": "ClusterTrainingRuntimeList is a collection of cluster training runtimes.", + "type": "object", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "List of ClusterTrainingRuntimes.", + "type": "array", + "items": { + "default": {}, + "$ref": "#/definitions/kubeflow.org.v2alpha1.ClusterTrainingRuntime" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard list metadata.", + "default": {}, + "$ref": "#/definitions/v1.ListMeta" + } + } + }, + "kubeflow.org.v2alpha1.ContainerOverride": { + "description": "ContainerOverride represents parameters that can be overridden using PodSpecOverrides. Parameters from the Trainer, DatasetConfig, and ModelConfig will take precedence.", + "type": "object", + "required": [ + "name" + ], + "properties": { + "args": { + "description": "Arguments to the entrypoint for the training container.", + "type": "array", + "items": { + "type": "string", + "default": "" + } + }, + "command": { + "description": "Entrypoint commands for the training container.", + "type": "array", + "items": { + "type": "string", + "default": "" + } + }, + "env": { + "description": "List of environment variables to set in the container. These values will be merged with the TrainingRuntime's environments.", + "type": "array", + "items": { + "default": {}, + "$ref": "#/definitions/v1.EnvVar" + } + }, + "envFrom": { + "description": "List of sources to populate environment variables in the container. These values will be merged with the TrainingRuntime's environments.", + "type": "array", + "items": { + "default": {}, + "$ref": "#/definitions/v1.EnvFromSource" + } + }, + "name": { + "description": "Name for the container. TrainingRuntime must have this container.", + "type": "string", + "default": "" + }, + "volumeMounts": { + "description": "Pod volumes to mount into the container's filesystem.", + "type": "array", + "items": { + "default": {}, + "$ref": "#/definitions/v1.VolumeMount" + } + } + } + }, + "kubeflow.org.v2alpha1.CoschedulingPodGroupPolicySource": { + "description": "CoschedulingPodGroupPolicySource represents configuration for coscheduling plugin. The number of min members in the PodGroupSpec is always equal to the number of nodes.", + "type": "object", + "properties": { + "scheduleTimeoutSeconds": { + "description": "Time threshold to schedule PodGroup for gang-scheduling. If the scheduling timeout is equal to 0, the default value is used. Defaults to 60 seconds.", + "type": "integer", + "format": "int32" + } + } + }, + "kubeflow.org.v2alpha1.DatasetConfig": { + "description": "DatasetConfig represents the desired dataset configuration. When this API is used, the training runtime must have the `dataset-initializer` container in the `Initializer` Job.", + "type": "object", + "properties": { + "env": { + "description": "List of environment variables to set in the dataset initializer container. These values will be merged with the TrainingRuntime's dataset initializer environments.", + "type": "array", + "items": { + "default": {}, + "$ref": "#/definitions/v1.EnvVar" + } + }, + "secretRef": { + "description": "Reference to the TrainJob's secrets to download dataset.", + "$ref": "#/definitions/v1.SecretReference" + }, + "storageUri": { + "description": "Storage uri for the dataset provider.", + "type": "string" + } + } + }, + "kubeflow.org.v2alpha1.InputModel": { + "description": "InputModel represents the desired pre-trained model configuration.", + "type": "object", + "properties": { + "env": { + "description": "List of environment variables to set in the model initializer container. These values will be merged with the TrainingRuntime's model initializer environments.", + "type": "array", + "items": { + "default": {}, + "$ref": "#/definitions/v1.EnvVar" + } + }, + "secretRef": { + "description": "Reference to the TrainJob's secrets to download model.", + "$ref": "#/definitions/v1.SecretReference" + }, + "storageUri": { + "description": "Storage uri for the model provider.", + "type": "string" + } + } + }, + "kubeflow.org.v2alpha1.JobSetTemplateSpec": { + "description": "JobSetTemplateSpec represents a template of the desired JobSet.", + "type": "object", + "properties": { + "metadata": { + "description": "Metadata for custom JobSet's labels and annotations. JobSet name and namespace is equal to the TrainJob's name and namespace.", + "default": {}, + "$ref": "#/definitions/v1.ObjectMeta" + }, + "spec": { + "description": "Specification of the desired JobSet which will be created from TrainJob.", + "default": {}, + "$ref": "#/definitions/sigs.k8s.io.jobset.api.jobset.v1alpha2.JobSetSpec" + } + } + }, + "kubeflow.org.v2alpha1.JobStatus": { + "type": "object", + "required": [ + "name", + "ready", + "succeeded", + "failed", + "active", + "suspended" + ], + "properties": { + "active": { + "description": "Active is the number of child Jobs with at least 1 pod in a running or pending state which are not marked for deletion.", + "type": "integer", + "format": "int32", + "default": 0 + }, + "failed": { + "description": "Failed is the number of failed child Jobs.", + "type": "integer", + "format": "int32", + "default": 0 + }, + "name": { + "description": "Name of the child Job.", + "type": "string", + "default": "" + }, + "ready": { + "description": "Ready is the number of child Jobs where the number of ready pods and completed pods is greater than or equal to the total expected pod count for the child Job.", + "type": "integer", + "format": "int32", + "default": 0 + }, + "succeeded": { + "description": "Succeeded is the number of successfully completed child Jobs.", + "type": "integer", + "format": "int32", + "default": 0 + }, + "suspended": { + "description": "Suspended is the number of child Jobs which are in a suspended state.", + "type": "integer", + "format": "int32", + "default": 0 + } + } + }, + "kubeflow.org.v2alpha1.MLPolicy": { + "description": "MLPolicy represents configuration for the model trining with ML-specific parameters.", + "type": "object", + "properties": { + "mpi": { + "description": "Configuration for the MPI Runtime.", + "$ref": "#/definitions/kubeflow.org.v2alpha1.MPIMLPolicySource" + }, + "numNodes": { + "description": "Number of training nodes. Defaults to 1.", + "type": "integer", + "format": "int32" + }, + "torch": { + "description": "Configuration for the PyTorch runtime.", + "$ref": "#/definitions/kubeflow.org.v2alpha1.TorchMLPolicySource" + } + } + }, + "kubeflow.org.v2alpha1.MLPolicySource": { + "description": "MLPolicySource represents the runtime-specific configuration for various technologies. One of the following specs can be set.", + "type": "object", + "properties": { + "mpi": { + "description": "Configuration for the MPI Runtime.", + "$ref": "#/definitions/kubeflow.org.v2alpha1.MPIMLPolicySource" + }, + "torch": { + "description": "Configuration for the PyTorch runtime.", + "$ref": "#/definitions/kubeflow.org.v2alpha1.TorchMLPolicySource" + } + } + }, + "kubeflow.org.v2alpha1.MPIMLPolicySource": { + "description": "MPIMLPolicySource represents a MPI runtime configuration.", + "type": "object", + "properties": { + "SSHAuthMountPath": { + "description": "Directory where SSH keys are mounted.", + "type": "string" + }, + "mpiImplementation": { + "description": "Implementation name for the MPI to create the appropriate hostfile. Defaults to OpenMPI.", + "type": "string" + }, + "numProcPerNode": { + "description": "Number of processes per node. This value is equal to the number of slots for each node in the hostfile.", + "type": "integer", + "format": "int32" + }, + "runLauncherAsNode": { + "description": "Whether to run training process on the launcher Job. Defaults to false.", + "type": "boolean" + } + } + }, + "kubeflow.org.v2alpha1.ModelConfig": { + "description": "ModelConfig represents the desired model configuration.", + "type": "object", + "properties": { + "input": { + "description": "Configuration of the pre-trained model. When this API is used, the training runtime must have the `model-initializer` container in the `Initializer` Job.", + "$ref": "#/definitions/kubeflow.org.v2alpha1.InputModel" + }, + "output": { + "description": "Configuration of the trained model. When this API is used, the training runtime must have the `model-exporter` container in the `Exporter` Job.", + "$ref": "#/definitions/kubeflow.org.v2alpha1.OutputModel" + } + } + }, + "kubeflow.org.v2alpha1.OutputModel": { + "description": "OutputModel represents the desired trained model configuration.", + "type": "object", + "properties": { + "env": { + "description": "List of environment variables to set in the model exporter container. These values will be merged with the TrainingRuntime's model exporter environments.", + "type": "array", + "items": { + "default": {}, + "$ref": "#/definitions/v1.EnvVar" + } + }, + "secretRef": { + "description": "Reference to the TrainJob's secrets to export model.", + "$ref": "#/definitions/v1.SecretReference" + }, + "storageUri": { + "description": "Storage uri for the model exporter.", + "type": "string" + } + } + }, + "kubeflow.org.v2alpha1.PodGroupPolicy": { + "description": "PodGroupPolicy represents a PodGroup configuration for gang-scheduling.", + "type": "object", + "properties": { + "coscheduling": { + "description": "Coscheduling plugin from the Kubernetes scheduler-plugins for gang-scheduling.", + "$ref": "#/definitions/kubeflow.org.v2alpha1.CoschedulingPodGroupPolicySource" + } + } + }, + "kubeflow.org.v2alpha1.PodGroupPolicySource": { + "description": "PodGroupPolicySource represents supported plugins for gang-scheduling. Only one of its members may be specified.", + "type": "object", + "properties": { + "coscheduling": { + "description": "Coscheduling plugin from the Kubernetes scheduler-plugins for gang-scheduling.", + "$ref": "#/definitions/kubeflow.org.v2alpha1.CoschedulingPodGroupPolicySource" + } + } + }, + "kubeflow.org.v2alpha1.PodSpecOverride": { + "description": "PodSpecOverride represents the custom overrides that will be applied for the TrainJob's resources.", + "type": "object", + "required": [ + "targetJobs" + ], + "properties": { + "containers": { + "description": "Overrides for the containers in the desired job templates.", + "type": "array", + "items": { + "default": {}, + "$ref": "#/definitions/kubeflow.org.v2alpha1.ContainerOverride" + } + }, + "initContainers": { + "description": "Overrides for the init container in the desired job templates.", + "type": "array", + "items": { + "default": {}, + "$ref": "#/definitions/kubeflow.org.v2alpha1.ContainerOverride" + } + }, + "nodeSelector": { + "description": "Override for the node selector to place Pod on the specific mode.", + "type": "object", + "additionalProperties": { + "type": "string", + "default": "" + } + }, + "serviceAccountName": { + "description": "Override for the service account.", + "type": "string" + }, + "targetJobs": { + "description": "TrainJobs is the training job replicas in the training runtime template to apply the overrides.", + "type": "array", + "items": { + "default": {}, + "$ref": "#/definitions/kubeflow.org.v2alpha1.PodSpecOverrideTargetJob" + } + }, + "tolerations": { + "description": "Override for the Pod's tolerations.", + "type": "array", + "items": { + "default": {}, + "$ref": "#/definitions/v1.Toleration" + } + }, + "volumes": { + "description": "Overrides for the Pod volume configuration.", + "type": "array", + "items": { + "default": {}, + "$ref": "#/definitions/v1.Volume" + } + } + } + }, + "kubeflow.org.v2alpha1.PodSpecOverrideTargetJob": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "name": { + "description": "Name is the target training job name for which the PodSpec is overridden.", + "type": "string", + "default": "" + } + } + }, + "kubeflow.org.v2alpha1.RuntimeRef": { + "description": "RuntimeRef represents the reference to the existing training runtime.", + "type": "object", + "required": [ + "name" + ], + "properties": { + "apiGroup": { + "description": "APIGroup of the runtime being referenced. Defaults to `kubeflow.org`.", + "type": "string" + }, + "kind": { + "description": "Kind of the runtime being referenced. Defaults to ClusterTrainingRuntime.", + "type": "string" + }, + "name": { + "description": "Name of the runtime being referenced. When namespaced-scoped TrainingRuntime is used, the TrainJob must have the same namespace as the deployed runtime.", + "type": "string", + "default": "" + } + } + }, + "kubeflow.org.v2alpha1.TorchElasticPolicy": { + "description": "TorchElasticPolicy represents a configuration for the PyTorch elastic training. If this policy is set, the `.spec.numNodes` parameter must be omitted, since min and max node is used to configure the `torchrun` CLI argument: `--nnodes=minNodes:maxNodes`. Only `c10d` backend is supported for the Rendezvous communication.", + "type": "object", + "properties": { + "maxNodes": { + "description": "Upper limit for the number of nodes to which training job can scale up.", + "type": "integer", + "format": "int32" + }, + "maxRestarts": { + "description": "How many times the training job can be restarted. This value is inserted into the `--max-restarts` argument of the `torchrun` CLI and the `.spec.failurePolicy.maxRestarts` parameter of the training Job.", + "type": "integer", + "format": "int32" + }, + "metrics": { + "description": "Specification which are used to calculate the desired number of nodes. See the individual metric source types for more information about how each type of metric must respond. The HPA will be created to perform auto-scaling.", + "type": "array", + "items": { + "default": {}, + "$ref": "#/definitions/k8s.io.api.autoscaling.v2.MetricSpec" + } + }, + "minNodes": { + "description": "Lower limit for the number of nodes to which training job can scale down.", + "type": "integer", + "format": "int32" + } + } + }, + "kubeflow.org.v2alpha1.TorchMLPolicySource": { + "description": "TorchMLPolicySource represents a PyTorch runtime configuration.", + "type": "object", + "properties": { + "elasticPolicy": { + "description": "Elastic policy for the PyTorch training.", + "$ref": "#/definitions/kubeflow.org.v2alpha1.TorchElasticPolicy" + }, + "numProcPerNode": { + "description": "Number of processes per node. This value is inserted into the `--nproc-per-node` argument of the `torchrun` CLI. Supported values: `auto`, `cpu`, `gpu`, or int value. Defaults to `auto`.", + "type": "string" + } + } + }, + "kubeflow.org.v2alpha1.TrainJob": { + "description": "TrainJob represents configuration of a training job.", + "type": "object", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard object's metadata.", + "default": {}, + "$ref": "#/definitions/v1.ObjectMeta" + }, + "spec": { + "description": "Specification of the desired TrainJob.", + "default": {}, + "$ref": "#/definitions/kubeflow.org.v2alpha1.TrainJobSpec" + }, + "status": { + "description": "Current status of TrainJob.", + "default": {}, + "$ref": "#/definitions/kubeflow.org.v2alpha1.TrainJobStatus" + } + } + }, + "kubeflow.org.v2alpha1.TrainJobList": { + "description": "TrainJobList is a collection of training jobs.", + "type": "object", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "List of TrainJobs.", + "type": "array", + "items": { + "default": {}, + "$ref": "#/definitions/kubeflow.org.v2alpha1.TrainJob" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard list metadata.", + "default": {}, + "$ref": "#/definitions/v1.ListMeta" + } + } + }, + "kubeflow.org.v2alpha1.TrainJobSpec": { + "description": "TrainJobSpec represents specification of the desired TrainJob.", + "type": "object", + "required": [ + "runtimeRef" + ], + "properties": { + "annotations": { + "description": "Annotations to apply for the derivative JobSet and Jobs. They will be merged with the TrainingRuntime values.", + "type": "object", + "additionalProperties": { + "type": "string", + "default": "" + } + }, + "datasetConfig": { + "description": "Configuration of the training dataset.", + "$ref": "#/definitions/kubeflow.org.v2alpha1.DatasetConfig" + }, + "labels": { + "description": "Labels to apply for the derivative JobSet and Jobs. They will be merged with the TrainingRuntime values.", + "type": "object", + "additionalProperties": { + "type": "string", + "default": "" + } + }, + "managedBy": { + "description": "ManagedBy is used to indicate the controller or entity that manages a TrainJob. The value must be either an empty, `kubeflow.org/trainjob-controller` or `kueue.x-k8s.io/multikueue`. The built-in TrainJob controller reconciles TrainJob which don't have this field at all or the field value is the reserved string `kubeflow.org/trainjob-controller`, but delegates reconciling TrainJobs with a 'kueue.x-k8s.io/multikueue' to the Kueue. The field is immutable. Defaults to `kubeflow.org/trainjob-controller`", + "type": "string" + }, + "modelConfig": { + "description": "Configuration of the pre-trained and trained model.", + "$ref": "#/definitions/kubeflow.org.v2alpha1.ModelConfig" + }, + "podSpecOverrides": { + "description": "Custom overrides for the training runtime.", + "type": "array", + "items": { + "default": {}, + "$ref": "#/definitions/kubeflow.org.v2alpha1.PodSpecOverride" + } + }, + "runtimeRef": { + "description": "Reference to the training runtime. The field is immutable.", + "default": {}, + "$ref": "#/definitions/kubeflow.org.v2alpha1.RuntimeRef" + }, + "suspend": { + "description": "Whether the controller should suspend the running TrainJob. Defaults to false.", + "type": "boolean" + }, + "trainer": { + "description": "Configuration of the desired trainer.", + "$ref": "#/definitions/kubeflow.org.v2alpha1.Trainer" + } + } + }, + "kubeflow.org.v2alpha1.TrainJobStatus": { + "description": "TrainJobStatus represents the current status of TrainJob.", + "type": "object", + "properties": { + "conditions": { + "description": "Conditions for the TrainJob.", + "type": "array", + "items": { + "default": {}, + "$ref": "#/definitions/v1.Condition" + } + }, + "jobsStatus": { + "description": "JobsStatus tracks the child Jobs in TrainJob.", + "type": "array", + "items": { + "default": {}, + "$ref": "#/definitions/kubeflow.org.v2alpha1.JobStatus" + } + } + } + }, + "kubeflow.org.v2alpha1.Trainer": { + "description": "Trainer represents the desired trainer configuration. Every training runtime contains `trainer` container which represents Trainer.", + "type": "object", + "properties": { + "args": { + "description": "Arguments to the entrypoint for the training container.", + "type": "array", + "items": { + "type": "string", + "default": "" + } + }, + "command": { + "description": "Entrypoint commands for the training container.", + "type": "array", + "items": { + "type": "string", + "default": "" + } + }, + "env": { + "description": "List of environment variables to set in the training container. These values will be merged with the TrainingRuntime's trainer environments.", + "type": "array", + "items": { + "default": {}, + "$ref": "#/definitions/v1.EnvVar" + } + }, + "image": { + "description": "Docker image for the training container.", + "type": "string" + }, + "numNodes": { + "description": "Number of training nodes.", + "type": "integer", + "format": "int32" + }, + "numProcPerNode": { + "description": "Number of processes/workers/slots on every training node. For the Torch runtime: `auto`, `cpu`, `gpu`, or int value can be set. For the MPI runtime only int value can be set.", + "type": "string" + }, + "resourcesPerNode": { + "description": "Compute resources for each training node.", + "$ref": "#/definitions/v1.ResourceRequirements" + } + } + }, + "kubeflow.org.v2alpha1.TrainingRuntime": { + "description": "TrainingRuntime represents a training runtime which can be referenced as part of `runtimeRef` API in TrainJob. This resource is a namespaced-scoped and can be referenced by TrainJob that created in the *same* namespace as the TrainingRuntime.", + "type": "object", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard object's metadata.", + "default": {}, + "$ref": "#/definitions/v1.ObjectMeta" + }, + "spec": { + "description": "Specification of the desired TrainingRuntime.", + "default": {}, + "$ref": "#/definitions/kubeflow.org.v2alpha1.TrainingRuntimeSpec" + } + } + }, + "kubeflow.org.v2alpha1.TrainingRuntimeList": { + "description": "TrainingRuntimeList is a collection of training runtimes.", + "type": "object", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "type": "string" + }, + "items": { + "description": "List of TrainingRuntimes.", + "type": "array", + "items": { + "default": {}, + "$ref": "#/definitions/kubeflow.org.v2alpha1.TrainingRuntime" + } + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "description": "Standard list metadata.", + "default": {}, + "$ref": "#/definitions/v1.ListMeta" + } + } + }, + "kubeflow.org.v2alpha1.TrainingRuntimeSpec": { + "description": "TrainingRuntimeSpec represents a specification of the desired training runtime.", + "type": "object", + "required": [ + "template" + ], + "properties": { + "mlPolicy": { + "description": "Configuration for the model training with ML-specific parameters.", + "$ref": "#/definitions/kubeflow.org.v2alpha1.MLPolicy" + }, + "podGroupPolicy": { + "description": "Configuration for the PodGroup to enable gang-scheduling via supported plugins.", + "$ref": "#/definitions/kubeflow.org.v2alpha1.PodGroupPolicy" + }, + "template": { + "description": "JobSet template which will be used by TrainJob.", + "default": {}, + "$ref": "#/definitions/kubeflow.org.v2alpha1.JobSetTemplateSpec" + } + } + } + } +} diff --git a/hack/python-sdk-v2/gen-sdk.sh b/hack/python-sdk-v2/gen-sdk.sh new file mode 100755 index 0000000000..981dd232d0 --- /dev/null +++ b/hack/python-sdk-v2/gen-sdk.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash + +# Copyright 2024 The Kubeflow Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Run this script from the root location: `make generate` + +set -o errexit +set -o nounset + +# TODO (andreyvelich): Read this data from the global VERSION file. +SDK_VERSION="2.0.0" + +SDK_OUTPUT_PATH="sdk_v2" + +SWAGGER_JAR_URL="https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/4.3.1/openapi-generator-cli-4.3.1.jar" +SWAGGER_CODEGEN_JAR="hack/python-sdk-v2/openapi-generator-cli.jar" +SWAGGER_CODEGEN_CONF="hack/python-sdk-v2/swagger_config.json" +SWAGGER_CODEGEN_FILE="api.v2/openapi-spec/swagger.json" + +if [[ ! -f "$SWAGGER_CODEGEN_JAR" ]]; then + echo "Downloading the openapi-generator-cli JAR package to generate SDK" + wget -O "${SWAGGER_CODEGEN_JAR}" ${SWAGGER_JAR_URL} +fi + +echo "Generating Python SDK for Training Operator V2 ..." +java -jar "${SWAGGER_CODEGEN_JAR}" generate -i "${SWAGGER_CODEGEN_FILE}" -g python -o "${SDK_OUTPUT_PATH}" -c "${SWAGGER_CODEGEN_CONF}" -p=packageVersion="${SDK_VERSION}" + +echo "Removing unused files for the Python SDK" +git clean -f ${SDK_OUTPUT_PATH}/.openapi-generator +git clean -f ${SDK_OUTPUT_PATH}/.gitignore +git clean -f ${SDK_OUTPUT_PATH}/.gitlab-ci.yml +git clean -f ${SDK_OUTPUT_PATH}/git_push.sh +git clean -f ${SDK_OUTPUT_PATH}/.openapi-generator-ignore +git clean -f ${SDK_OUTPUT_PATH}/.travis.yml +git clean -f ${SDK_OUTPUT_PATH}/requirements.txt +git clean -f ${SDK_OUTPUT_PATH}/setup.cfg +git clean -f ${SDK_OUTPUT_PATH}/setup.py +git clean -f ${SDK_OUTPUT_PATH}/test-requirements.txt +git clean -f ${SDK_OUTPUT_PATH}/tox.ini + +# TODO (andreyvelich): Discuss if we should use these test files. +git clean -f ${SDK_OUTPUT_PATH}/test + +# Revert the README since it is manually created. +git checkout ${SDK_OUTPUT_PATH}/README.md diff --git a/hack/python-sdk-v2/swagger_config.json b/hack/python-sdk-v2/swagger_config.json new file mode 100644 index 0000000000..0f440e8710 --- /dev/null +++ b/hack/python-sdk-v2/swagger_config.json @@ -0,0 +1,6 @@ +{ + "packageName": "kubeflow.training", + "typeMappings": { + "V1Time": "datetime" + } +} diff --git a/hack/swagger-v2/main.go b/hack/swagger-v2/main.go new file mode 100644 index 0000000000..eb30b99900 --- /dev/null +++ b/hack/swagger-v2/main.go @@ -0,0 +1,74 @@ +/* +Copyright 2024 The Kubeflow Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package main + +import ( + "encoding/json" + "fmt" + "strings" + + "k8s.io/klog/v2" + "k8s.io/kube-openapi/pkg/common" + "k8s.io/kube-openapi/pkg/validation/spec" + + kubeflowv2 "github.com/kubeflow/training-operator/pkg/apis/kubeflow.org/v2alpha1" +) + +// Generate Kubeflow Training OpenAPI specification. +func main() { + + var oAPIDefs = map[string]common.OpenAPIDefinition{} + defs := spec.Definitions{} + + refCallback := func(name string) spec.Ref { + return spec.MustCreateRef("#/definitions/" + common.EscapeJsonPointer(swaggify(name))) + } + + for k, v := range kubeflowv2.GetOpenAPIDefinitions(refCallback) { + oAPIDefs[k] = v + } + + for defName, val := range oAPIDefs { + defs[swaggify(defName)] = val.Schema + } + swagger := spec.Swagger{ + SwaggerProps: spec.SwaggerProps{ + Swagger: "2.0", + Definitions: defs, + Paths: &spec.Paths{Paths: map[string]spec.PathItem{}}, + Info: &spec.Info{ + InfoProps: spec.InfoProps{ + Title: "Kubeflow Training OpenAPI Spec", + }, + }, + }, + } + jsonBytes, err := json.MarshalIndent(swagger, "", " ") + if err != nil { + klog.Fatal(err.Error()) + } + fmt.Println(string(jsonBytes)) +} + +func swaggify(name string) string { + name = strings.Replace(name, "github.com/kubeflow/training-operator/pkg/apis/", "", -1) + name = strings.Replace(name, "k8s.io/api/core/", "", -1) + name = strings.Replace(name, "k8s.io/apimachinery/pkg/apis/meta/", "", -1) + name = strings.Replace(name, "k8s.io/apimachinery/pkg/api/resource", "", -1) + name = strings.Replace(name, "/", ".", -1) + return name +} diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index eadecc7414..a9ffcd0151 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -30,16 +30,16 @@ SCRIPT_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. ROOT_PKG=github.com/kubeflow/training-operator GET_PKG_LOCATION() { - pkg_name="${1:-}" + pkg_name="${1:-}" - pkg_location="$(go list -m -f '{{.Dir}}' "${pkg_name}" 2>/dev/null)" - if [ "${pkg_location}" = "" ]; then - echo "${pkg_name} is missing. Running 'go mod download'." + pkg_location="$(go list -m -f '{{.Dir}}' "${pkg_name}" 2>/dev/null)" + if [ "${pkg_location}" = "" ]; then + echo "${pkg_name} is missing. Running 'go mod download'." - go mod download - pkg_location=$(go list -m -f '{{.Dir}}' "${pkg_name}") - fi - echo "${pkg_location}" + go mod download + pkg_location=$(go list -m -f '{{.Dir}}' "${pkg_name}") + fi + echo "${pkg_location}" } # Grab code-generator version from go.sum @@ -113,6 +113,9 @@ echo "Generating OpenAPI specification for kubeflow.org/v2alpha1" --go-header-file hack/boilerplate/boilerplate.go.txt "$@" \ --output-base "${TEMP_DIR}" +echo "Generate OpenAPI Swagger for kubeflow.org/v2alpha1" +go run hack/swagger-v2/main.go >api.v2/openapi-spec/swagger.json + cd - >/dev/null # Copy everything back. diff --git a/sdk_v2/README.md b/sdk_v2/README.md new file mode 100644 index 0000000000..7f43091905 --- /dev/null +++ b/sdk_v2/README.md @@ -0,0 +1,3 @@ +# Kubeflow Training V2 SDK + +Work in progress... diff --git a/sdk_v2/docs/KubeflowOrgV2alpha1ClusterTrainingRuntime.md b/sdk_v2/docs/KubeflowOrgV2alpha1ClusterTrainingRuntime.md new file mode 100644 index 0000000000..c66ce33a67 --- /dev/null +++ b/sdk_v2/docs/KubeflowOrgV2alpha1ClusterTrainingRuntime.md @@ -0,0 +1,14 @@ +# KubeflowOrgV2alpha1ClusterTrainingRuntime + +ClusterTrainingRuntime represents a training runtime which can be referenced as part of `runtimeRef` API in TrainJob. This resource is a cluster-scoped and can be referenced by TrainJob that created in *any* namespace. +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**api_version** | **str** | APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources | [optional] +**kind** | **str** | Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds | [optional] +**metadata** | [**V1ObjectMeta**](V1ObjectMeta.md) | | [optional] +**spec** | [**KubeflowOrgV2alpha1TrainingRuntimeSpec**](KubeflowOrgV2alpha1TrainingRuntimeSpec.md) | | [optional] + +[[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/sdk_v2/docs/KubeflowOrgV2alpha1ClusterTrainingRuntimeList.md b/sdk_v2/docs/KubeflowOrgV2alpha1ClusterTrainingRuntimeList.md new file mode 100644 index 0000000000..6c0cdf3d42 --- /dev/null +++ b/sdk_v2/docs/KubeflowOrgV2alpha1ClusterTrainingRuntimeList.md @@ -0,0 +1,14 @@ +# KubeflowOrgV2alpha1ClusterTrainingRuntimeList + +ClusterTrainingRuntimeList is a collection of cluster training runtimes. +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**api_version** | **str** | APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources | [optional] +**items** | [**list[KubeflowOrgV2alpha1ClusterTrainingRuntime]**](KubeflowOrgV2alpha1ClusterTrainingRuntime.md) | List of ClusterTrainingRuntimes. | +**kind** | **str** | Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds | [optional] +**metadata** | [**V1ListMeta**](V1ListMeta.md) | | [optional] + +[[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/sdk_v2/docs/KubeflowOrgV2alpha1ContainerOverride.md b/sdk_v2/docs/KubeflowOrgV2alpha1ContainerOverride.md new file mode 100644 index 0000000000..65a0128699 --- /dev/null +++ b/sdk_v2/docs/KubeflowOrgV2alpha1ContainerOverride.md @@ -0,0 +1,16 @@ +# KubeflowOrgV2alpha1ContainerOverride + +ContainerOverride represents parameters that can be overridden using PodSpecOverrides. Parameters from the Trainer, DatasetConfig, and ModelConfig will take precedence. +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**args** | **list[str]** | Arguments to the entrypoint for the training container. | [optional] +**command** | **list[str]** | Entrypoint commands for the training container. | [optional] +**env** | [**list[V1EnvVar]**](V1EnvVar.md) | List of environment variables to set in the container. These values will be merged with the TrainingRuntime's environments. | [optional] +**env_from** | [**list[V1EnvFromSource]**](V1EnvFromSource.md) | List of sources to populate environment variables in the container. These values will be merged with the TrainingRuntime's environments. | [optional] +**name** | **str** | Name for the container. TrainingRuntime must have this container. | [default to ''] +**volume_mounts** | [**list[V1VolumeMount]**](V1VolumeMount.md) | Pod volumes to mount into the container's filesystem. | [optional] + +[[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/sdk_v2/docs/KubeflowOrgV2alpha1CoschedulingPodGroupPolicySource.md b/sdk_v2/docs/KubeflowOrgV2alpha1CoschedulingPodGroupPolicySource.md new file mode 100644 index 0000000000..0bbb6cdf68 --- /dev/null +++ b/sdk_v2/docs/KubeflowOrgV2alpha1CoschedulingPodGroupPolicySource.md @@ -0,0 +1,11 @@ +# KubeflowOrgV2alpha1CoschedulingPodGroupPolicySource + +CoschedulingPodGroupPolicySource represents configuration for coscheduling plugin. The number of min members in the PodGroupSpec is always equal to the number of nodes. +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**schedule_timeout_seconds** | **int** | Time threshold to schedule PodGroup for gang-scheduling. If the scheduling timeout is equal to 0, the default value is used. Defaults to 60 seconds. | [optional] + +[[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/sdk_v2/docs/KubeflowOrgV2alpha1DatasetConfig.md b/sdk_v2/docs/KubeflowOrgV2alpha1DatasetConfig.md new file mode 100644 index 0000000000..39edeefdab --- /dev/null +++ b/sdk_v2/docs/KubeflowOrgV2alpha1DatasetConfig.md @@ -0,0 +1,13 @@ +# KubeflowOrgV2alpha1DatasetConfig + +DatasetConfig represents the desired dataset configuration. When this API is used, the training runtime must have the `dataset-initializer` container in the `Initializer` Job. +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**env** | [**list[V1EnvVar]**](V1EnvVar.md) | List of environment variables to set in the dataset initializer container. These values will be merged with the TrainingRuntime's dataset initializer environments. | [optional] +**secret_ref** | [**V1SecretReference**](V1SecretReference.md) | | [optional] +**storage_uri** | **str** | Storage uri for the dataset provider. | [optional] + +[[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/sdk_v2/docs/KubeflowOrgV2alpha1InputModel.md b/sdk_v2/docs/KubeflowOrgV2alpha1InputModel.md new file mode 100644 index 0000000000..ae22fddd4f --- /dev/null +++ b/sdk_v2/docs/KubeflowOrgV2alpha1InputModel.md @@ -0,0 +1,13 @@ +# KubeflowOrgV2alpha1InputModel + +InputModel represents the desired pre-trained model configuration. +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**env** | [**list[V1EnvVar]**](V1EnvVar.md) | List of environment variables to set in the model initializer container. These values will be merged with the TrainingRuntime's model initializer environments. | [optional] +**secret_ref** | [**V1SecretReference**](V1SecretReference.md) | | [optional] +**storage_uri** | **str** | Storage uri for the model provider. | [optional] + +[[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/sdk_v2/docs/KubeflowOrgV2alpha1JobSetTemplateSpec.md b/sdk_v2/docs/KubeflowOrgV2alpha1JobSetTemplateSpec.md new file mode 100644 index 0000000000..4a5643e621 --- /dev/null +++ b/sdk_v2/docs/KubeflowOrgV2alpha1JobSetTemplateSpec.md @@ -0,0 +1,12 @@ +# KubeflowOrgV2alpha1JobSetTemplateSpec + +JobSetTemplateSpec represents a template of the desired JobSet. +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**metadata** | [**V1ObjectMeta**](V1ObjectMeta.md) | | [optional] +**spec** | [**SigsK8sIoJobsetApiJobsetV1alpha2JobSetSpec**](SigsK8sIoJobsetApiJobsetV1alpha2JobSetSpec.md) | | [optional] + +[[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/sdk_v2/docs/KubeflowOrgV2alpha1JobStatus.md b/sdk_v2/docs/KubeflowOrgV2alpha1JobStatus.md new file mode 100644 index 0000000000..ec06fb2fa4 --- /dev/null +++ b/sdk_v2/docs/KubeflowOrgV2alpha1JobStatus.md @@ -0,0 +1,15 @@ +# KubeflowOrgV2alpha1JobStatus + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**active** | **int** | Active is the number of child Jobs with at least 1 pod in a running or pending state which are not marked for deletion. | [default to 0] +**failed** | **int** | Failed is the number of failed child Jobs. | [default to 0] +**name** | **str** | Name of the child Job. | [default to ''] +**ready** | **int** | Ready is the number of child Jobs where the number of ready pods and completed pods is greater than or equal to the total expected pod count for the child Job. | [default to 0] +**succeeded** | **int** | Succeeded is the number of successfully completed child Jobs. | [default to 0] +**suspended** | **int** | Suspended is the number of child Jobs which are in a suspended state. | [default to 0] + +[[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/sdk_v2/docs/KubeflowOrgV2alpha1MLPolicy.md b/sdk_v2/docs/KubeflowOrgV2alpha1MLPolicy.md new file mode 100644 index 0000000000..20c9a250df --- /dev/null +++ b/sdk_v2/docs/KubeflowOrgV2alpha1MLPolicy.md @@ -0,0 +1,13 @@ +# KubeflowOrgV2alpha1MLPolicy + +MLPolicy represents configuration for the model trining with ML-specific parameters. +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**mpi** | [**KubeflowOrgV2alpha1MPIMLPolicySource**](KubeflowOrgV2alpha1MPIMLPolicySource.md) | | [optional] +**num_nodes** | **int** | Number of training nodes. Defaults to 1. | [optional] +**torch** | [**KubeflowOrgV2alpha1TorchMLPolicySource**](KubeflowOrgV2alpha1TorchMLPolicySource.md) | | [optional] + +[[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/sdk_v2/docs/KubeflowOrgV2alpha1MLPolicySource.md b/sdk_v2/docs/KubeflowOrgV2alpha1MLPolicySource.md new file mode 100644 index 0000000000..fb324b21cc --- /dev/null +++ b/sdk_v2/docs/KubeflowOrgV2alpha1MLPolicySource.md @@ -0,0 +1,12 @@ +# KubeflowOrgV2alpha1MLPolicySource + +MLPolicySource represents the runtime-specific configuration for various technologies. One of the following specs can be set. +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**mpi** | [**KubeflowOrgV2alpha1MPIMLPolicySource**](KubeflowOrgV2alpha1MPIMLPolicySource.md) | | [optional] +**torch** | [**KubeflowOrgV2alpha1TorchMLPolicySource**](KubeflowOrgV2alpha1TorchMLPolicySource.md) | | [optional] + +[[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/sdk_v2/docs/KubeflowOrgV2alpha1MPIMLPolicySource.md b/sdk_v2/docs/KubeflowOrgV2alpha1MPIMLPolicySource.md new file mode 100644 index 0000000000..0f71b352df --- /dev/null +++ b/sdk_v2/docs/KubeflowOrgV2alpha1MPIMLPolicySource.md @@ -0,0 +1,14 @@ +# KubeflowOrgV2alpha1MPIMLPolicySource + +MPIMLPolicySource represents a MPI runtime configuration. +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ssh_auth_mount_path** | **str** | Directory where SSH keys are mounted. | [optional] +**mpi_implementation** | **str** | Implementation name for the MPI to create the appropriate hostfile. Defaults to OpenMPI. | [optional] +**num_proc_per_node** | **int** | Number of processes per node. This value is equal to the number of slots for each node in the hostfile. | [optional] +**run_launcher_as_node** | **bool** | Whether to run training process on the launcher Job. Defaults to false. | [optional] + +[[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/sdk_v2/docs/KubeflowOrgV2alpha1ModelConfig.md b/sdk_v2/docs/KubeflowOrgV2alpha1ModelConfig.md new file mode 100644 index 0000000000..45a1f29093 --- /dev/null +++ b/sdk_v2/docs/KubeflowOrgV2alpha1ModelConfig.md @@ -0,0 +1,12 @@ +# KubeflowOrgV2alpha1ModelConfig + +ModelConfig represents the desired model configuration. +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**input** | [**KubeflowOrgV2alpha1InputModel**](KubeflowOrgV2alpha1InputModel.md) | | [optional] +**output** | [**KubeflowOrgV2alpha1OutputModel**](KubeflowOrgV2alpha1OutputModel.md) | | [optional] + +[[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/sdk_v2/docs/KubeflowOrgV2alpha1OutputModel.md b/sdk_v2/docs/KubeflowOrgV2alpha1OutputModel.md new file mode 100644 index 0000000000..10563c4697 --- /dev/null +++ b/sdk_v2/docs/KubeflowOrgV2alpha1OutputModel.md @@ -0,0 +1,13 @@ +# KubeflowOrgV2alpha1OutputModel + +OutputModel represents the desired trained model configuration. +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**env** | [**list[V1EnvVar]**](V1EnvVar.md) | List of environment variables to set in the model exporter container. These values will be merged with the TrainingRuntime's model exporter environments. | [optional] +**secret_ref** | [**V1SecretReference**](V1SecretReference.md) | | [optional] +**storage_uri** | **str** | Storage uri for the model exporter. | [optional] + +[[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/sdk_v2/docs/KubeflowOrgV2alpha1PodGroupPolicy.md b/sdk_v2/docs/KubeflowOrgV2alpha1PodGroupPolicy.md new file mode 100644 index 0000000000..ed148dec19 --- /dev/null +++ b/sdk_v2/docs/KubeflowOrgV2alpha1PodGroupPolicy.md @@ -0,0 +1,11 @@ +# KubeflowOrgV2alpha1PodGroupPolicy + +PodGroupPolicy represents a PodGroup configuration for gang-scheduling. +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**coscheduling** | [**KubeflowOrgV2alpha1CoschedulingPodGroupPolicySource**](KubeflowOrgV2alpha1CoschedulingPodGroupPolicySource.md) | | [optional] + +[[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/sdk_v2/docs/KubeflowOrgV2alpha1PodGroupPolicySource.md b/sdk_v2/docs/KubeflowOrgV2alpha1PodGroupPolicySource.md new file mode 100644 index 0000000000..3407c7b18b --- /dev/null +++ b/sdk_v2/docs/KubeflowOrgV2alpha1PodGroupPolicySource.md @@ -0,0 +1,11 @@ +# KubeflowOrgV2alpha1PodGroupPolicySource + +PodGroupPolicySource represents supported plugins for gang-scheduling. Only one of its members may be specified. +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**coscheduling** | [**KubeflowOrgV2alpha1CoschedulingPodGroupPolicySource**](KubeflowOrgV2alpha1CoschedulingPodGroupPolicySource.md) | | [optional] + +[[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/sdk_v2/docs/KubeflowOrgV2alpha1PodSpecOverride.md b/sdk_v2/docs/KubeflowOrgV2alpha1PodSpecOverride.md new file mode 100644 index 0000000000..0c7c7bbfb2 --- /dev/null +++ b/sdk_v2/docs/KubeflowOrgV2alpha1PodSpecOverride.md @@ -0,0 +1,17 @@ +# KubeflowOrgV2alpha1PodSpecOverride + +PodSpecOverride represents the custom overrides that will be applied for the TrainJob's resources. +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**containers** | [**list[KubeflowOrgV2alpha1ContainerOverride]**](KubeflowOrgV2alpha1ContainerOverride.md) | Overrides for the containers in the desired job templates. | [optional] +**init_containers** | [**list[KubeflowOrgV2alpha1ContainerOverride]**](KubeflowOrgV2alpha1ContainerOverride.md) | Overrides for the init container in the desired job templates. | [optional] +**node_selector** | **dict(str, str)** | Override for the node selector to place Pod on the specific mode. | [optional] +**service_account_name** | **str** | Override for the service account. | [optional] +**target_jobs** | [**list[KubeflowOrgV2alpha1PodSpecOverrideTargetJob]**](KubeflowOrgV2alpha1PodSpecOverrideTargetJob.md) | TrainJobs is the training job replicas in the training runtime template to apply the overrides. | +**tolerations** | [**list[V1Toleration]**](V1Toleration.md) | Override for the Pod's tolerations. | [optional] +**volumes** | [**list[V1Volume]**](V1Volume.md) | Overrides for the Pod volume configuration. | [optional] + +[[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/sdk_v2/docs/KubeflowOrgV2alpha1PodSpecOverrideTargetJob.md b/sdk_v2/docs/KubeflowOrgV2alpha1PodSpecOverrideTargetJob.md new file mode 100644 index 0000000000..2651ada5be --- /dev/null +++ b/sdk_v2/docs/KubeflowOrgV2alpha1PodSpecOverrideTargetJob.md @@ -0,0 +1,10 @@ +# KubeflowOrgV2alpha1PodSpecOverrideTargetJob + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **str** | Name is the target training job name for which the PodSpec is overridden. | [default to ''] + +[[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/sdk_v2/docs/KubeflowOrgV2alpha1RuntimeRef.md b/sdk_v2/docs/KubeflowOrgV2alpha1RuntimeRef.md new file mode 100644 index 0000000000..0e779f6171 --- /dev/null +++ b/sdk_v2/docs/KubeflowOrgV2alpha1RuntimeRef.md @@ -0,0 +1,13 @@ +# KubeflowOrgV2alpha1RuntimeRef + +RuntimeRef represents the reference to the existing training runtime. +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**api_group** | **str** | APIGroup of the runtime being referenced. Defaults to `kubeflow.org`. | [optional] +**kind** | **str** | Kind of the runtime being referenced. Defaults to ClusterTrainingRuntime. | [optional] +**name** | **str** | Name of the runtime being referenced. When namespaced-scoped TrainingRuntime is used, the TrainJob must have the same namespace as the deployed runtime. | [default to ''] + +[[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/sdk_v2/docs/KubeflowOrgV2alpha1TorchElasticPolicy.md b/sdk_v2/docs/KubeflowOrgV2alpha1TorchElasticPolicy.md new file mode 100644 index 0000000000..b7d7e41133 --- /dev/null +++ b/sdk_v2/docs/KubeflowOrgV2alpha1TorchElasticPolicy.md @@ -0,0 +1,14 @@ +# KubeflowOrgV2alpha1TorchElasticPolicy + +TorchElasticPolicy represents a configuration for the PyTorch elastic training. If this policy is set, the `.spec.numNodes` parameter must be omitted, since min and max node is used to configure the `torchrun` CLI argument: `--nnodes=minNodes:maxNodes`. Only `c10d` backend is supported for the Rendezvous communication. +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**max_nodes** | **int** | Upper limit for the number of nodes to which training job can scale up. | [optional] +**max_restarts** | **int** | How many times the training job can be restarted. This value is inserted into the `--max-restarts` argument of the `torchrun` CLI and the `.spec.failurePolicy.maxRestarts` parameter of the training Job. | [optional] +**metrics** | [**list[K8sIoApiAutoscalingV2MetricSpec]**](K8sIoApiAutoscalingV2MetricSpec.md) | Specification which are used to calculate the desired number of nodes. See the individual metric source types for more information about how each type of metric must respond. The HPA will be created to perform auto-scaling. | [optional] +**min_nodes** | **int** | Lower limit for the number of nodes to which training job can scale down. | [optional] + +[[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/sdk_v2/docs/KubeflowOrgV2alpha1TorchMLPolicySource.md b/sdk_v2/docs/KubeflowOrgV2alpha1TorchMLPolicySource.md new file mode 100644 index 0000000000..72c2a70129 --- /dev/null +++ b/sdk_v2/docs/KubeflowOrgV2alpha1TorchMLPolicySource.md @@ -0,0 +1,12 @@ +# KubeflowOrgV2alpha1TorchMLPolicySource + +TorchMLPolicySource represents a PyTorch runtime configuration. +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**elastic_policy** | [**KubeflowOrgV2alpha1TorchElasticPolicy**](KubeflowOrgV2alpha1TorchElasticPolicy.md) | | [optional] +**num_proc_per_node** | **str** | Number of processes per node. This value is inserted into the `--nproc-per-node` argument of the `torchrun` CLI. Supported values: `auto`, `cpu`, `gpu`, or int value. Defaults to `auto`. | [optional] + +[[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/sdk_v2/docs/KubeflowOrgV2alpha1TrainJob.md b/sdk_v2/docs/KubeflowOrgV2alpha1TrainJob.md new file mode 100644 index 0000000000..3b67821127 --- /dev/null +++ b/sdk_v2/docs/KubeflowOrgV2alpha1TrainJob.md @@ -0,0 +1,15 @@ +# KubeflowOrgV2alpha1TrainJob + +TrainJob represents configuration of a training job. +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**api_version** | **str** | APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources | [optional] +**kind** | **str** | Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds | [optional] +**metadata** | [**V1ObjectMeta**](V1ObjectMeta.md) | | [optional] +**spec** | [**KubeflowOrgV2alpha1TrainJobSpec**](KubeflowOrgV2alpha1TrainJobSpec.md) | | [optional] +**status** | [**KubeflowOrgV2alpha1TrainJobStatus**](KubeflowOrgV2alpha1TrainJobStatus.md) | | [optional] + +[[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/sdk_v2/docs/KubeflowOrgV2alpha1TrainJobList.md b/sdk_v2/docs/KubeflowOrgV2alpha1TrainJobList.md new file mode 100644 index 0000000000..340b5de07c --- /dev/null +++ b/sdk_v2/docs/KubeflowOrgV2alpha1TrainJobList.md @@ -0,0 +1,14 @@ +# KubeflowOrgV2alpha1TrainJobList + +TrainJobList is a collection of training jobs. +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**api_version** | **str** | APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources | [optional] +**items** | [**list[KubeflowOrgV2alpha1TrainJob]**](KubeflowOrgV2alpha1TrainJob.md) | List of TrainJobs. | +**kind** | **str** | Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds | [optional] +**metadata** | [**V1ListMeta**](V1ListMeta.md) | | [optional] + +[[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/sdk_v2/docs/KubeflowOrgV2alpha1TrainJobSpec.md b/sdk_v2/docs/KubeflowOrgV2alpha1TrainJobSpec.md new file mode 100644 index 0000000000..de0ed7656b --- /dev/null +++ b/sdk_v2/docs/KubeflowOrgV2alpha1TrainJobSpec.md @@ -0,0 +1,19 @@ +# KubeflowOrgV2alpha1TrainJobSpec + +TrainJobSpec represents specification of the desired TrainJob. +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**annotations** | **dict(str, str)** | Annotations to apply for the derivative JobSet and Jobs. They will be merged with the TrainingRuntime values. | [optional] +**dataset_config** | [**KubeflowOrgV2alpha1DatasetConfig**](KubeflowOrgV2alpha1DatasetConfig.md) | | [optional] +**labels** | **dict(str, str)** | Labels to apply for the derivative JobSet and Jobs. They will be merged with the TrainingRuntime values. | [optional] +**managed_by** | **str** | ManagedBy is used to indicate the controller or entity that manages a TrainJob. The value must be either an empty, `kubeflow.org/trainjob-controller` or `kueue.x-k8s.io/multikueue`. The built-in TrainJob controller reconciles TrainJob which don't have this field at all or the field value is the reserved string `kubeflow.org/trainjob-controller`, but delegates reconciling TrainJobs with a 'kueue.x-k8s.io/multikueue' to the Kueue. The field is immutable. Defaults to `kubeflow.org/trainjob-controller` | [optional] +**model_config** | [**KubeflowOrgV2alpha1ModelConfig**](KubeflowOrgV2alpha1ModelConfig.md) | | [optional] +**pod_spec_overrides** | [**list[KubeflowOrgV2alpha1PodSpecOverride]**](KubeflowOrgV2alpha1PodSpecOverride.md) | Custom overrides for the training runtime. | [optional] +**runtime_ref** | [**KubeflowOrgV2alpha1RuntimeRef**](KubeflowOrgV2alpha1RuntimeRef.md) | | +**suspend** | **bool** | Whether the controller should suspend the running TrainJob. Defaults to false. | [optional] +**trainer** | [**KubeflowOrgV2alpha1Trainer**](KubeflowOrgV2alpha1Trainer.md) | | [optional] + +[[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/sdk_v2/docs/KubeflowOrgV2alpha1TrainJobStatus.md b/sdk_v2/docs/KubeflowOrgV2alpha1TrainJobStatus.md new file mode 100644 index 0000000000..17675f4890 --- /dev/null +++ b/sdk_v2/docs/KubeflowOrgV2alpha1TrainJobStatus.md @@ -0,0 +1,12 @@ +# KubeflowOrgV2alpha1TrainJobStatus + +TrainJobStatus represents the current status of TrainJob. +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**conditions** | [**list[V1Condition]**](V1Condition.md) | Conditions for the TrainJob. | [optional] +**jobs_status** | [**list[KubeflowOrgV2alpha1JobStatus]**](KubeflowOrgV2alpha1JobStatus.md) | JobsStatus tracks the child Jobs in TrainJob. | [optional] + +[[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/sdk_v2/docs/KubeflowOrgV2alpha1Trainer.md b/sdk_v2/docs/KubeflowOrgV2alpha1Trainer.md new file mode 100644 index 0000000000..f69b5ba330 --- /dev/null +++ b/sdk_v2/docs/KubeflowOrgV2alpha1Trainer.md @@ -0,0 +1,17 @@ +# KubeflowOrgV2alpha1Trainer + +Trainer represents the desired trainer configuration. Every training runtime contains `trainer` container which represents Trainer. +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**args** | **list[str]** | Arguments to the entrypoint for the training container. | [optional] +**command** | **list[str]** | Entrypoint commands for the training container. | [optional] +**env** | [**list[V1EnvVar]**](V1EnvVar.md) | List of environment variables to set in the training container. These values will be merged with the TrainingRuntime's trainer environments. | [optional] +**image** | **str** | Docker image for the training container. | [optional] +**num_nodes** | **int** | Number of training nodes. | [optional] +**num_proc_per_node** | **str** | Number of processes/workers/slots on every training node. For the Torch runtime: `auto`, `cpu`, `gpu`, or int value can be set. For the MPI runtime only int value can be set. | [optional] +**resources_per_node** | [**V1ResourceRequirements**](V1ResourceRequirements.md) | | [optional] + +[[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/sdk_v2/docs/KubeflowOrgV2alpha1TrainingRuntime.md b/sdk_v2/docs/KubeflowOrgV2alpha1TrainingRuntime.md new file mode 100644 index 0000000000..8176601f92 --- /dev/null +++ b/sdk_v2/docs/KubeflowOrgV2alpha1TrainingRuntime.md @@ -0,0 +1,14 @@ +# KubeflowOrgV2alpha1TrainingRuntime + +TrainingRuntime represents a training runtime which can be referenced as part of `runtimeRef` API in TrainJob. This resource is a namespaced-scoped and can be referenced by TrainJob that created in the *same* namespace as the TrainingRuntime. +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**api_version** | **str** | APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources | [optional] +**kind** | **str** | Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds | [optional] +**metadata** | [**V1ObjectMeta**](V1ObjectMeta.md) | | [optional] +**spec** | [**KubeflowOrgV2alpha1TrainingRuntimeSpec**](KubeflowOrgV2alpha1TrainingRuntimeSpec.md) | | [optional] + +[[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/sdk_v2/docs/KubeflowOrgV2alpha1TrainingRuntimeList.md b/sdk_v2/docs/KubeflowOrgV2alpha1TrainingRuntimeList.md new file mode 100644 index 0000000000..3008606c7a --- /dev/null +++ b/sdk_v2/docs/KubeflowOrgV2alpha1TrainingRuntimeList.md @@ -0,0 +1,14 @@ +# KubeflowOrgV2alpha1TrainingRuntimeList + +TrainingRuntimeList is a collection of training runtimes. +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**api_version** | **str** | APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources | [optional] +**items** | [**list[KubeflowOrgV2alpha1TrainingRuntime]**](KubeflowOrgV2alpha1TrainingRuntime.md) | List of TrainingRuntimes. | +**kind** | **str** | Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds | [optional] +**metadata** | [**V1ListMeta**](V1ListMeta.md) | | [optional] + +[[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/sdk_v2/docs/KubeflowOrgV2alpha1TrainingRuntimeSpec.md b/sdk_v2/docs/KubeflowOrgV2alpha1TrainingRuntimeSpec.md new file mode 100644 index 0000000000..70c994afc9 --- /dev/null +++ b/sdk_v2/docs/KubeflowOrgV2alpha1TrainingRuntimeSpec.md @@ -0,0 +1,13 @@ +# KubeflowOrgV2alpha1TrainingRuntimeSpec + +TrainingRuntimeSpec represents a specification of the desired training runtime. +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ml_policy** | [**KubeflowOrgV2alpha1MLPolicy**](KubeflowOrgV2alpha1MLPolicy.md) | | [optional] +**pod_group_policy** | [**KubeflowOrgV2alpha1PodGroupPolicy**](KubeflowOrgV2alpha1PodGroupPolicy.md) | | [optional] +**template** | [**KubeflowOrgV2alpha1JobSetTemplateSpec**](KubeflowOrgV2alpha1JobSetTemplateSpec.md) | | + +[[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/sdk_v2/kubeflow/__init__.py b/sdk_v2/kubeflow/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/sdk_v2/kubeflow/training/__init__.py b/sdk_v2/kubeflow/training/__init__.py new file mode 100644 index 0000000000..08f8ada8b7 --- /dev/null +++ b/sdk_v2/kubeflow/training/__init__.py @@ -0,0 +1,58 @@ +# coding: utf-8 + +# flake8: noqa + +""" + Kubeflow Training OpenAPI Spec + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +__version__ = "2.0.0" + +# import apis into sdk package + +# import ApiClient +from kubeflow.training.api_client import ApiClient +from kubeflow.training.configuration import Configuration +from kubeflow.training.exceptions import OpenApiException +from kubeflow.training.exceptions import ApiTypeError +from kubeflow.training.exceptions import ApiValueError +from kubeflow.training.exceptions import ApiKeyError +from kubeflow.training.exceptions import ApiException +# import models into sdk package +from kubeflow.training.models.kubeflow_org_v2alpha1_cluster_training_runtime import KubeflowOrgV2alpha1ClusterTrainingRuntime +from kubeflow.training.models.kubeflow_org_v2alpha1_cluster_training_runtime_list import KubeflowOrgV2alpha1ClusterTrainingRuntimeList +from kubeflow.training.models.kubeflow_org_v2alpha1_container_override import KubeflowOrgV2alpha1ContainerOverride +from kubeflow.training.models.kubeflow_org_v2alpha1_coscheduling_pod_group_policy_source import KubeflowOrgV2alpha1CoschedulingPodGroupPolicySource +from kubeflow.training.models.kubeflow_org_v2alpha1_dataset_config import KubeflowOrgV2alpha1DatasetConfig +from kubeflow.training.models.kubeflow_org_v2alpha1_input_model import KubeflowOrgV2alpha1InputModel +from kubeflow.training.models.kubeflow_org_v2alpha1_job_set_template_spec import KubeflowOrgV2alpha1JobSetTemplateSpec +from kubeflow.training.models.kubeflow_org_v2alpha1_job_status import KubeflowOrgV2alpha1JobStatus +from kubeflow.training.models.kubeflow_org_v2alpha1_ml_policy import KubeflowOrgV2alpha1MLPolicy +from kubeflow.training.models.kubeflow_org_v2alpha1_ml_policy_source import KubeflowOrgV2alpha1MLPolicySource +from kubeflow.training.models.kubeflow_org_v2alpha1_mpiml_policy_source import KubeflowOrgV2alpha1MPIMLPolicySource +from kubeflow.training.models.kubeflow_org_v2alpha1_model_config import KubeflowOrgV2alpha1ModelConfig +from kubeflow.training.models.kubeflow_org_v2alpha1_output_model import KubeflowOrgV2alpha1OutputModel +from kubeflow.training.models.kubeflow_org_v2alpha1_pod_group_policy import KubeflowOrgV2alpha1PodGroupPolicy +from kubeflow.training.models.kubeflow_org_v2alpha1_pod_group_policy_source import KubeflowOrgV2alpha1PodGroupPolicySource +from kubeflow.training.models.kubeflow_org_v2alpha1_pod_spec_override import KubeflowOrgV2alpha1PodSpecOverride +from kubeflow.training.models.kubeflow_org_v2alpha1_pod_spec_override_target_job import KubeflowOrgV2alpha1PodSpecOverrideTargetJob +from kubeflow.training.models.kubeflow_org_v2alpha1_runtime_ref import KubeflowOrgV2alpha1RuntimeRef +from kubeflow.training.models.kubeflow_org_v2alpha1_torch_elastic_policy import KubeflowOrgV2alpha1TorchElasticPolicy +from kubeflow.training.models.kubeflow_org_v2alpha1_torch_ml_policy_source import KubeflowOrgV2alpha1TorchMLPolicySource +from kubeflow.training.models.kubeflow_org_v2alpha1_train_job import KubeflowOrgV2alpha1TrainJob +from kubeflow.training.models.kubeflow_org_v2alpha1_train_job_list import KubeflowOrgV2alpha1TrainJobList +from kubeflow.training.models.kubeflow_org_v2alpha1_train_job_spec import KubeflowOrgV2alpha1TrainJobSpec +from kubeflow.training.models.kubeflow_org_v2alpha1_train_job_status import KubeflowOrgV2alpha1TrainJobStatus +from kubeflow.training.models.kubeflow_org_v2alpha1_trainer import KubeflowOrgV2alpha1Trainer +from kubeflow.training.models.kubeflow_org_v2alpha1_training_runtime import KubeflowOrgV2alpha1TrainingRuntime +from kubeflow.training.models.kubeflow_org_v2alpha1_training_runtime_list import KubeflowOrgV2alpha1TrainingRuntimeList +from kubeflow.training.models.kubeflow_org_v2alpha1_training_runtime_spec import KubeflowOrgV2alpha1TrainingRuntimeSpec + diff --git a/sdk_v2/kubeflow/training/api/__init__.py b/sdk_v2/kubeflow/training/api/__init__.py new file mode 100644 index 0000000000..36dce7fe22 --- /dev/null +++ b/sdk_v2/kubeflow/training/api/__init__.py @@ -0,0 +1,5 @@ +from __future__ import absolute_import + +# flake8: noqa + +# import apis into api package diff --git a/sdk_v2/kubeflow/training/api/training_client.py b/sdk_v2/kubeflow/training/api/training_client.py new file mode 100644 index 0000000000..065cdbe375 --- /dev/null +++ b/sdk_v2/kubeflow/training/api/training_client.py @@ -0,0 +1,18 @@ +# Copyright 2024 The Kubeflow Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +class TrainingClient: + def __init__(self): + print("Work in progress...") diff --git a/sdk_v2/kubeflow/training/api_client.py b/sdk_v2/kubeflow/training/api_client.py new file mode 100644 index 0000000000..f8608a6a3f --- /dev/null +++ b/sdk_v2/kubeflow/training/api_client.py @@ -0,0 +1,666 @@ +# coding: utf-8 +""" + Kubeflow Training OpenAPI Spec + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + +from __future__ import absolute_import + +import atexit +import datetime +from dateutil.parser import parse +import json +import mimetypes +from multiprocessing.pool import ThreadPool +import os +import re +import tempfile + +# python 2 and python 3 compatibility library +import six +from six.moves.urllib.parse import quote + +from kubeflow.training.configuration import Configuration +import kubeflow.training.models +from kubeflow.training import rest +from kubeflow.training.exceptions import ApiValueError, ApiException + + +class ApiClient(object): + """Generic API client for OpenAPI client library builds. + + OpenAPI generic API client. This client handles the client- + server communication, and is invariant across implementations. Specifics of + the methods and models for each application are generated from the OpenAPI + templates. + + NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + Do not edit the class manually. + + :param configuration: .Configuration object for this client + :param header_name: a header to pass when making calls to the API. + :param header_value: a header value to pass when making calls to + the API. + :param cookie: a cookie to include in the header when making calls + to the API + :param pool_threads: The number of threads to use for async requests + to the API. More threads means more concurrent API requests. + """ + + PRIMITIVE_TYPES = (float, bool, bytes, six.text_type) + six.integer_types + NATIVE_TYPES_MAPPING = { + 'int': int, + 'long': int if six.PY3 else long, # noqa: F821 + 'float': float, + 'str': str, + 'bool': bool, + 'date': datetime.date, + 'datetime': datetime.datetime, + 'object': object, + } + _pool = None + + def __init__(self, configuration=None, header_name=None, header_value=None, + cookie=None, pool_threads=1): + if configuration is None: + configuration = Configuration.get_default_copy() + self.configuration = configuration + self.pool_threads = pool_threads + + self.rest_client = rest.RESTClientObject(configuration) + self.default_headers = {} + if header_name is not None: + self.default_headers[header_name] = header_value + self.cookie = cookie + # Set default User-Agent. + self.user_agent = 'OpenAPI-Generator/2.0.0/python' + self.client_side_validation = configuration.client_side_validation + + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_value, traceback): + self.close() + + def close(self): + if self._pool: + self._pool.close() + self._pool.join() + self._pool = None + if hasattr(atexit, 'unregister'): + atexit.unregister(self.close) + + @property + def pool(self): + """Create thread pool on first request + avoids instantiating unused threadpool for blocking clients. + """ + if self._pool is None: + atexit.register(self.close) + self._pool = ThreadPool(self.pool_threads) + return self._pool + + @property + def user_agent(self): + """User agent for this API client""" + return self.default_headers['User-Agent'] + + @user_agent.setter + def user_agent(self, value): + self.default_headers['User-Agent'] = value + + def set_default_header(self, header_name, header_value): + self.default_headers[header_name] = header_value + + def __call_api( + self, resource_path, method, path_params=None, + query_params=None, header_params=None, body=None, post_params=None, + files=None, response_type=None, auth_settings=None, + _return_http_data_only=None, collection_formats=None, + _preload_content=True, _request_timeout=None, _host=None): + + config = self.configuration + + # header parameters + header_params = header_params or {} + header_params.update(self.default_headers) + if self.cookie: + header_params['Cookie'] = self.cookie + if header_params: + header_params = self.sanitize_for_serialization(header_params) + header_params = dict(self.parameters_to_tuples(header_params, + collection_formats)) + + # path parameters + if path_params: + path_params = self.sanitize_for_serialization(path_params) + path_params = self.parameters_to_tuples(path_params, + collection_formats) + 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) + ) + + # query parameters + if query_params: + query_params = self.sanitize_for_serialization(query_params) + query_params = self.parameters_to_tuples(query_params, + collection_formats) + + # post parameters + if post_params or files: + post_params = post_params if post_params else [] + post_params = self.sanitize_for_serialization(post_params) + post_params = self.parameters_to_tuples(post_params, + collection_formats) + post_params.extend(self.files_parameters(files)) + + # auth setting + self.update_params_for_auth(header_params, query_params, auth_settings) + + # body + if body: + body = self.sanitize_for_serialization(body) + + # request url + if _host is None: + url = self.configuration.host + resource_path + else: + # use server/host defined in path or operation instead + url = _host + resource_path + + try: + # perform request and return response + response_data = self.request( + method, url, query_params=query_params, headers=header_params, + post_params=post_params, body=body, + _preload_content=_preload_content, + _request_timeout=_request_timeout) + except ApiException as e: + e.body = e.body.decode('utf-8') if six.PY3 else e.body + raise e + + content_type = response_data.getheader('content-type') + + self.last_response = response_data + + return_data = response_data + + if not _preload_content: + return return_data + + if six.PY3 and response_type not in ["file", "bytes"]: + match = None + if content_type is not None: + match = re.search(r"charset=([a-zA-Z\-\d]+)[\s\;]?", content_type) + encoding = match.group(1) if match else "utf-8" + response_data.data = response_data.data.decode(encoding) + + # deserialize response data + if response_type: + return_data = self.deserialize(response_data, response_type) + else: + return_data = None + + if _return_http_data_only: + return (return_data) + else: + return (return_data, response_data.status, + response_data.getheaders()) + + def sanitize_for_serialization(self, obj): + """Builds a JSON POST object. + + If obj is None, return None. + If obj is str, int, long, float, bool, return directly. + If obj is datetime.datetime, datetime.date + convert to string in iso8601 format. + If obj is list, sanitize each element in the list. + If obj is dict, return the dict. + If obj is OpenAPI model, return the properties dict. + + :param obj: The data to serialize. + :return: The serialized form of data. + """ + if obj is None: + return None + elif isinstance(obj, self.PRIMITIVE_TYPES): + return obj + elif isinstance(obj, list): + 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)): + return obj.isoformat() + + if isinstance(obj, dict): + obj_dict = obj + else: + # Convert model obj to dict except + # attributes `openapi_types`, `attribute_map` + # and attributes which value is not None. + # Convert attribute name to json key in + # model definition for request. + obj_dict = {obj.attribute_map[attr]: getattr(obj, attr) + for attr, _ in six.iteritems(obj.openapi_types) + if getattr(obj, attr) is not None} + + return {key: self.sanitize_for_serialization(val) + for key, val in six.iteritems(obj_dict)} + + def deserialize(self, response, response_type): + """Deserializes response into an object. + + :param response: RESTResponse object to be deserialized. + :param response_type: class literal for + deserialized object, or string of class name. + + :return: deserialized object. + """ + # handle file downloading + # save response body into a tmp file and return the instance + if response_type == "file": + return self.__deserialize_file(response) + + # fetch data from response object + try: + data = json.loads(response.data) + except ValueError: + data = response.data + + return self.__deserialize(data, response_type) + + def __deserialize(self, data, klass): + """Deserializes dict, list, str into an object. + + :param data: dict, list or str. + :param klass: class literal, or string of class name. + + :return: object. + """ + if data is None: + return None + + if type(klass) == str: + if klass.startswith('list['): + sub_kls = re.match(r'list\[(.*)\]', klass).group(1) + return [self.__deserialize(sub_data, sub_kls) + for sub_data in data] + + if klass.startswith('dict('): + sub_kls = re.match(r'dict\(([^,]*), (.*)\)', klass).group(2) + return {k: self.__deserialize(v, sub_kls) + for k, v in six.iteritems(data)} + + # convert str to class + if klass in self.NATIVE_TYPES_MAPPING: + klass = self.NATIVE_TYPES_MAPPING[klass] + else: + klass = getattr(kubeflow.training.models, klass) + + if klass in self.PRIMITIVE_TYPES: + return self.__deserialize_primitive(data, klass) + elif klass == object: + return self.__deserialize_object(data) + elif klass == datetime.date: + return self.__deserialize_date(data) + elif klass == datetime.datetime: + return self.__deserialize_datetime(data) + else: + return self.__deserialize_model(data, klass) + + def call_api(self, resource_path, method, + path_params=None, query_params=None, header_params=None, + body=None, post_params=None, files=None, + response_type=None, auth_settings=None, async_req=None, + _return_http_data_only=None, collection_formats=None, + _preload_content=True, _request_timeout=None, _host=None): + """Makes the HTTP request (synchronous) and returns deserialized data. + + To make an async_req request, set the async_req parameter. + + :param resource_path: Path to method endpoint. + :param method: Method to call. + :param path_params: Path parameters in the url. + :param query_params: Query parameters in the url. + :param header_params: Header parameters to be + placed in the request header. + :param body: Request body. + :param post_params dict: Request post form parameters, + for `application/x-www-form-urlencoded`, `multipart/form-data`. + :param auth_settings list: Auth Settings names for the request. + :param response: Response data type. + :param files dict: key -> filename, value -> filepath, + for `multipart/form-data`. + :param async_req bool: execute request asynchronously + :param _return_http_data_only: response data without head status code + and headers + :param collection_formats: dict of collection formats for path, query, + header, and post parameters. + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :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. + :return: + If async_req parameter is True, + the request will be called asynchronously. + The method will return the request thread. + If parameter async_req is False or missing, + then the method will return the response directly. + """ + if not async_req: + return self.__call_api(resource_path, method, + path_params, query_params, header_params, + body, post_params, files, + response_type, auth_settings, + _return_http_data_only, collection_formats, + _preload_content, _request_timeout, _host) + + return self.pool.apply_async(self.__call_api, (resource_path, + method, path_params, + query_params, + header_params, body, + post_params, files, + response_type, + auth_settings, + _return_http_data_only, + collection_formats, + _preload_content, + _request_timeout, + _host)) + + def request(self, method, url, query_params=None, headers=None, + post_params=None, body=None, _preload_content=True, + _request_timeout=None): + """Makes the HTTP request using RESTClient.""" + if method == "GET": + return self.rest_client.GET(url, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + headers=headers) + elif method == "HEAD": + return self.rest_client.HEAD(url, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + headers=headers) + elif method == "OPTIONS": + return self.rest_client.OPTIONS(url, + query_params=query_params, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout) + elif method == "POST": + return self.rest_client.POST(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + elif method == "PUT": + return self.rest_client.PUT(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + elif method == "PATCH": + return self.rest_client.PATCH(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + elif method == "DELETE": + return self.rest_client.DELETE(url, + query_params=query_params, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + else: + raise ApiValueError( + "http method must be `GET`, `HEAD`, `OPTIONS`," + " `POST`, `PATCH`, `PUT` or `DELETE`." + ) + + def parameters_to_tuples(self, params, collection_formats): + """Get parameters as list of tuples, formatting collections. + + :param params: Parameters as dict or list of two-tuples + :param dict collection_formats: Parameter collection formats + :return: Parameters as list of tuples, collections formatted + """ + new_params = [] + if collection_formats is None: + collection_formats = {} + for k, v in six.iteritems(params) if isinstance(params, dict) else params: # noqa: E501 + if k in collection_formats: + collection_format = collection_formats[k] + if collection_format == 'multi': + new_params.extend((k, value) for value in v) + else: + if collection_format == 'ssv': + delimiter = ' ' + elif collection_format == 'tsv': + delimiter = '\t' + elif collection_format == 'pipes': + delimiter = '|' + else: # csv is the default + delimiter = ',' + new_params.append( + (k, delimiter.join(str(value) for value in v))) + else: + new_params.append((k, v)) + return new_params + + def files_parameters(self, files=None): + """Builds form parameters. + + :param files: File parameters. + :return: Form parameters with files. + """ + params = [] + + if files: + for k, v in six.iteritems(files): + if not v: + continue + file_names = v if type(v) is list else [v] + for n in file_names: + with open(n, 'rb') as f: + filename = os.path.basename(f.name) + filedata = f.read() + mimetype = (mimetypes.guess_type(filename)[0] or + 'application/octet-stream') + params.append( + tuple([k, tuple([filename, filedata, mimetype])])) + + return params + + def select_header_accept(self, accepts): + """Returns `Accept` based on an array of accepts provided. + + :param accepts: List of headers. + :return: Accept (e.g. application/json). + """ + if not accepts: + return + + accepts = [x.lower() for x in accepts] + + if 'application/json' in accepts: + return 'application/json' + else: + return ', '.join(accepts) + + def select_header_content_type(self, content_types): + """Returns `Content-Type` based on an array of content_types provided. + + :param content_types: List of content-types. + :return: Content-Type (e.g. application/json). + """ + if not content_types: + return 'application/json' + + content_types = [x.lower() for x in content_types] + + if 'application/json' in content_types or '*/*' in content_types: + return 'application/json' + else: + return content_types[0] + + def update_params_for_auth(self, headers, querys, auth_settings): + """Updates header and query params based on authentication setting. + + :param headers: Header parameters dict to be updated. + :param querys: Query parameters tuple list to be updated. + :param auth_settings: Authentication setting identifiers list. + """ + if not auth_settings: + return + + for auth in auth_settings: + auth_setting = self.configuration.auth_settings().get(auth) + if auth_setting: + if auth_setting['in'] == 'cookie': + headers['Cookie'] = auth_setting['value'] + elif auth_setting['in'] == 'header': + headers[auth_setting['key']] = auth_setting['value'] + elif auth_setting['in'] == 'query': + querys.append((auth_setting['key'], auth_setting['value'])) + else: + raise ApiValueError( + 'Authentication token must be in `query` or `header`' + ) + + def __deserialize_file(self, response): + """Deserializes body to file + + Saves response body into a file in a temporary folder, + using the filename from the `Content-Disposition` header if provided. + + :param response: RESTResponse. + :return: file path. + """ + fd, path = tempfile.mkstemp(dir=self.configuration.temp_folder_path) + os.close(fd) + os.remove(path) + + content_disposition = response.getheader("Content-Disposition") + if content_disposition: + filename = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', + content_disposition).group(1) + path = os.path.join(os.path.dirname(path), filename) + + with open(path, "wb") as f: + f.write(response.data) + + return path + + def __deserialize_primitive(self, data, klass): + """Deserializes string to primitive type. + + :param data: str. + :param klass: class literal. + + :return: int, long, float, str, bool. + """ + try: + return klass(data) + except UnicodeEncodeError: + return six.text_type(data) + except TypeError: + return data + + def __deserialize_object(self, value): + """Return an original value. + + :return: object. + """ + return value + + def __deserialize_date(self, string): + """Deserializes string to date. + + :param string: str. + :return: date. + """ + try: + return parse(string).date() + except ImportError: + return string + except ValueError: + raise rest.ApiException( + status=0, + reason="Failed to parse `{0}` as date object".format(string) + ) + + def __deserialize_datetime(self, string): + """Deserializes string to datetime. + + The string should be in iso8601 datetime format. + + :param string: str. + :return: datetime. + """ + try: + return parse(string) + except ImportError: + return string + except ValueError: + raise rest.ApiException( + status=0, + reason=( + "Failed to parse `{0}` as datetime object" + .format(string) + ) + ) + + def __deserialize_model(self, data, klass): + """Deserializes list or dict to model. + + :param data: dict, list. + :param klass: class literal. + :return: model object. + """ + has_discriminator = False + if (hasattr(klass, 'get_real_child_model') + and klass.discriminator_value_class_map): + has_discriminator = True + + if not klass.openapi_types and has_discriminator is False: + return data + + kwargs = {} + if (data is not None and + klass.openapi_types is not None and + isinstance(data, (list, dict))): + for attr, attr_type in six.iteritems(klass.openapi_types): + if klass.attribute_map[attr] in data: + value = data[klass.attribute_map[attr]] + kwargs[attr] = self.__deserialize(value, attr_type) + + instance = klass(**kwargs) + + if has_discriminator: + klass_name = instance.get_real_child_model(data) + if klass_name: + instance = self.__deserialize(data, klass_name) + return instance diff --git a/sdk_v2/kubeflow/training/configuration.py b/sdk_v2/kubeflow/training/configuration.py new file mode 100644 index 0000000000..86cb1c921f --- /dev/null +++ b/sdk_v2/kubeflow/training/configuration.py @@ -0,0 +1,376 @@ +# coding: utf-8 + +""" + Kubeflow Training OpenAPI Spec + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import copy +import logging +import multiprocessing +import sys +import urllib3 + +import six +from six.moves import http_client as httplib + + +class Configuration(object): + """NOTE: This class is auto generated by OpenAPI Generator + + Ref: https://openapi-generator.tech + Do not edit the class manually. + + :param host: Base url + :param api_key: Dict to store API key(s). + Each entry in the dict specifies an API key. + The dict key is the name of the security scheme in the OAS specification. + The dict value is the API key secret. + :param api_key_prefix: Dict to store API prefix (e.g. Bearer) + The dict key is the name of the security scheme in the OAS specification. + The dict value is an API key prefix when generating the auth data. + :param username: Username for HTTP basic authentication + :param password: Password for HTTP basic authentication + :param discard_unknown_keys: Boolean value indicating whether to discard + unknown properties. A server may send a response that includes additional + properties that are not known by the client in the following scenarios: + 1. The OpenAPI document is incomplete, i.e. it does not match the server + implementation. + 2. The client was generated using an older version of the OpenAPI document + and the server has been upgraded since then. + If a schema in the OpenAPI document defines the additionalProperties attribute, + then all undeclared properties received by the server are injected into the + additional properties map. In that case, there are undeclared properties, and + nothing to discard. + + """ + + _default = None + + def __init__(self, host="http://localhost", + api_key=None, api_key_prefix=None, + username=None, password=None, + discard_unknown_keys=False, + ): + """Constructor + """ + self.host = host + """Default Base url + """ + self.temp_folder_path = None + """Temp file folder for downloading files + """ + # Authentication Settings + self.api_key = {} + if api_key: + self.api_key = api_key + """dict to store API key(s) + """ + self.api_key_prefix = {} + if api_key_prefix: + self.api_key_prefix = api_key_prefix + """dict to store API prefix (e.g. Bearer) + """ + self.refresh_api_key_hook = None + """function hook to refresh API key if expired + """ + self.username = username + """Username for HTTP basic authentication + """ + self.password = password + """Password for HTTP basic authentication + """ + self.discard_unknown_keys = discard_unknown_keys + self.logger = {} + """Logging Settings + """ + self.logger["package_logger"] = logging.getLogger("kubeflow.training") + self.logger["urllib3_logger"] = logging.getLogger("urllib3") + self.logger_format = '%(asctime)s %(levelname)s %(message)s' + """Log format + """ + self.logger_stream_handler = None + """Log stream handler + """ + self.logger_file_handler = None + """Log file handler + """ + self.logger_file = None + """Debug file location + """ + self.debug = False + """Debug switch + """ + + self.verify_ssl = True + """SSL/TLS verification + Set this to false to skip verifying SSL certificate when calling API + from https server. + """ + self.ssl_ca_cert = None + """Set this to customize the certificate file to verify the peer. + """ + self.cert_file = None + """client certificate file + """ + self.key_file = None + """client key file + """ + self.assert_hostname = None + """Set this to True/False to enable/disable SSL hostname verification. + """ + + self.connection_pool_maxsize = multiprocessing.cpu_count() * 5 + """urllib3 connection pool's maximum number of connections saved + per pool. urllib3 uses 1 connection as default value, but this is + not the best value when you are making a lot of possibly parallel + requests to the same host, which is often the case here. + cpu_count * 5 is used as default value to increase performance. + """ + + self.proxy = None + """Proxy URL + """ + self.proxy_headers = None + """Proxy headers + """ + self.safe_chars_for_path_param = '' + """Safe chars for path_param + """ + self.retries = None + """Adding retries to override urllib3 default value 3 + """ + # Disable client side validation + self.client_side_validation = True + + def __deepcopy__(self, memo): + cls = self.__class__ + result = cls.__new__(cls) + memo[id(self)] = result + for k, v in self.__dict__.items(): + if k not in ('logger', 'logger_file_handler'): + setattr(result, k, copy.deepcopy(v, memo)) + # shallow copy of loggers + result.logger = copy.copy(self.logger) + # use setters to configure loggers + result.logger_file = self.logger_file + result.debug = self.debug + return result + + def __setattr__(self, name, value): + object.__setattr__(self, name, value) + + @classmethod + def set_default(cls, default): + """Set default instance of configuration. + + It stores default configuration, which can be + returned by get_default_copy method. + + :param default: object of Configuration + """ + cls._default = copy.deepcopy(default) + + @classmethod + def get_default_copy(cls): + """Return new instance of configuration. + + This method returns newly created, based on default constructor, + object of Configuration class or returns a copy of default + configuration passed by the set_default method. + + :return: The configuration object. + """ + if cls._default is not None: + return copy.deepcopy(cls._default) + return Configuration() + + @property + def logger_file(self): + """The logger file. + + If the logger_file is None, then add stream handler and remove file + handler. Otherwise, add file handler and remove stream handler. + + :param value: The logger_file path. + :type: str + """ + return self.__logger_file + + @logger_file.setter + def logger_file(self, value): + """The logger file. + + If the logger_file is None, then add stream handler and remove file + handler. Otherwise, add file handler and remove stream handler. + + :param value: The logger_file path. + :type: str + """ + self.__logger_file = value + if self.__logger_file: + # If set logging file, + # then add file handler and remove stream handler. + self.logger_file_handler = logging.FileHandler(self.__logger_file) + self.logger_file_handler.setFormatter(self.logger_formatter) + for _, logger in six.iteritems(self.logger): + logger.addHandler(self.logger_file_handler) + + @property + def debug(self): + """Debug status + + :param value: The debug status, True or False. + :type: bool + """ + return self.__debug + + @debug.setter + def debug(self, value): + """Debug status + + :param value: The debug status, True or False. + :type: bool + """ + self.__debug = value + if self.__debug: + # if debug status is True, turn on debug logging + for _, logger in six.iteritems(self.logger): + logger.setLevel(logging.DEBUG) + # turn on httplib debug + httplib.HTTPConnection.debuglevel = 1 + else: + # if debug status is False, turn off debug logging, + # setting log level to default `logging.WARNING` + for _, logger in six.iteritems(self.logger): + logger.setLevel(logging.WARNING) + # turn off httplib debug + httplib.HTTPConnection.debuglevel = 0 + + @property + def logger_format(self): + """The logger format. + + The logger_formatter will be updated when sets logger_format. + + :param value: The format string. + :type: str + """ + return self.__logger_format + + @logger_format.setter + def logger_format(self, value): + """The logger format. + + The logger_formatter will be updated when sets logger_format. + + :param value: The format string. + :type: str + """ + self.__logger_format = value + self.logger_formatter = logging.Formatter(self.__logger_format) + + def get_api_key_with_prefix(self, identifier): + """Gets API key (with prefix if set). + + :param identifier: The identifier of apiKey. + :return: The token for api key authentication. + """ + if self.refresh_api_key_hook is not None: + self.refresh_api_key_hook(self) + key = self.api_key.get(identifier) + if key: + prefix = self.api_key_prefix.get(identifier) + if prefix: + return "%s %s" % (prefix, key) + else: + return key + + def get_basic_auth_token(self): + """Gets HTTP basic authentication header (string). + + :return: The token for basic HTTP authentication. + """ + username = "" + if self.username is not None: + username = self.username + password = "" + if self.password is not None: + password = self.password + return urllib3.util.make_headers( + basic_auth=username + ':' + password + ).get('authorization') + + def auth_settings(self): + """Gets Auth Settings dict for api client. + + :return: The Auth Settings information dict. + """ + auth = {} + return auth + + def to_debug_report(self): + """Gets the essential information for debugging. + + :return: The report for debugging. + """ + return "Python SDK Debug Report:\n"\ + "OS: {env}\n"\ + "Python Version: {pyversion}\n"\ + "Version of the API: 1.0.0\n"\ + "SDK Package Version: 2.0.0".\ + format(env=sys.platform, pyversion=sys.version) + + def get_host_settings(self): + """Gets an array of host settings + + :return: An array of host settings + """ + return [ + { + 'url': "/", + 'description': "No description provided", + } + ] + + def get_host_from_settings(self, index, variables=None): + """Gets host URL based on the index and variables + :param index: array index of the host settings + :param variables: hash of variable and the corresponding value + :return: URL based on host settings + """ + variables = {} if variables is None else variables + servers = self.get_host_settings() + + try: + server = servers[index] + except IndexError: + raise ValueError( + "Invalid index {0} when selecting the host settings. " + "Must be less than {1}".format(index, len(servers))) + + url = server['url'] + + # go through variables and replace placeholders + for variable_name, variable in server['variables'].items(): + used_value = variables.get( + variable_name, variable['default_value']) + + 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( + variable_name, variables[variable_name], + variable['enum_values'])) + + url = url.replace("{" + variable_name + "}", used_value) + + return url diff --git a/sdk_v2/kubeflow/training/exceptions.py b/sdk_v2/kubeflow/training/exceptions.py new file mode 100644 index 0000000000..e801225bb7 --- /dev/null +++ b/sdk_v2/kubeflow/training/exceptions.py @@ -0,0 +1,120 @@ +# coding: utf-8 + +""" + Kubeflow Training OpenAPI Spec + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import six + + +class OpenApiException(Exception): + """The base exception class for all OpenAPIExceptions""" + + +class ApiTypeError(OpenApiException, TypeError): + def __init__(self, msg, path_to_item=None, valid_classes=None, + key_type=None): + """ Raises an exception for TypeErrors + + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (list): a list of keys an indices to get to the + current_item + None if unset + valid_classes (tuple): the primitive classes that current item + should be an instance of + None if unset + key_type (bool): False if our value is a value in a dict + True if it is a key in a dict + False if our item is an item in a list + None if unset + """ + self.path_to_item = path_to_item + self.valid_classes = valid_classes + 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) + + +class ApiValueError(OpenApiException, ValueError): + def __init__(self, msg, path_to_item=None): + """ + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (list) the path to the exception in the + received_data dict. None if unset + """ + + 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) + + +class ApiKeyError(OpenApiException, KeyError): + def __init__(self, msg, path_to_item=None): + """ + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (None/list) the path to the exception in the + received_data dict + """ + 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) + + +class ApiException(OpenApiException): + + def __init__(self, status=None, reason=None, http_resp=None): + if http_resp: + self.status = http_resp.status + self.reason = http_resp.reason + self.body = http_resp.data + self.headers = http_resp.getheaders() + else: + self.status = status + self.reason = reason + self.body = None + self.headers = None + + def __str__(self): + """Custom error messages for exception""" + error_message = "({0})\n"\ + "Reason: {1}\n".format(self.status, self.reason) + if self.headers: + error_message += "HTTP response headers: {0}\n".format( + self.headers) + + if self.body: + error_message += "HTTP response body: {0}\n".format(self.body) + + return error_message + + +def render_path(path_to_item): + """Returns a string representation of a path""" + result = "" + for pth in path_to_item: + if isinstance(pth, six.integer_types): + result += "[{0}]".format(pth) + else: + result += "['{0}']".format(pth) + return result diff --git a/sdk_v2/kubeflow/training/models/__init__.py b/sdk_v2/kubeflow/training/models/__init__.py new file mode 100644 index 0000000000..78285c49d3 --- /dev/null +++ b/sdk_v2/kubeflow/training/models/__init__.py @@ -0,0 +1,44 @@ +# coding: utf-8 + +# flake8: noqa +""" + Kubeflow Training OpenAPI Spec + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +# import models into model package +from kubeflow.training.models.kubeflow_org_v2alpha1_cluster_training_runtime import KubeflowOrgV2alpha1ClusterTrainingRuntime +from kubeflow.training.models.kubeflow_org_v2alpha1_cluster_training_runtime_list import KubeflowOrgV2alpha1ClusterTrainingRuntimeList +from kubeflow.training.models.kubeflow_org_v2alpha1_container_override import KubeflowOrgV2alpha1ContainerOverride +from kubeflow.training.models.kubeflow_org_v2alpha1_coscheduling_pod_group_policy_source import KubeflowOrgV2alpha1CoschedulingPodGroupPolicySource +from kubeflow.training.models.kubeflow_org_v2alpha1_dataset_config import KubeflowOrgV2alpha1DatasetConfig +from kubeflow.training.models.kubeflow_org_v2alpha1_input_model import KubeflowOrgV2alpha1InputModel +from kubeflow.training.models.kubeflow_org_v2alpha1_job_set_template_spec import KubeflowOrgV2alpha1JobSetTemplateSpec +from kubeflow.training.models.kubeflow_org_v2alpha1_job_status import KubeflowOrgV2alpha1JobStatus +from kubeflow.training.models.kubeflow_org_v2alpha1_ml_policy import KubeflowOrgV2alpha1MLPolicy +from kubeflow.training.models.kubeflow_org_v2alpha1_ml_policy_source import KubeflowOrgV2alpha1MLPolicySource +from kubeflow.training.models.kubeflow_org_v2alpha1_mpiml_policy_source import KubeflowOrgV2alpha1MPIMLPolicySource +from kubeflow.training.models.kubeflow_org_v2alpha1_model_config import KubeflowOrgV2alpha1ModelConfig +from kubeflow.training.models.kubeflow_org_v2alpha1_output_model import KubeflowOrgV2alpha1OutputModel +from kubeflow.training.models.kubeflow_org_v2alpha1_pod_group_policy import KubeflowOrgV2alpha1PodGroupPolicy +from kubeflow.training.models.kubeflow_org_v2alpha1_pod_group_policy_source import KubeflowOrgV2alpha1PodGroupPolicySource +from kubeflow.training.models.kubeflow_org_v2alpha1_pod_spec_override import KubeflowOrgV2alpha1PodSpecOverride +from kubeflow.training.models.kubeflow_org_v2alpha1_pod_spec_override_target_job import KubeflowOrgV2alpha1PodSpecOverrideTargetJob +from kubeflow.training.models.kubeflow_org_v2alpha1_runtime_ref import KubeflowOrgV2alpha1RuntimeRef +from kubeflow.training.models.kubeflow_org_v2alpha1_torch_elastic_policy import KubeflowOrgV2alpha1TorchElasticPolicy +from kubeflow.training.models.kubeflow_org_v2alpha1_torch_ml_policy_source import KubeflowOrgV2alpha1TorchMLPolicySource +from kubeflow.training.models.kubeflow_org_v2alpha1_train_job import KubeflowOrgV2alpha1TrainJob +from kubeflow.training.models.kubeflow_org_v2alpha1_train_job_list import KubeflowOrgV2alpha1TrainJobList +from kubeflow.training.models.kubeflow_org_v2alpha1_train_job_spec import KubeflowOrgV2alpha1TrainJobSpec +from kubeflow.training.models.kubeflow_org_v2alpha1_train_job_status import KubeflowOrgV2alpha1TrainJobStatus +from kubeflow.training.models.kubeflow_org_v2alpha1_trainer import KubeflowOrgV2alpha1Trainer +from kubeflow.training.models.kubeflow_org_v2alpha1_training_runtime import KubeflowOrgV2alpha1TrainingRuntime +from kubeflow.training.models.kubeflow_org_v2alpha1_training_runtime_list import KubeflowOrgV2alpha1TrainingRuntimeList +from kubeflow.training.models.kubeflow_org_v2alpha1_training_runtime_spec import KubeflowOrgV2alpha1TrainingRuntimeSpec diff --git a/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_cluster_training_runtime.py b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_cluster_training_runtime.py new file mode 100644 index 0000000000..98ab4763ac --- /dev/null +++ b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_cluster_training_runtime.py @@ -0,0 +1,202 @@ +# coding: utf-8 + +""" + Kubeflow Training OpenAPI Spec + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from kubeflow.training.configuration import Configuration + + +class KubeflowOrgV2alpha1ClusterTrainingRuntime(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = { + 'api_version': 'str', + 'kind': 'str', + 'metadata': 'V1ObjectMeta', + 'spec': 'KubeflowOrgV2alpha1TrainingRuntimeSpec' + } + + attribute_map = { + 'api_version': 'apiVersion', + 'kind': 'kind', + 'metadata': 'metadata', + 'spec': 'spec' + } + + def __init__(self, api_version=None, kind=None, metadata=None, spec=None, local_vars_configuration=None): # noqa: E501 + """KubeflowOrgV2alpha1ClusterTrainingRuntime - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._api_version = None + self._kind = None + self._metadata = None + self._spec = None + self.discriminator = None + + if api_version is not None: + self.api_version = api_version + if kind is not None: + self.kind = kind + if metadata is not None: + self.metadata = metadata + if spec is not None: + self.spec = spec + + @property + def api_version(self): + """Gets the api_version of this KubeflowOrgV2alpha1ClusterTrainingRuntime. # noqa: E501 + + APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources # noqa: E501 + + :return: The api_version of this KubeflowOrgV2alpha1ClusterTrainingRuntime. # noqa: E501 + :rtype: str + """ + return self._api_version + + @api_version.setter + def api_version(self, api_version): + """Sets the api_version of this KubeflowOrgV2alpha1ClusterTrainingRuntime. + + APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources # noqa: E501 + + :param api_version: The api_version of this KubeflowOrgV2alpha1ClusterTrainingRuntime. # noqa: E501 + :type: str + """ + + self._api_version = api_version + + @property + def kind(self): + """Gets the kind of this KubeflowOrgV2alpha1ClusterTrainingRuntime. # noqa: E501 + + Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds # noqa: E501 + + :return: The kind of this KubeflowOrgV2alpha1ClusterTrainingRuntime. # noqa: E501 + :rtype: str + """ + return self._kind + + @kind.setter + def kind(self, kind): + """Sets the kind of this KubeflowOrgV2alpha1ClusterTrainingRuntime. + + Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds # noqa: E501 + + :param kind: The kind of this KubeflowOrgV2alpha1ClusterTrainingRuntime. # noqa: E501 + :type: str + """ + + self._kind = kind + + @property + def metadata(self): + """Gets the metadata of this KubeflowOrgV2alpha1ClusterTrainingRuntime. # noqa: E501 + + + :return: The metadata of this KubeflowOrgV2alpha1ClusterTrainingRuntime. # noqa: E501 + :rtype: V1ObjectMeta + """ + return self._metadata + + @metadata.setter + def metadata(self, metadata): + """Sets the metadata of this KubeflowOrgV2alpha1ClusterTrainingRuntime. + + + :param metadata: The metadata of this KubeflowOrgV2alpha1ClusterTrainingRuntime. # noqa: E501 + :type: V1ObjectMeta + """ + + self._metadata = metadata + + @property + def spec(self): + """Gets the spec of this KubeflowOrgV2alpha1ClusterTrainingRuntime. # noqa: E501 + + + :return: The spec of this KubeflowOrgV2alpha1ClusterTrainingRuntime. # noqa: E501 + :rtype: KubeflowOrgV2alpha1TrainingRuntimeSpec + """ + return self._spec + + @spec.setter + def spec(self, spec): + """Sets the spec of this KubeflowOrgV2alpha1ClusterTrainingRuntime. + + + :param spec: The spec of this KubeflowOrgV2alpha1ClusterTrainingRuntime. # noqa: E501 + :type: KubeflowOrgV2alpha1TrainingRuntimeSpec + """ + + self._spec = spec + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, KubeflowOrgV2alpha1ClusterTrainingRuntime): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, KubeflowOrgV2alpha1ClusterTrainingRuntime): + return True + + return self.to_dict() != other.to_dict() diff --git a/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_cluster_training_runtime_list.py b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_cluster_training_runtime_list.py new file mode 100644 index 0000000000..469fb277da --- /dev/null +++ b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_cluster_training_runtime_list.py @@ -0,0 +1,205 @@ +# coding: utf-8 + +""" + Kubeflow Training OpenAPI Spec + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from kubeflow.training.configuration import Configuration + + +class KubeflowOrgV2alpha1ClusterTrainingRuntimeList(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = { + 'api_version': 'str', + 'items': 'list[KubeflowOrgV2alpha1ClusterTrainingRuntime]', + 'kind': 'str', + 'metadata': 'V1ListMeta' + } + + attribute_map = { + 'api_version': 'apiVersion', + 'items': 'items', + 'kind': 'kind', + 'metadata': 'metadata' + } + + def __init__(self, api_version=None, items=None, kind=None, metadata=None, local_vars_configuration=None): # noqa: E501 + """KubeflowOrgV2alpha1ClusterTrainingRuntimeList - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._api_version = None + self._items = None + self._kind = None + self._metadata = None + self.discriminator = None + + if api_version is not None: + self.api_version = api_version + self.items = items + if kind is not None: + self.kind = kind + if metadata is not None: + self.metadata = metadata + + @property + def api_version(self): + """Gets the api_version of this KubeflowOrgV2alpha1ClusterTrainingRuntimeList. # noqa: E501 + + APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources # noqa: E501 + + :return: The api_version of this KubeflowOrgV2alpha1ClusterTrainingRuntimeList. # noqa: E501 + :rtype: str + """ + return self._api_version + + @api_version.setter + def api_version(self, api_version): + """Sets the api_version of this KubeflowOrgV2alpha1ClusterTrainingRuntimeList. + + APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources # noqa: E501 + + :param api_version: The api_version of this KubeflowOrgV2alpha1ClusterTrainingRuntimeList. # noqa: E501 + :type: str + """ + + self._api_version = api_version + + @property + def items(self): + """Gets the items of this KubeflowOrgV2alpha1ClusterTrainingRuntimeList. # noqa: E501 + + List of ClusterTrainingRuntimes. # noqa: E501 + + :return: The items of this KubeflowOrgV2alpha1ClusterTrainingRuntimeList. # noqa: E501 + :rtype: list[KubeflowOrgV2alpha1ClusterTrainingRuntime] + """ + return self._items + + @items.setter + def items(self, items): + """Sets the items of this KubeflowOrgV2alpha1ClusterTrainingRuntimeList. + + List of ClusterTrainingRuntimes. # noqa: E501 + + :param items: The items of this KubeflowOrgV2alpha1ClusterTrainingRuntimeList. # noqa: E501 + :type: list[KubeflowOrgV2alpha1ClusterTrainingRuntime] + """ + if self.local_vars_configuration.client_side_validation and items is None: # noqa: E501 + raise ValueError("Invalid value for `items`, must not be `None`") # noqa: E501 + + self._items = items + + @property + def kind(self): + """Gets the kind of this KubeflowOrgV2alpha1ClusterTrainingRuntimeList. # noqa: E501 + + Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds # noqa: E501 + + :return: The kind of this KubeflowOrgV2alpha1ClusterTrainingRuntimeList. # noqa: E501 + :rtype: str + """ + return self._kind + + @kind.setter + def kind(self, kind): + """Sets the kind of this KubeflowOrgV2alpha1ClusterTrainingRuntimeList. + + Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds # noqa: E501 + + :param kind: The kind of this KubeflowOrgV2alpha1ClusterTrainingRuntimeList. # noqa: E501 + :type: str + """ + + self._kind = kind + + @property + def metadata(self): + """Gets the metadata of this KubeflowOrgV2alpha1ClusterTrainingRuntimeList. # noqa: E501 + + + :return: The metadata of this KubeflowOrgV2alpha1ClusterTrainingRuntimeList. # noqa: E501 + :rtype: V1ListMeta + """ + return self._metadata + + @metadata.setter + def metadata(self, metadata): + """Sets the metadata of this KubeflowOrgV2alpha1ClusterTrainingRuntimeList. + + + :param metadata: The metadata of this KubeflowOrgV2alpha1ClusterTrainingRuntimeList. # noqa: E501 + :type: V1ListMeta + """ + + self._metadata = metadata + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, KubeflowOrgV2alpha1ClusterTrainingRuntimeList): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, KubeflowOrgV2alpha1ClusterTrainingRuntimeList): + return True + + return self.to_dict() != other.to_dict() diff --git a/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_container_override.py b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_container_override.py new file mode 100644 index 0000000000..fc3dbc562c --- /dev/null +++ b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_container_override.py @@ -0,0 +1,263 @@ +# coding: utf-8 + +""" + Kubeflow Training OpenAPI Spec + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from kubeflow.training.configuration import Configuration + + +class KubeflowOrgV2alpha1ContainerOverride(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = { + 'args': 'list[str]', + 'command': 'list[str]', + 'env': 'list[V1EnvVar]', + 'env_from': 'list[V1EnvFromSource]', + 'name': 'str', + 'volume_mounts': 'list[V1VolumeMount]' + } + + attribute_map = { + 'args': 'args', + 'command': 'command', + 'env': 'env', + 'env_from': 'envFrom', + 'name': 'name', + 'volume_mounts': 'volumeMounts' + } + + def __init__(self, args=None, command=None, env=None, env_from=None, name='', volume_mounts=None, local_vars_configuration=None): # noqa: E501 + """KubeflowOrgV2alpha1ContainerOverride - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._args = None + self._command = None + self._env = None + self._env_from = None + self._name = None + self._volume_mounts = None + self.discriminator = None + + if args is not None: + self.args = args + if command is not None: + self.command = command + if env is not None: + self.env = env + if env_from is not None: + self.env_from = env_from + self.name = name + if volume_mounts is not None: + self.volume_mounts = volume_mounts + + @property + def args(self): + """Gets the args of this KubeflowOrgV2alpha1ContainerOverride. # noqa: E501 + + Arguments to the entrypoint for the training container. # noqa: E501 + + :return: The args of this KubeflowOrgV2alpha1ContainerOverride. # noqa: E501 + :rtype: list[str] + """ + return self._args + + @args.setter + def args(self, args): + """Sets the args of this KubeflowOrgV2alpha1ContainerOverride. + + Arguments to the entrypoint for the training container. # noqa: E501 + + :param args: The args of this KubeflowOrgV2alpha1ContainerOverride. # noqa: E501 + :type: list[str] + """ + + self._args = args + + @property + def command(self): + """Gets the command of this KubeflowOrgV2alpha1ContainerOverride. # noqa: E501 + + Entrypoint commands for the training container. # noqa: E501 + + :return: The command of this KubeflowOrgV2alpha1ContainerOverride. # noqa: E501 + :rtype: list[str] + """ + return self._command + + @command.setter + def command(self, command): + """Sets the command of this KubeflowOrgV2alpha1ContainerOverride. + + Entrypoint commands for the training container. # noqa: E501 + + :param command: The command of this KubeflowOrgV2alpha1ContainerOverride. # noqa: E501 + :type: list[str] + """ + + self._command = command + + @property + def env(self): + """Gets the env of this KubeflowOrgV2alpha1ContainerOverride. # noqa: E501 + + List of environment variables to set in the container. These values will be merged with the TrainingRuntime's environments. # noqa: E501 + + :return: The env of this KubeflowOrgV2alpha1ContainerOverride. # noqa: E501 + :rtype: list[V1EnvVar] + """ + return self._env + + @env.setter + def env(self, env): + """Sets the env of this KubeflowOrgV2alpha1ContainerOverride. + + List of environment variables to set in the container. These values will be merged with the TrainingRuntime's environments. # noqa: E501 + + :param env: The env of this KubeflowOrgV2alpha1ContainerOverride. # noqa: E501 + :type: list[V1EnvVar] + """ + + self._env = env + + @property + def env_from(self): + """Gets the env_from of this KubeflowOrgV2alpha1ContainerOverride. # noqa: E501 + + List of sources to populate environment variables in the container. These values will be merged with the TrainingRuntime's environments. # noqa: E501 + + :return: The env_from of this KubeflowOrgV2alpha1ContainerOverride. # noqa: E501 + :rtype: list[V1EnvFromSource] + """ + return self._env_from + + @env_from.setter + def env_from(self, env_from): + """Sets the env_from of this KubeflowOrgV2alpha1ContainerOverride. + + List of sources to populate environment variables in the container. These values will be merged with the TrainingRuntime's environments. # noqa: E501 + + :param env_from: The env_from of this KubeflowOrgV2alpha1ContainerOverride. # noqa: E501 + :type: list[V1EnvFromSource] + """ + + self._env_from = env_from + + @property + def name(self): + """Gets the name of this KubeflowOrgV2alpha1ContainerOverride. # noqa: E501 + + Name for the container. TrainingRuntime must have this container. # noqa: E501 + + :return: The name of this KubeflowOrgV2alpha1ContainerOverride. # noqa: E501 + :rtype: str + """ + return self._name + + @name.setter + def name(self, name): + """Sets the name of this KubeflowOrgV2alpha1ContainerOverride. + + Name for the container. TrainingRuntime must have this container. # noqa: E501 + + :param name: The name of this KubeflowOrgV2alpha1ContainerOverride. # noqa: E501 + :type: str + """ + if self.local_vars_configuration.client_side_validation and name is None: # noqa: E501 + raise ValueError("Invalid value for `name`, must not be `None`") # noqa: E501 + + self._name = name + + @property + def volume_mounts(self): + """Gets the volume_mounts of this KubeflowOrgV2alpha1ContainerOverride. # noqa: E501 + + Pod volumes to mount into the container's filesystem. # noqa: E501 + + :return: The volume_mounts of this KubeflowOrgV2alpha1ContainerOverride. # noqa: E501 + :rtype: list[V1VolumeMount] + """ + return self._volume_mounts + + @volume_mounts.setter + def volume_mounts(self, volume_mounts): + """Sets the volume_mounts of this KubeflowOrgV2alpha1ContainerOverride. + + Pod volumes to mount into the container's filesystem. # noqa: E501 + + :param volume_mounts: The volume_mounts of this KubeflowOrgV2alpha1ContainerOverride. # noqa: E501 + :type: list[V1VolumeMount] + """ + + self._volume_mounts = volume_mounts + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, KubeflowOrgV2alpha1ContainerOverride): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, KubeflowOrgV2alpha1ContainerOverride): + return True + + return self.to_dict() != other.to_dict() diff --git a/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_coscheduling_pod_group_policy_source.py b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_coscheduling_pod_group_policy_source.py new file mode 100644 index 0000000000..694f1a0076 --- /dev/null +++ b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_coscheduling_pod_group_policy_source.py @@ -0,0 +1,122 @@ +# coding: utf-8 + +""" + Kubeflow Training OpenAPI Spec + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from kubeflow.training.configuration import Configuration + + +class KubeflowOrgV2alpha1CoschedulingPodGroupPolicySource(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = { + 'schedule_timeout_seconds': 'int' + } + + attribute_map = { + 'schedule_timeout_seconds': 'scheduleTimeoutSeconds' + } + + def __init__(self, schedule_timeout_seconds=None, local_vars_configuration=None): # noqa: E501 + """KubeflowOrgV2alpha1CoschedulingPodGroupPolicySource - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._schedule_timeout_seconds = None + self.discriminator = None + + if schedule_timeout_seconds is not None: + self.schedule_timeout_seconds = schedule_timeout_seconds + + @property + def schedule_timeout_seconds(self): + """Gets the schedule_timeout_seconds of this KubeflowOrgV2alpha1CoschedulingPodGroupPolicySource. # noqa: E501 + + Time threshold to schedule PodGroup for gang-scheduling. If the scheduling timeout is equal to 0, the default value is used. Defaults to 60 seconds. # noqa: E501 + + :return: The schedule_timeout_seconds of this KubeflowOrgV2alpha1CoschedulingPodGroupPolicySource. # noqa: E501 + :rtype: int + """ + return self._schedule_timeout_seconds + + @schedule_timeout_seconds.setter + def schedule_timeout_seconds(self, schedule_timeout_seconds): + """Sets the schedule_timeout_seconds of this KubeflowOrgV2alpha1CoschedulingPodGroupPolicySource. + + Time threshold to schedule PodGroup for gang-scheduling. If the scheduling timeout is equal to 0, the default value is used. Defaults to 60 seconds. # noqa: E501 + + :param schedule_timeout_seconds: The schedule_timeout_seconds of this KubeflowOrgV2alpha1CoschedulingPodGroupPolicySource. # noqa: E501 + :type: int + """ + + self._schedule_timeout_seconds = schedule_timeout_seconds + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, KubeflowOrgV2alpha1CoschedulingPodGroupPolicySource): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, KubeflowOrgV2alpha1CoschedulingPodGroupPolicySource): + return True + + return self.to_dict() != other.to_dict() diff --git a/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_dataset_config.py b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_dataset_config.py new file mode 100644 index 0000000000..406bcebca6 --- /dev/null +++ b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_dataset_config.py @@ -0,0 +1,176 @@ +# coding: utf-8 + +""" + Kubeflow Training OpenAPI Spec + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from kubeflow.training.configuration import Configuration + + +class KubeflowOrgV2alpha1DatasetConfig(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = { + 'env': 'list[V1EnvVar]', + 'secret_ref': 'V1SecretReference', + 'storage_uri': 'str' + } + + attribute_map = { + 'env': 'env', + 'secret_ref': 'secretRef', + 'storage_uri': 'storageUri' + } + + def __init__(self, env=None, secret_ref=None, storage_uri=None, local_vars_configuration=None): # noqa: E501 + """KubeflowOrgV2alpha1DatasetConfig - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._env = None + self._secret_ref = None + self._storage_uri = None + self.discriminator = None + + if env is not None: + self.env = env + if secret_ref is not None: + self.secret_ref = secret_ref + if storage_uri is not None: + self.storage_uri = storage_uri + + @property + def env(self): + """Gets the env of this KubeflowOrgV2alpha1DatasetConfig. # noqa: E501 + + List of environment variables to set in the dataset initializer container. These values will be merged with the TrainingRuntime's dataset initializer environments. # noqa: E501 + + :return: The env of this KubeflowOrgV2alpha1DatasetConfig. # noqa: E501 + :rtype: list[V1EnvVar] + """ + return self._env + + @env.setter + def env(self, env): + """Sets the env of this KubeflowOrgV2alpha1DatasetConfig. + + List of environment variables to set in the dataset initializer container. These values will be merged with the TrainingRuntime's dataset initializer environments. # noqa: E501 + + :param env: The env of this KubeflowOrgV2alpha1DatasetConfig. # noqa: E501 + :type: list[V1EnvVar] + """ + + self._env = env + + @property + def secret_ref(self): + """Gets the secret_ref of this KubeflowOrgV2alpha1DatasetConfig. # noqa: E501 + + + :return: The secret_ref of this KubeflowOrgV2alpha1DatasetConfig. # noqa: E501 + :rtype: V1SecretReference + """ + return self._secret_ref + + @secret_ref.setter + def secret_ref(self, secret_ref): + """Sets the secret_ref of this KubeflowOrgV2alpha1DatasetConfig. + + + :param secret_ref: The secret_ref of this KubeflowOrgV2alpha1DatasetConfig. # noqa: E501 + :type: V1SecretReference + """ + + self._secret_ref = secret_ref + + @property + def storage_uri(self): + """Gets the storage_uri of this KubeflowOrgV2alpha1DatasetConfig. # noqa: E501 + + Storage uri for the dataset provider. # noqa: E501 + + :return: The storage_uri of this KubeflowOrgV2alpha1DatasetConfig. # noqa: E501 + :rtype: str + """ + return self._storage_uri + + @storage_uri.setter + def storage_uri(self, storage_uri): + """Sets the storage_uri of this KubeflowOrgV2alpha1DatasetConfig. + + Storage uri for the dataset provider. # noqa: E501 + + :param storage_uri: The storage_uri of this KubeflowOrgV2alpha1DatasetConfig. # noqa: E501 + :type: str + """ + + self._storage_uri = storage_uri + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, KubeflowOrgV2alpha1DatasetConfig): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, KubeflowOrgV2alpha1DatasetConfig): + return True + + return self.to_dict() != other.to_dict() diff --git a/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_input_model.py b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_input_model.py new file mode 100644 index 0000000000..3a06d04596 --- /dev/null +++ b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_input_model.py @@ -0,0 +1,176 @@ +# coding: utf-8 + +""" + Kubeflow Training OpenAPI Spec + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from kubeflow.training.configuration import Configuration + + +class KubeflowOrgV2alpha1InputModel(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = { + 'env': 'list[V1EnvVar]', + 'secret_ref': 'V1SecretReference', + 'storage_uri': 'str' + } + + attribute_map = { + 'env': 'env', + 'secret_ref': 'secretRef', + 'storage_uri': 'storageUri' + } + + def __init__(self, env=None, secret_ref=None, storage_uri=None, local_vars_configuration=None): # noqa: E501 + """KubeflowOrgV2alpha1InputModel - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._env = None + self._secret_ref = None + self._storage_uri = None + self.discriminator = None + + if env is not None: + self.env = env + if secret_ref is not None: + self.secret_ref = secret_ref + if storage_uri is not None: + self.storage_uri = storage_uri + + @property + def env(self): + """Gets the env of this KubeflowOrgV2alpha1InputModel. # noqa: E501 + + List of environment variables to set in the model initializer container. These values will be merged with the TrainingRuntime's model initializer environments. # noqa: E501 + + :return: The env of this KubeflowOrgV2alpha1InputModel. # noqa: E501 + :rtype: list[V1EnvVar] + """ + return self._env + + @env.setter + def env(self, env): + """Sets the env of this KubeflowOrgV2alpha1InputModel. + + List of environment variables to set in the model initializer container. These values will be merged with the TrainingRuntime's model initializer environments. # noqa: E501 + + :param env: The env of this KubeflowOrgV2alpha1InputModel. # noqa: E501 + :type: list[V1EnvVar] + """ + + self._env = env + + @property + def secret_ref(self): + """Gets the secret_ref of this KubeflowOrgV2alpha1InputModel. # noqa: E501 + + + :return: The secret_ref of this KubeflowOrgV2alpha1InputModel. # noqa: E501 + :rtype: V1SecretReference + """ + return self._secret_ref + + @secret_ref.setter + def secret_ref(self, secret_ref): + """Sets the secret_ref of this KubeflowOrgV2alpha1InputModel. + + + :param secret_ref: The secret_ref of this KubeflowOrgV2alpha1InputModel. # noqa: E501 + :type: V1SecretReference + """ + + self._secret_ref = secret_ref + + @property + def storage_uri(self): + """Gets the storage_uri of this KubeflowOrgV2alpha1InputModel. # noqa: E501 + + Storage uri for the model provider. # noqa: E501 + + :return: The storage_uri of this KubeflowOrgV2alpha1InputModel. # noqa: E501 + :rtype: str + """ + return self._storage_uri + + @storage_uri.setter + def storage_uri(self, storage_uri): + """Sets the storage_uri of this KubeflowOrgV2alpha1InputModel. + + Storage uri for the model provider. # noqa: E501 + + :param storage_uri: The storage_uri of this KubeflowOrgV2alpha1InputModel. # noqa: E501 + :type: str + """ + + self._storage_uri = storage_uri + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, KubeflowOrgV2alpha1InputModel): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, KubeflowOrgV2alpha1InputModel): + return True + + return self.to_dict() != other.to_dict() diff --git a/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_job_set_template_spec.py b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_job_set_template_spec.py new file mode 100644 index 0000000000..550dd0a1c8 --- /dev/null +++ b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_job_set_template_spec.py @@ -0,0 +1,146 @@ +# coding: utf-8 + +""" + Kubeflow Training OpenAPI Spec + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from kubeflow.training.configuration import Configuration + + +class KubeflowOrgV2alpha1JobSetTemplateSpec(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = { + 'metadata': 'V1ObjectMeta', + 'spec': 'SigsK8sIoJobsetApiJobsetV1alpha2JobSetSpec' + } + + attribute_map = { + 'metadata': 'metadata', + 'spec': 'spec' + } + + def __init__(self, metadata=None, spec=None, local_vars_configuration=None): # noqa: E501 + """KubeflowOrgV2alpha1JobSetTemplateSpec - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._metadata = None + self._spec = None + self.discriminator = None + + if metadata is not None: + self.metadata = metadata + if spec is not None: + self.spec = spec + + @property + def metadata(self): + """Gets the metadata of this KubeflowOrgV2alpha1JobSetTemplateSpec. # noqa: E501 + + + :return: The metadata of this KubeflowOrgV2alpha1JobSetTemplateSpec. # noqa: E501 + :rtype: V1ObjectMeta + """ + return self._metadata + + @metadata.setter + def metadata(self, metadata): + """Sets the metadata of this KubeflowOrgV2alpha1JobSetTemplateSpec. + + + :param metadata: The metadata of this KubeflowOrgV2alpha1JobSetTemplateSpec. # noqa: E501 + :type: V1ObjectMeta + """ + + self._metadata = metadata + + @property + def spec(self): + """Gets the spec of this KubeflowOrgV2alpha1JobSetTemplateSpec. # noqa: E501 + + + :return: The spec of this KubeflowOrgV2alpha1JobSetTemplateSpec. # noqa: E501 + :rtype: SigsK8sIoJobsetApiJobsetV1alpha2JobSetSpec + """ + return self._spec + + @spec.setter + def spec(self, spec): + """Sets the spec of this KubeflowOrgV2alpha1JobSetTemplateSpec. + + + :param spec: The spec of this KubeflowOrgV2alpha1JobSetTemplateSpec. # noqa: E501 + :type: SigsK8sIoJobsetApiJobsetV1alpha2JobSetSpec + """ + + self._spec = spec + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, KubeflowOrgV2alpha1JobSetTemplateSpec): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, KubeflowOrgV2alpha1JobSetTemplateSpec): + return True + + return self.to_dict() != other.to_dict() diff --git a/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_job_status.py b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_job_status.py new file mode 100644 index 0000000000..c9a5b52851 --- /dev/null +++ b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_job_status.py @@ -0,0 +1,268 @@ +# coding: utf-8 + +""" + Kubeflow Training OpenAPI Spec + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from kubeflow.training.configuration import Configuration + + +class KubeflowOrgV2alpha1JobStatus(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = { + 'active': 'int', + 'failed': 'int', + 'name': 'str', + 'ready': 'int', + 'succeeded': 'int', + 'suspended': 'int' + } + + attribute_map = { + 'active': 'active', + 'failed': 'failed', + 'name': 'name', + 'ready': 'ready', + 'succeeded': 'succeeded', + 'suspended': 'suspended' + } + + def __init__(self, active=0, failed=0, name='', ready=0, succeeded=0, suspended=0, local_vars_configuration=None): # noqa: E501 + """KubeflowOrgV2alpha1JobStatus - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._active = None + self._failed = None + self._name = None + self._ready = None + self._succeeded = None + self._suspended = None + self.discriminator = None + + self.active = active + self.failed = failed + self.name = name + self.ready = ready + self.succeeded = succeeded + self.suspended = suspended + + @property + def active(self): + """Gets the active of this KubeflowOrgV2alpha1JobStatus. # noqa: E501 + + Active is the number of child Jobs with at least 1 pod in a running or pending state which are not marked for deletion. # noqa: E501 + + :return: The active of this KubeflowOrgV2alpha1JobStatus. # noqa: E501 + :rtype: int + """ + return self._active + + @active.setter + def active(self, active): + """Sets the active of this KubeflowOrgV2alpha1JobStatus. + + Active is the number of child Jobs with at least 1 pod in a running or pending state which are not marked for deletion. # noqa: E501 + + :param active: The active of this KubeflowOrgV2alpha1JobStatus. # noqa: E501 + :type: int + """ + if self.local_vars_configuration.client_side_validation and active is None: # noqa: E501 + raise ValueError("Invalid value for `active`, must not be `None`") # noqa: E501 + + self._active = active + + @property + def failed(self): + """Gets the failed of this KubeflowOrgV2alpha1JobStatus. # noqa: E501 + + Failed is the number of failed child Jobs. # noqa: E501 + + :return: The failed of this KubeflowOrgV2alpha1JobStatus. # noqa: E501 + :rtype: int + """ + return self._failed + + @failed.setter + def failed(self, failed): + """Sets the failed of this KubeflowOrgV2alpha1JobStatus. + + Failed is the number of failed child Jobs. # noqa: E501 + + :param failed: The failed of this KubeflowOrgV2alpha1JobStatus. # noqa: E501 + :type: int + """ + if self.local_vars_configuration.client_side_validation and failed is None: # noqa: E501 + raise ValueError("Invalid value for `failed`, must not be `None`") # noqa: E501 + + self._failed = failed + + @property + def name(self): + """Gets the name of this KubeflowOrgV2alpha1JobStatus. # noqa: E501 + + Name of the child Job. # noqa: E501 + + :return: The name of this KubeflowOrgV2alpha1JobStatus. # noqa: E501 + :rtype: str + """ + return self._name + + @name.setter + def name(self, name): + """Sets the name of this KubeflowOrgV2alpha1JobStatus. + + Name of the child Job. # noqa: E501 + + :param name: The name of this KubeflowOrgV2alpha1JobStatus. # noqa: E501 + :type: str + """ + if self.local_vars_configuration.client_side_validation and name is None: # noqa: E501 + raise ValueError("Invalid value for `name`, must not be `None`") # noqa: E501 + + self._name = name + + @property + def ready(self): + """Gets the ready of this KubeflowOrgV2alpha1JobStatus. # noqa: E501 + + Ready is the number of child Jobs where the number of ready pods and completed pods is greater than or equal to the total expected pod count for the child Job. # noqa: E501 + + :return: The ready of this KubeflowOrgV2alpha1JobStatus. # noqa: E501 + :rtype: int + """ + return self._ready + + @ready.setter + def ready(self, ready): + """Sets the ready of this KubeflowOrgV2alpha1JobStatus. + + Ready is the number of child Jobs where the number of ready pods and completed pods is greater than or equal to the total expected pod count for the child Job. # noqa: E501 + + :param ready: The ready of this KubeflowOrgV2alpha1JobStatus. # noqa: E501 + :type: int + """ + if self.local_vars_configuration.client_side_validation and ready is None: # noqa: E501 + raise ValueError("Invalid value for `ready`, must not be `None`") # noqa: E501 + + self._ready = ready + + @property + def succeeded(self): + """Gets the succeeded of this KubeflowOrgV2alpha1JobStatus. # noqa: E501 + + Succeeded is the number of successfully completed child Jobs. # noqa: E501 + + :return: The succeeded of this KubeflowOrgV2alpha1JobStatus. # noqa: E501 + :rtype: int + """ + return self._succeeded + + @succeeded.setter + def succeeded(self, succeeded): + """Sets the succeeded of this KubeflowOrgV2alpha1JobStatus. + + Succeeded is the number of successfully completed child Jobs. # noqa: E501 + + :param succeeded: The succeeded of this KubeflowOrgV2alpha1JobStatus. # noqa: E501 + :type: int + """ + if self.local_vars_configuration.client_side_validation and succeeded is None: # noqa: E501 + raise ValueError("Invalid value for `succeeded`, must not be `None`") # noqa: E501 + + self._succeeded = succeeded + + @property + def suspended(self): + """Gets the suspended of this KubeflowOrgV2alpha1JobStatus. # noqa: E501 + + Suspended is the number of child Jobs which are in a suspended state. # noqa: E501 + + :return: The suspended of this KubeflowOrgV2alpha1JobStatus. # noqa: E501 + :rtype: int + """ + return self._suspended + + @suspended.setter + def suspended(self, suspended): + """Sets the suspended of this KubeflowOrgV2alpha1JobStatus. + + Suspended is the number of child Jobs which are in a suspended state. # noqa: E501 + + :param suspended: The suspended of this KubeflowOrgV2alpha1JobStatus. # noqa: E501 + :type: int + """ + if self.local_vars_configuration.client_side_validation and suspended is None: # noqa: E501 + raise ValueError("Invalid value for `suspended`, must not be `None`") # noqa: E501 + + self._suspended = suspended + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, KubeflowOrgV2alpha1JobStatus): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, KubeflowOrgV2alpha1JobStatus): + return True + + return self.to_dict() != other.to_dict() diff --git a/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_ml_policy.py b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_ml_policy.py new file mode 100644 index 0000000000..d01314a38d --- /dev/null +++ b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_ml_policy.py @@ -0,0 +1,174 @@ +# coding: utf-8 + +""" + Kubeflow Training OpenAPI Spec + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from kubeflow.training.configuration import Configuration + + +class KubeflowOrgV2alpha1MLPolicy(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = { + 'mpi': 'KubeflowOrgV2alpha1MPIMLPolicySource', + 'num_nodes': 'int', + 'torch': 'KubeflowOrgV2alpha1TorchMLPolicySource' + } + + attribute_map = { + 'mpi': 'mpi', + 'num_nodes': 'numNodes', + 'torch': 'torch' + } + + def __init__(self, mpi=None, num_nodes=None, torch=None, local_vars_configuration=None): # noqa: E501 + """KubeflowOrgV2alpha1MLPolicy - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._mpi = None + self._num_nodes = None + self._torch = None + self.discriminator = None + + if mpi is not None: + self.mpi = mpi + if num_nodes is not None: + self.num_nodes = num_nodes + if torch is not None: + self.torch = torch + + @property + def mpi(self): + """Gets the mpi of this KubeflowOrgV2alpha1MLPolicy. # noqa: E501 + + + :return: The mpi of this KubeflowOrgV2alpha1MLPolicy. # noqa: E501 + :rtype: KubeflowOrgV2alpha1MPIMLPolicySource + """ + return self._mpi + + @mpi.setter + def mpi(self, mpi): + """Sets the mpi of this KubeflowOrgV2alpha1MLPolicy. + + + :param mpi: The mpi of this KubeflowOrgV2alpha1MLPolicy. # noqa: E501 + :type: KubeflowOrgV2alpha1MPIMLPolicySource + """ + + self._mpi = mpi + + @property + def num_nodes(self): + """Gets the num_nodes of this KubeflowOrgV2alpha1MLPolicy. # noqa: E501 + + Number of training nodes. Defaults to 1. # noqa: E501 + + :return: The num_nodes of this KubeflowOrgV2alpha1MLPolicy. # noqa: E501 + :rtype: int + """ + return self._num_nodes + + @num_nodes.setter + def num_nodes(self, num_nodes): + """Sets the num_nodes of this KubeflowOrgV2alpha1MLPolicy. + + Number of training nodes. Defaults to 1. # noqa: E501 + + :param num_nodes: The num_nodes of this KubeflowOrgV2alpha1MLPolicy. # noqa: E501 + :type: int + """ + + self._num_nodes = num_nodes + + @property + def torch(self): + """Gets the torch of this KubeflowOrgV2alpha1MLPolicy. # noqa: E501 + + + :return: The torch of this KubeflowOrgV2alpha1MLPolicy. # noqa: E501 + :rtype: KubeflowOrgV2alpha1TorchMLPolicySource + """ + return self._torch + + @torch.setter + def torch(self, torch): + """Sets the torch of this KubeflowOrgV2alpha1MLPolicy. + + + :param torch: The torch of this KubeflowOrgV2alpha1MLPolicy. # noqa: E501 + :type: KubeflowOrgV2alpha1TorchMLPolicySource + """ + + self._torch = torch + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, KubeflowOrgV2alpha1MLPolicy): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, KubeflowOrgV2alpha1MLPolicy): + return True + + return self.to_dict() != other.to_dict() diff --git a/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_ml_policy_source.py b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_ml_policy_source.py new file mode 100644 index 0000000000..e8953cb810 --- /dev/null +++ b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_ml_policy_source.py @@ -0,0 +1,146 @@ +# coding: utf-8 + +""" + Kubeflow Training OpenAPI Spec + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from kubeflow.training.configuration import Configuration + + +class KubeflowOrgV2alpha1MLPolicySource(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = { + 'mpi': 'KubeflowOrgV2alpha1MPIMLPolicySource', + 'torch': 'KubeflowOrgV2alpha1TorchMLPolicySource' + } + + attribute_map = { + 'mpi': 'mpi', + 'torch': 'torch' + } + + def __init__(self, mpi=None, torch=None, local_vars_configuration=None): # noqa: E501 + """KubeflowOrgV2alpha1MLPolicySource - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._mpi = None + self._torch = None + self.discriminator = None + + if mpi is not None: + self.mpi = mpi + if torch is not None: + self.torch = torch + + @property + def mpi(self): + """Gets the mpi of this KubeflowOrgV2alpha1MLPolicySource. # noqa: E501 + + + :return: The mpi of this KubeflowOrgV2alpha1MLPolicySource. # noqa: E501 + :rtype: KubeflowOrgV2alpha1MPIMLPolicySource + """ + return self._mpi + + @mpi.setter + def mpi(self, mpi): + """Sets the mpi of this KubeflowOrgV2alpha1MLPolicySource. + + + :param mpi: The mpi of this KubeflowOrgV2alpha1MLPolicySource. # noqa: E501 + :type: KubeflowOrgV2alpha1MPIMLPolicySource + """ + + self._mpi = mpi + + @property + def torch(self): + """Gets the torch of this KubeflowOrgV2alpha1MLPolicySource. # noqa: E501 + + + :return: The torch of this KubeflowOrgV2alpha1MLPolicySource. # noqa: E501 + :rtype: KubeflowOrgV2alpha1TorchMLPolicySource + """ + return self._torch + + @torch.setter + def torch(self, torch): + """Sets the torch of this KubeflowOrgV2alpha1MLPolicySource. + + + :param torch: The torch of this KubeflowOrgV2alpha1MLPolicySource. # noqa: E501 + :type: KubeflowOrgV2alpha1TorchMLPolicySource + """ + + self._torch = torch + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, KubeflowOrgV2alpha1MLPolicySource): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, KubeflowOrgV2alpha1MLPolicySource): + return True + + return self.to_dict() != other.to_dict() diff --git a/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_model_config.py b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_model_config.py new file mode 100644 index 0000000000..6ac362cbe0 --- /dev/null +++ b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_model_config.py @@ -0,0 +1,146 @@ +# coding: utf-8 + +""" + Kubeflow Training OpenAPI Spec + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from kubeflow.training.configuration import Configuration + + +class KubeflowOrgV2alpha1ModelConfig(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = { + 'input': 'KubeflowOrgV2alpha1InputModel', + 'output': 'KubeflowOrgV2alpha1OutputModel' + } + + attribute_map = { + 'input': 'input', + 'output': 'output' + } + + def __init__(self, input=None, output=None, local_vars_configuration=None): # noqa: E501 + """KubeflowOrgV2alpha1ModelConfig - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._input = None + self._output = None + self.discriminator = None + + if input is not None: + self.input = input + if output is not None: + self.output = output + + @property + def input(self): + """Gets the input of this KubeflowOrgV2alpha1ModelConfig. # noqa: E501 + + + :return: The input of this KubeflowOrgV2alpha1ModelConfig. # noqa: E501 + :rtype: KubeflowOrgV2alpha1InputModel + """ + return self._input + + @input.setter + def input(self, input): + """Sets the input of this KubeflowOrgV2alpha1ModelConfig. + + + :param input: The input of this KubeflowOrgV2alpha1ModelConfig. # noqa: E501 + :type: KubeflowOrgV2alpha1InputModel + """ + + self._input = input + + @property + def output(self): + """Gets the output of this KubeflowOrgV2alpha1ModelConfig. # noqa: E501 + + + :return: The output of this KubeflowOrgV2alpha1ModelConfig. # noqa: E501 + :rtype: KubeflowOrgV2alpha1OutputModel + """ + return self._output + + @output.setter + def output(self, output): + """Sets the output of this KubeflowOrgV2alpha1ModelConfig. + + + :param output: The output of this KubeflowOrgV2alpha1ModelConfig. # noqa: E501 + :type: KubeflowOrgV2alpha1OutputModel + """ + + self._output = output + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, KubeflowOrgV2alpha1ModelConfig): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, KubeflowOrgV2alpha1ModelConfig): + return True + + return self.to_dict() != other.to_dict() diff --git a/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_mpiml_policy_source.py b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_mpiml_policy_source.py new file mode 100644 index 0000000000..063b72f1e2 --- /dev/null +++ b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_mpiml_policy_source.py @@ -0,0 +1,206 @@ +# coding: utf-8 + +""" + Kubeflow Training OpenAPI Spec + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from kubeflow.training.configuration import Configuration + + +class KubeflowOrgV2alpha1MPIMLPolicySource(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = { + 'ssh_auth_mount_path': 'str', + 'mpi_implementation': 'str', + 'num_proc_per_node': 'int', + 'run_launcher_as_node': 'bool' + } + + attribute_map = { + 'ssh_auth_mount_path': 'SSHAuthMountPath', + 'mpi_implementation': 'mpiImplementation', + 'num_proc_per_node': 'numProcPerNode', + 'run_launcher_as_node': 'runLauncherAsNode' + } + + def __init__(self, ssh_auth_mount_path=None, mpi_implementation=None, num_proc_per_node=None, run_launcher_as_node=None, local_vars_configuration=None): # noqa: E501 + """KubeflowOrgV2alpha1MPIMLPolicySource - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._ssh_auth_mount_path = None + self._mpi_implementation = None + self._num_proc_per_node = None + self._run_launcher_as_node = None + self.discriminator = None + + if ssh_auth_mount_path is not None: + self.ssh_auth_mount_path = ssh_auth_mount_path + if mpi_implementation is not None: + self.mpi_implementation = mpi_implementation + if num_proc_per_node is not None: + self.num_proc_per_node = num_proc_per_node + if run_launcher_as_node is not None: + self.run_launcher_as_node = run_launcher_as_node + + @property + def ssh_auth_mount_path(self): + """Gets the ssh_auth_mount_path of this KubeflowOrgV2alpha1MPIMLPolicySource. # noqa: E501 + + Directory where SSH keys are mounted. # noqa: E501 + + :return: The ssh_auth_mount_path of this KubeflowOrgV2alpha1MPIMLPolicySource. # noqa: E501 + :rtype: str + """ + return self._ssh_auth_mount_path + + @ssh_auth_mount_path.setter + def ssh_auth_mount_path(self, ssh_auth_mount_path): + """Sets the ssh_auth_mount_path of this KubeflowOrgV2alpha1MPIMLPolicySource. + + Directory where SSH keys are mounted. # noqa: E501 + + :param ssh_auth_mount_path: The ssh_auth_mount_path of this KubeflowOrgV2alpha1MPIMLPolicySource. # noqa: E501 + :type: str + """ + + self._ssh_auth_mount_path = ssh_auth_mount_path + + @property + def mpi_implementation(self): + """Gets the mpi_implementation of this KubeflowOrgV2alpha1MPIMLPolicySource. # noqa: E501 + + Implementation name for the MPI to create the appropriate hostfile. Defaults to OpenMPI. # noqa: E501 + + :return: The mpi_implementation of this KubeflowOrgV2alpha1MPIMLPolicySource. # noqa: E501 + :rtype: str + """ + return self._mpi_implementation + + @mpi_implementation.setter + def mpi_implementation(self, mpi_implementation): + """Sets the mpi_implementation of this KubeflowOrgV2alpha1MPIMLPolicySource. + + Implementation name for the MPI to create the appropriate hostfile. Defaults to OpenMPI. # noqa: E501 + + :param mpi_implementation: The mpi_implementation of this KubeflowOrgV2alpha1MPIMLPolicySource. # noqa: E501 + :type: str + """ + + self._mpi_implementation = mpi_implementation + + @property + def num_proc_per_node(self): + """Gets the num_proc_per_node of this KubeflowOrgV2alpha1MPIMLPolicySource. # noqa: E501 + + Number of processes per node. This value is equal to the number of slots for each node in the hostfile. # noqa: E501 + + :return: The num_proc_per_node of this KubeflowOrgV2alpha1MPIMLPolicySource. # noqa: E501 + :rtype: int + """ + return self._num_proc_per_node + + @num_proc_per_node.setter + def num_proc_per_node(self, num_proc_per_node): + """Sets the num_proc_per_node of this KubeflowOrgV2alpha1MPIMLPolicySource. + + Number of processes per node. This value is equal to the number of slots for each node in the hostfile. # noqa: E501 + + :param num_proc_per_node: The num_proc_per_node of this KubeflowOrgV2alpha1MPIMLPolicySource. # noqa: E501 + :type: int + """ + + self._num_proc_per_node = num_proc_per_node + + @property + def run_launcher_as_node(self): + """Gets the run_launcher_as_node of this KubeflowOrgV2alpha1MPIMLPolicySource. # noqa: E501 + + Whether to run training process on the launcher Job. Defaults to false. # noqa: E501 + + :return: The run_launcher_as_node of this KubeflowOrgV2alpha1MPIMLPolicySource. # noqa: E501 + :rtype: bool + """ + return self._run_launcher_as_node + + @run_launcher_as_node.setter + def run_launcher_as_node(self, run_launcher_as_node): + """Sets the run_launcher_as_node of this KubeflowOrgV2alpha1MPIMLPolicySource. + + Whether to run training process on the launcher Job. Defaults to false. # noqa: E501 + + :param run_launcher_as_node: The run_launcher_as_node of this KubeflowOrgV2alpha1MPIMLPolicySource. # noqa: E501 + :type: bool + """ + + self._run_launcher_as_node = run_launcher_as_node + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, KubeflowOrgV2alpha1MPIMLPolicySource): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, KubeflowOrgV2alpha1MPIMLPolicySource): + return True + + return self.to_dict() != other.to_dict() diff --git a/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_output_model.py b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_output_model.py new file mode 100644 index 0000000000..501fcb39ab --- /dev/null +++ b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_output_model.py @@ -0,0 +1,176 @@ +# coding: utf-8 + +""" + Kubeflow Training OpenAPI Spec + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from kubeflow.training.configuration import Configuration + + +class KubeflowOrgV2alpha1OutputModel(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = { + 'env': 'list[V1EnvVar]', + 'secret_ref': 'V1SecretReference', + 'storage_uri': 'str' + } + + attribute_map = { + 'env': 'env', + 'secret_ref': 'secretRef', + 'storage_uri': 'storageUri' + } + + def __init__(self, env=None, secret_ref=None, storage_uri=None, local_vars_configuration=None): # noqa: E501 + """KubeflowOrgV2alpha1OutputModel - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._env = None + self._secret_ref = None + self._storage_uri = None + self.discriminator = None + + if env is not None: + self.env = env + if secret_ref is not None: + self.secret_ref = secret_ref + if storage_uri is not None: + self.storage_uri = storage_uri + + @property + def env(self): + """Gets the env of this KubeflowOrgV2alpha1OutputModel. # noqa: E501 + + List of environment variables to set in the model exporter container. These values will be merged with the TrainingRuntime's model exporter environments. # noqa: E501 + + :return: The env of this KubeflowOrgV2alpha1OutputModel. # noqa: E501 + :rtype: list[V1EnvVar] + """ + return self._env + + @env.setter + def env(self, env): + """Sets the env of this KubeflowOrgV2alpha1OutputModel. + + List of environment variables to set in the model exporter container. These values will be merged with the TrainingRuntime's model exporter environments. # noqa: E501 + + :param env: The env of this KubeflowOrgV2alpha1OutputModel. # noqa: E501 + :type: list[V1EnvVar] + """ + + self._env = env + + @property + def secret_ref(self): + """Gets the secret_ref of this KubeflowOrgV2alpha1OutputModel. # noqa: E501 + + + :return: The secret_ref of this KubeflowOrgV2alpha1OutputModel. # noqa: E501 + :rtype: V1SecretReference + """ + return self._secret_ref + + @secret_ref.setter + def secret_ref(self, secret_ref): + """Sets the secret_ref of this KubeflowOrgV2alpha1OutputModel. + + + :param secret_ref: The secret_ref of this KubeflowOrgV2alpha1OutputModel. # noqa: E501 + :type: V1SecretReference + """ + + self._secret_ref = secret_ref + + @property + def storage_uri(self): + """Gets the storage_uri of this KubeflowOrgV2alpha1OutputModel. # noqa: E501 + + Storage uri for the model exporter. # noqa: E501 + + :return: The storage_uri of this KubeflowOrgV2alpha1OutputModel. # noqa: E501 + :rtype: str + """ + return self._storage_uri + + @storage_uri.setter + def storage_uri(self, storage_uri): + """Sets the storage_uri of this KubeflowOrgV2alpha1OutputModel. + + Storage uri for the model exporter. # noqa: E501 + + :param storage_uri: The storage_uri of this KubeflowOrgV2alpha1OutputModel. # noqa: E501 + :type: str + """ + + self._storage_uri = storage_uri + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, KubeflowOrgV2alpha1OutputModel): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, KubeflowOrgV2alpha1OutputModel): + return True + + return self.to_dict() != other.to_dict() diff --git a/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_pod_group_policy.py b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_pod_group_policy.py new file mode 100644 index 0000000000..46bb200a21 --- /dev/null +++ b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_pod_group_policy.py @@ -0,0 +1,120 @@ +# coding: utf-8 + +""" + Kubeflow Training OpenAPI Spec + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from kubeflow.training.configuration import Configuration + + +class KubeflowOrgV2alpha1PodGroupPolicy(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = { + 'coscheduling': 'KubeflowOrgV2alpha1CoschedulingPodGroupPolicySource' + } + + attribute_map = { + 'coscheduling': 'coscheduling' + } + + def __init__(self, coscheduling=None, local_vars_configuration=None): # noqa: E501 + """KubeflowOrgV2alpha1PodGroupPolicy - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._coscheduling = None + self.discriminator = None + + if coscheduling is not None: + self.coscheduling = coscheduling + + @property + def coscheduling(self): + """Gets the coscheduling of this KubeflowOrgV2alpha1PodGroupPolicy. # noqa: E501 + + + :return: The coscheduling of this KubeflowOrgV2alpha1PodGroupPolicy. # noqa: E501 + :rtype: KubeflowOrgV2alpha1CoschedulingPodGroupPolicySource + """ + return self._coscheduling + + @coscheduling.setter + def coscheduling(self, coscheduling): + """Sets the coscheduling of this KubeflowOrgV2alpha1PodGroupPolicy. + + + :param coscheduling: The coscheduling of this KubeflowOrgV2alpha1PodGroupPolicy. # noqa: E501 + :type: KubeflowOrgV2alpha1CoschedulingPodGroupPolicySource + """ + + self._coscheduling = coscheduling + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, KubeflowOrgV2alpha1PodGroupPolicy): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, KubeflowOrgV2alpha1PodGroupPolicy): + return True + + return self.to_dict() != other.to_dict() diff --git a/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_pod_group_policy_source.py b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_pod_group_policy_source.py new file mode 100644 index 0000000000..2fcceae7f1 --- /dev/null +++ b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_pod_group_policy_source.py @@ -0,0 +1,120 @@ +# coding: utf-8 + +""" + Kubeflow Training OpenAPI Spec + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from kubeflow.training.configuration import Configuration + + +class KubeflowOrgV2alpha1PodGroupPolicySource(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = { + 'coscheduling': 'KubeflowOrgV2alpha1CoschedulingPodGroupPolicySource' + } + + attribute_map = { + 'coscheduling': 'coscheduling' + } + + def __init__(self, coscheduling=None, local_vars_configuration=None): # noqa: E501 + """KubeflowOrgV2alpha1PodGroupPolicySource - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._coscheduling = None + self.discriminator = None + + if coscheduling is not None: + self.coscheduling = coscheduling + + @property + def coscheduling(self): + """Gets the coscheduling of this KubeflowOrgV2alpha1PodGroupPolicySource. # noqa: E501 + + + :return: The coscheduling of this KubeflowOrgV2alpha1PodGroupPolicySource. # noqa: E501 + :rtype: KubeflowOrgV2alpha1CoschedulingPodGroupPolicySource + """ + return self._coscheduling + + @coscheduling.setter + def coscheduling(self, coscheduling): + """Sets the coscheduling of this KubeflowOrgV2alpha1PodGroupPolicySource. + + + :param coscheduling: The coscheduling of this KubeflowOrgV2alpha1PodGroupPolicySource. # noqa: E501 + :type: KubeflowOrgV2alpha1CoschedulingPodGroupPolicySource + """ + + self._coscheduling = coscheduling + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, KubeflowOrgV2alpha1PodGroupPolicySource): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, KubeflowOrgV2alpha1PodGroupPolicySource): + return True + + return self.to_dict() != other.to_dict() diff --git a/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_pod_spec_override.py b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_pod_spec_override.py new file mode 100644 index 0000000000..8b137acf0d --- /dev/null +++ b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_pod_spec_override.py @@ -0,0 +1,291 @@ +# coding: utf-8 + +""" + Kubeflow Training OpenAPI Spec + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from kubeflow.training.configuration import Configuration + + +class KubeflowOrgV2alpha1PodSpecOverride(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = { + 'containers': 'list[KubeflowOrgV2alpha1ContainerOverride]', + 'init_containers': 'list[KubeflowOrgV2alpha1ContainerOverride]', + 'node_selector': 'dict(str, str)', + 'service_account_name': 'str', + 'target_jobs': 'list[KubeflowOrgV2alpha1PodSpecOverrideTargetJob]', + 'tolerations': 'list[V1Toleration]', + 'volumes': 'list[V1Volume]' + } + + attribute_map = { + 'containers': 'containers', + 'init_containers': 'initContainers', + 'node_selector': 'nodeSelector', + 'service_account_name': 'serviceAccountName', + 'target_jobs': 'targetJobs', + 'tolerations': 'tolerations', + 'volumes': 'volumes' + } + + def __init__(self, containers=None, init_containers=None, node_selector=None, service_account_name=None, target_jobs=None, tolerations=None, volumes=None, local_vars_configuration=None): # noqa: E501 + """KubeflowOrgV2alpha1PodSpecOverride - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._containers = None + self._init_containers = None + self._node_selector = None + self._service_account_name = None + self._target_jobs = None + self._tolerations = None + self._volumes = None + self.discriminator = None + + if containers is not None: + self.containers = containers + if init_containers is not None: + self.init_containers = init_containers + if node_selector is not None: + self.node_selector = node_selector + if service_account_name is not None: + self.service_account_name = service_account_name + self.target_jobs = target_jobs + if tolerations is not None: + self.tolerations = tolerations + if volumes is not None: + self.volumes = volumes + + @property + def containers(self): + """Gets the containers of this KubeflowOrgV2alpha1PodSpecOverride. # noqa: E501 + + Overrides for the containers in the desired job templates. # noqa: E501 + + :return: The containers of this KubeflowOrgV2alpha1PodSpecOverride. # noqa: E501 + :rtype: list[KubeflowOrgV2alpha1ContainerOverride] + """ + return self._containers + + @containers.setter + def containers(self, containers): + """Sets the containers of this KubeflowOrgV2alpha1PodSpecOverride. + + Overrides for the containers in the desired job templates. # noqa: E501 + + :param containers: The containers of this KubeflowOrgV2alpha1PodSpecOverride. # noqa: E501 + :type: list[KubeflowOrgV2alpha1ContainerOverride] + """ + + self._containers = containers + + @property + def init_containers(self): + """Gets the init_containers of this KubeflowOrgV2alpha1PodSpecOverride. # noqa: E501 + + Overrides for the init container in the desired job templates. # noqa: E501 + + :return: The init_containers of this KubeflowOrgV2alpha1PodSpecOverride. # noqa: E501 + :rtype: list[KubeflowOrgV2alpha1ContainerOverride] + """ + return self._init_containers + + @init_containers.setter + def init_containers(self, init_containers): + """Sets the init_containers of this KubeflowOrgV2alpha1PodSpecOverride. + + Overrides for the init container in the desired job templates. # noqa: E501 + + :param init_containers: The init_containers of this KubeflowOrgV2alpha1PodSpecOverride. # noqa: E501 + :type: list[KubeflowOrgV2alpha1ContainerOverride] + """ + + self._init_containers = init_containers + + @property + def node_selector(self): + """Gets the node_selector of this KubeflowOrgV2alpha1PodSpecOverride. # noqa: E501 + + Override for the node selector to place Pod on the specific mode. # noqa: E501 + + :return: The node_selector of this KubeflowOrgV2alpha1PodSpecOverride. # noqa: E501 + :rtype: dict(str, str) + """ + return self._node_selector + + @node_selector.setter + def node_selector(self, node_selector): + """Sets the node_selector of this KubeflowOrgV2alpha1PodSpecOverride. + + Override for the node selector to place Pod on the specific mode. # noqa: E501 + + :param node_selector: The node_selector of this KubeflowOrgV2alpha1PodSpecOverride. # noqa: E501 + :type: dict(str, str) + """ + + self._node_selector = node_selector + + @property + def service_account_name(self): + """Gets the service_account_name of this KubeflowOrgV2alpha1PodSpecOverride. # noqa: E501 + + Override for the service account. # noqa: E501 + + :return: The service_account_name of this KubeflowOrgV2alpha1PodSpecOverride. # noqa: E501 + :rtype: str + """ + return self._service_account_name + + @service_account_name.setter + def service_account_name(self, service_account_name): + """Sets the service_account_name of this KubeflowOrgV2alpha1PodSpecOverride. + + Override for the service account. # noqa: E501 + + :param service_account_name: The service_account_name of this KubeflowOrgV2alpha1PodSpecOverride. # noqa: E501 + :type: str + """ + + self._service_account_name = service_account_name + + @property + def target_jobs(self): + """Gets the target_jobs of this KubeflowOrgV2alpha1PodSpecOverride. # noqa: E501 + + TrainJobs is the training job replicas in the training runtime template to apply the overrides. # noqa: E501 + + :return: The target_jobs of this KubeflowOrgV2alpha1PodSpecOverride. # noqa: E501 + :rtype: list[KubeflowOrgV2alpha1PodSpecOverrideTargetJob] + """ + return self._target_jobs + + @target_jobs.setter + def target_jobs(self, target_jobs): + """Sets the target_jobs of this KubeflowOrgV2alpha1PodSpecOverride. + + TrainJobs is the training job replicas in the training runtime template to apply the overrides. # noqa: E501 + + :param target_jobs: The target_jobs of this KubeflowOrgV2alpha1PodSpecOverride. # noqa: E501 + :type: list[KubeflowOrgV2alpha1PodSpecOverrideTargetJob] + """ + if self.local_vars_configuration.client_side_validation and target_jobs is None: # noqa: E501 + raise ValueError("Invalid value for `target_jobs`, must not be `None`") # noqa: E501 + + self._target_jobs = target_jobs + + @property + def tolerations(self): + """Gets the tolerations of this KubeflowOrgV2alpha1PodSpecOverride. # noqa: E501 + + Override for the Pod's tolerations. # noqa: E501 + + :return: The tolerations of this KubeflowOrgV2alpha1PodSpecOverride. # noqa: E501 + :rtype: list[V1Toleration] + """ + return self._tolerations + + @tolerations.setter + def tolerations(self, tolerations): + """Sets the tolerations of this KubeflowOrgV2alpha1PodSpecOverride. + + Override for the Pod's tolerations. # noqa: E501 + + :param tolerations: The tolerations of this KubeflowOrgV2alpha1PodSpecOverride. # noqa: E501 + :type: list[V1Toleration] + """ + + self._tolerations = tolerations + + @property + def volumes(self): + """Gets the volumes of this KubeflowOrgV2alpha1PodSpecOverride. # noqa: E501 + + Overrides for the Pod volume configuration. # noqa: E501 + + :return: The volumes of this KubeflowOrgV2alpha1PodSpecOverride. # noqa: E501 + :rtype: list[V1Volume] + """ + return self._volumes + + @volumes.setter + def volumes(self, volumes): + """Sets the volumes of this KubeflowOrgV2alpha1PodSpecOverride. + + Overrides for the Pod volume configuration. # noqa: E501 + + :param volumes: The volumes of this KubeflowOrgV2alpha1PodSpecOverride. # noqa: E501 + :type: list[V1Volume] + """ + + self._volumes = volumes + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, KubeflowOrgV2alpha1PodSpecOverride): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, KubeflowOrgV2alpha1PodSpecOverride): + return True + + return self.to_dict() != other.to_dict() diff --git a/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_pod_spec_override_target_job.py b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_pod_spec_override_target_job.py new file mode 100644 index 0000000000..1307c70c47 --- /dev/null +++ b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_pod_spec_override_target_job.py @@ -0,0 +1,123 @@ +# coding: utf-8 + +""" + Kubeflow Training OpenAPI Spec + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from kubeflow.training.configuration import Configuration + + +class KubeflowOrgV2alpha1PodSpecOverrideTargetJob(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = { + 'name': 'str' + } + + attribute_map = { + 'name': 'name' + } + + def __init__(self, name='', local_vars_configuration=None): # noqa: E501 + """KubeflowOrgV2alpha1PodSpecOverrideTargetJob - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._name = None + self.discriminator = None + + self.name = name + + @property + def name(self): + """Gets the name of this KubeflowOrgV2alpha1PodSpecOverrideTargetJob. # noqa: E501 + + Name is the target training job name for which the PodSpec is overridden. # noqa: E501 + + :return: The name of this KubeflowOrgV2alpha1PodSpecOverrideTargetJob. # noqa: E501 + :rtype: str + """ + return self._name + + @name.setter + def name(self, name): + """Sets the name of this KubeflowOrgV2alpha1PodSpecOverrideTargetJob. + + Name is the target training job name for which the PodSpec is overridden. # noqa: E501 + + :param name: The name of this KubeflowOrgV2alpha1PodSpecOverrideTargetJob. # noqa: E501 + :type: str + """ + if self.local_vars_configuration.client_side_validation and name is None: # noqa: E501 + raise ValueError("Invalid value for `name`, must not be `None`") # noqa: E501 + + self._name = name + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, KubeflowOrgV2alpha1PodSpecOverrideTargetJob): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, KubeflowOrgV2alpha1PodSpecOverrideTargetJob): + return True + + return self.to_dict() != other.to_dict() diff --git a/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_runtime_ref.py b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_runtime_ref.py new file mode 100644 index 0000000000..63e6bd00bd --- /dev/null +++ b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_runtime_ref.py @@ -0,0 +1,179 @@ +# coding: utf-8 + +""" + Kubeflow Training OpenAPI Spec + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from kubeflow.training.configuration import Configuration + + +class KubeflowOrgV2alpha1RuntimeRef(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = { + 'api_group': 'str', + 'kind': 'str', + 'name': 'str' + } + + attribute_map = { + 'api_group': 'apiGroup', + 'kind': 'kind', + 'name': 'name' + } + + def __init__(self, api_group=None, kind=None, name='', local_vars_configuration=None): # noqa: E501 + """KubeflowOrgV2alpha1RuntimeRef - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._api_group = None + self._kind = None + self._name = None + self.discriminator = None + + if api_group is not None: + self.api_group = api_group + if kind is not None: + self.kind = kind + self.name = name + + @property + def api_group(self): + """Gets the api_group of this KubeflowOrgV2alpha1RuntimeRef. # noqa: E501 + + APIGroup of the runtime being referenced. Defaults to `kubeflow.org`. # noqa: E501 + + :return: The api_group of this KubeflowOrgV2alpha1RuntimeRef. # noqa: E501 + :rtype: str + """ + return self._api_group + + @api_group.setter + def api_group(self, api_group): + """Sets the api_group of this KubeflowOrgV2alpha1RuntimeRef. + + APIGroup of the runtime being referenced. Defaults to `kubeflow.org`. # noqa: E501 + + :param api_group: The api_group of this KubeflowOrgV2alpha1RuntimeRef. # noqa: E501 + :type: str + """ + + self._api_group = api_group + + @property + def kind(self): + """Gets the kind of this KubeflowOrgV2alpha1RuntimeRef. # noqa: E501 + + Kind of the runtime being referenced. Defaults to ClusterTrainingRuntime. # noqa: E501 + + :return: The kind of this KubeflowOrgV2alpha1RuntimeRef. # noqa: E501 + :rtype: str + """ + return self._kind + + @kind.setter + def kind(self, kind): + """Sets the kind of this KubeflowOrgV2alpha1RuntimeRef. + + Kind of the runtime being referenced. Defaults to ClusterTrainingRuntime. # noqa: E501 + + :param kind: The kind of this KubeflowOrgV2alpha1RuntimeRef. # noqa: E501 + :type: str + """ + + self._kind = kind + + @property + def name(self): + """Gets the name of this KubeflowOrgV2alpha1RuntimeRef. # noqa: E501 + + Name of the runtime being referenced. When namespaced-scoped TrainingRuntime is used, the TrainJob must have the same namespace as the deployed runtime. # noqa: E501 + + :return: The name of this KubeflowOrgV2alpha1RuntimeRef. # noqa: E501 + :rtype: str + """ + return self._name + + @name.setter + def name(self, name): + """Sets the name of this KubeflowOrgV2alpha1RuntimeRef. + + Name of the runtime being referenced. When namespaced-scoped TrainingRuntime is used, the TrainJob must have the same namespace as the deployed runtime. # noqa: E501 + + :param name: The name of this KubeflowOrgV2alpha1RuntimeRef. # noqa: E501 + :type: str + """ + if self.local_vars_configuration.client_side_validation and name is None: # noqa: E501 + raise ValueError("Invalid value for `name`, must not be `None`") # noqa: E501 + + self._name = name + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, KubeflowOrgV2alpha1RuntimeRef): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, KubeflowOrgV2alpha1RuntimeRef): + return True + + return self.to_dict() != other.to_dict() diff --git a/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_torch_elastic_policy.py b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_torch_elastic_policy.py new file mode 100644 index 0000000000..9380564f08 --- /dev/null +++ b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_torch_elastic_policy.py @@ -0,0 +1,206 @@ +# coding: utf-8 + +""" + Kubeflow Training OpenAPI Spec + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from kubeflow.training.configuration import Configuration + + +class KubeflowOrgV2alpha1TorchElasticPolicy(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = { + 'max_nodes': 'int', + 'max_restarts': 'int', + 'metrics': 'list[K8sIoApiAutoscalingV2MetricSpec]', + 'min_nodes': 'int' + } + + attribute_map = { + 'max_nodes': 'maxNodes', + 'max_restarts': 'maxRestarts', + 'metrics': 'metrics', + 'min_nodes': 'minNodes' + } + + def __init__(self, max_nodes=None, max_restarts=None, metrics=None, min_nodes=None, local_vars_configuration=None): # noqa: E501 + """KubeflowOrgV2alpha1TorchElasticPolicy - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._max_nodes = None + self._max_restarts = None + self._metrics = None + self._min_nodes = None + self.discriminator = None + + if max_nodes is not None: + self.max_nodes = max_nodes + if max_restarts is not None: + self.max_restarts = max_restarts + if metrics is not None: + self.metrics = metrics + if min_nodes is not None: + self.min_nodes = min_nodes + + @property + def max_nodes(self): + """Gets the max_nodes of this KubeflowOrgV2alpha1TorchElasticPolicy. # noqa: E501 + + Upper limit for the number of nodes to which training job can scale up. # noqa: E501 + + :return: The max_nodes of this KubeflowOrgV2alpha1TorchElasticPolicy. # noqa: E501 + :rtype: int + """ + return self._max_nodes + + @max_nodes.setter + def max_nodes(self, max_nodes): + """Sets the max_nodes of this KubeflowOrgV2alpha1TorchElasticPolicy. + + Upper limit for the number of nodes to which training job can scale up. # noqa: E501 + + :param max_nodes: The max_nodes of this KubeflowOrgV2alpha1TorchElasticPolicy. # noqa: E501 + :type: int + """ + + self._max_nodes = max_nodes + + @property + def max_restarts(self): + """Gets the max_restarts of this KubeflowOrgV2alpha1TorchElasticPolicy. # noqa: E501 + + How many times the training job can be restarted. This value is inserted into the `--max-restarts` argument of the `torchrun` CLI and the `.spec.failurePolicy.maxRestarts` parameter of the training Job. # noqa: E501 + + :return: The max_restarts of this KubeflowOrgV2alpha1TorchElasticPolicy. # noqa: E501 + :rtype: int + """ + return self._max_restarts + + @max_restarts.setter + def max_restarts(self, max_restarts): + """Sets the max_restarts of this KubeflowOrgV2alpha1TorchElasticPolicy. + + How many times the training job can be restarted. This value is inserted into the `--max-restarts` argument of the `torchrun` CLI and the `.spec.failurePolicy.maxRestarts` parameter of the training Job. # noqa: E501 + + :param max_restarts: The max_restarts of this KubeflowOrgV2alpha1TorchElasticPolicy. # noqa: E501 + :type: int + """ + + self._max_restarts = max_restarts + + @property + def metrics(self): + """Gets the metrics of this KubeflowOrgV2alpha1TorchElasticPolicy. # noqa: E501 + + Specification which are used to calculate the desired number of nodes. See the individual metric source types for more information about how each type of metric must respond. The HPA will be created to perform auto-scaling. # noqa: E501 + + :return: The metrics of this KubeflowOrgV2alpha1TorchElasticPolicy. # noqa: E501 + :rtype: list[K8sIoApiAutoscalingV2MetricSpec] + """ + return self._metrics + + @metrics.setter + def metrics(self, metrics): + """Sets the metrics of this KubeflowOrgV2alpha1TorchElasticPolicy. + + Specification which are used to calculate the desired number of nodes. See the individual metric source types for more information about how each type of metric must respond. The HPA will be created to perform auto-scaling. # noqa: E501 + + :param metrics: The metrics of this KubeflowOrgV2alpha1TorchElasticPolicy. # noqa: E501 + :type: list[K8sIoApiAutoscalingV2MetricSpec] + """ + + self._metrics = metrics + + @property + def min_nodes(self): + """Gets the min_nodes of this KubeflowOrgV2alpha1TorchElasticPolicy. # noqa: E501 + + Lower limit for the number of nodes to which training job can scale down. # noqa: E501 + + :return: The min_nodes of this KubeflowOrgV2alpha1TorchElasticPolicy. # noqa: E501 + :rtype: int + """ + return self._min_nodes + + @min_nodes.setter + def min_nodes(self, min_nodes): + """Sets the min_nodes of this KubeflowOrgV2alpha1TorchElasticPolicy. + + Lower limit for the number of nodes to which training job can scale down. # noqa: E501 + + :param min_nodes: The min_nodes of this KubeflowOrgV2alpha1TorchElasticPolicy. # noqa: E501 + :type: int + """ + + self._min_nodes = min_nodes + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, KubeflowOrgV2alpha1TorchElasticPolicy): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, KubeflowOrgV2alpha1TorchElasticPolicy): + return True + + return self.to_dict() != other.to_dict() diff --git a/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_torch_ml_policy_source.py b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_torch_ml_policy_source.py new file mode 100644 index 0000000000..5cb0d5aa53 --- /dev/null +++ b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_torch_ml_policy_source.py @@ -0,0 +1,148 @@ +# coding: utf-8 + +""" + Kubeflow Training OpenAPI Spec + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from kubeflow.training.configuration import Configuration + + +class KubeflowOrgV2alpha1TorchMLPolicySource(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = { + 'elastic_policy': 'KubeflowOrgV2alpha1TorchElasticPolicy', + 'num_proc_per_node': 'str' + } + + attribute_map = { + 'elastic_policy': 'elasticPolicy', + 'num_proc_per_node': 'numProcPerNode' + } + + def __init__(self, elastic_policy=None, num_proc_per_node=None, local_vars_configuration=None): # noqa: E501 + """KubeflowOrgV2alpha1TorchMLPolicySource - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._elastic_policy = None + self._num_proc_per_node = None + self.discriminator = None + + if elastic_policy is not None: + self.elastic_policy = elastic_policy + if num_proc_per_node is not None: + self.num_proc_per_node = num_proc_per_node + + @property + def elastic_policy(self): + """Gets the elastic_policy of this KubeflowOrgV2alpha1TorchMLPolicySource. # noqa: E501 + + + :return: The elastic_policy of this KubeflowOrgV2alpha1TorchMLPolicySource. # noqa: E501 + :rtype: KubeflowOrgV2alpha1TorchElasticPolicy + """ + return self._elastic_policy + + @elastic_policy.setter + def elastic_policy(self, elastic_policy): + """Sets the elastic_policy of this KubeflowOrgV2alpha1TorchMLPolicySource. + + + :param elastic_policy: The elastic_policy of this KubeflowOrgV2alpha1TorchMLPolicySource. # noqa: E501 + :type: KubeflowOrgV2alpha1TorchElasticPolicy + """ + + self._elastic_policy = elastic_policy + + @property + def num_proc_per_node(self): + """Gets the num_proc_per_node of this KubeflowOrgV2alpha1TorchMLPolicySource. # noqa: E501 + + Number of processes per node. This value is inserted into the `--nproc-per-node` argument of the `torchrun` CLI. Supported values: `auto`, `cpu`, `gpu`, or int value. Defaults to `auto`. # noqa: E501 + + :return: The num_proc_per_node of this KubeflowOrgV2alpha1TorchMLPolicySource. # noqa: E501 + :rtype: str + """ + return self._num_proc_per_node + + @num_proc_per_node.setter + def num_proc_per_node(self, num_proc_per_node): + """Sets the num_proc_per_node of this KubeflowOrgV2alpha1TorchMLPolicySource. + + Number of processes per node. This value is inserted into the `--nproc-per-node` argument of the `torchrun` CLI. Supported values: `auto`, `cpu`, `gpu`, or int value. Defaults to `auto`. # noqa: E501 + + :param num_proc_per_node: The num_proc_per_node of this KubeflowOrgV2alpha1TorchMLPolicySource. # noqa: E501 + :type: str + """ + + self._num_proc_per_node = num_proc_per_node + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, KubeflowOrgV2alpha1TorchMLPolicySource): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, KubeflowOrgV2alpha1TorchMLPolicySource): + return True + + return self.to_dict() != other.to_dict() diff --git a/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_train_job.py b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_train_job.py new file mode 100644 index 0000000000..f0af810fdb --- /dev/null +++ b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_train_job.py @@ -0,0 +1,228 @@ +# coding: utf-8 + +""" + Kubeflow Training OpenAPI Spec + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from kubeflow.training.configuration import Configuration + + +class KubeflowOrgV2alpha1TrainJob(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = { + 'api_version': 'str', + 'kind': 'str', + 'metadata': 'V1ObjectMeta', + 'spec': 'KubeflowOrgV2alpha1TrainJobSpec', + 'status': 'KubeflowOrgV2alpha1TrainJobStatus' + } + + attribute_map = { + 'api_version': 'apiVersion', + 'kind': 'kind', + 'metadata': 'metadata', + 'spec': 'spec', + 'status': 'status' + } + + def __init__(self, api_version=None, kind=None, metadata=None, spec=None, status=None, local_vars_configuration=None): # noqa: E501 + """KubeflowOrgV2alpha1TrainJob - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._api_version = None + self._kind = None + self._metadata = None + self._spec = None + self._status = None + self.discriminator = None + + if api_version is not None: + self.api_version = api_version + if kind is not None: + self.kind = kind + if metadata is not None: + self.metadata = metadata + if spec is not None: + self.spec = spec + if status is not None: + self.status = status + + @property + def api_version(self): + """Gets the api_version of this KubeflowOrgV2alpha1TrainJob. # noqa: E501 + + APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources # noqa: E501 + + :return: The api_version of this KubeflowOrgV2alpha1TrainJob. # noqa: E501 + :rtype: str + """ + return self._api_version + + @api_version.setter + def api_version(self, api_version): + """Sets the api_version of this KubeflowOrgV2alpha1TrainJob. + + APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources # noqa: E501 + + :param api_version: The api_version of this KubeflowOrgV2alpha1TrainJob. # noqa: E501 + :type: str + """ + + self._api_version = api_version + + @property + def kind(self): + """Gets the kind of this KubeflowOrgV2alpha1TrainJob. # noqa: E501 + + Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds # noqa: E501 + + :return: The kind of this KubeflowOrgV2alpha1TrainJob. # noqa: E501 + :rtype: str + """ + return self._kind + + @kind.setter + def kind(self, kind): + """Sets the kind of this KubeflowOrgV2alpha1TrainJob. + + Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds # noqa: E501 + + :param kind: The kind of this KubeflowOrgV2alpha1TrainJob. # noqa: E501 + :type: str + """ + + self._kind = kind + + @property + def metadata(self): + """Gets the metadata of this KubeflowOrgV2alpha1TrainJob. # noqa: E501 + + + :return: The metadata of this KubeflowOrgV2alpha1TrainJob. # noqa: E501 + :rtype: V1ObjectMeta + """ + return self._metadata + + @metadata.setter + def metadata(self, metadata): + """Sets the metadata of this KubeflowOrgV2alpha1TrainJob. + + + :param metadata: The metadata of this KubeflowOrgV2alpha1TrainJob. # noqa: E501 + :type: V1ObjectMeta + """ + + self._metadata = metadata + + @property + def spec(self): + """Gets the spec of this KubeflowOrgV2alpha1TrainJob. # noqa: E501 + + + :return: The spec of this KubeflowOrgV2alpha1TrainJob. # noqa: E501 + :rtype: KubeflowOrgV2alpha1TrainJobSpec + """ + return self._spec + + @spec.setter + def spec(self, spec): + """Sets the spec of this KubeflowOrgV2alpha1TrainJob. + + + :param spec: The spec of this KubeflowOrgV2alpha1TrainJob. # noqa: E501 + :type: KubeflowOrgV2alpha1TrainJobSpec + """ + + self._spec = spec + + @property + def status(self): + """Gets the status of this KubeflowOrgV2alpha1TrainJob. # noqa: E501 + + + :return: The status of this KubeflowOrgV2alpha1TrainJob. # noqa: E501 + :rtype: KubeflowOrgV2alpha1TrainJobStatus + """ + return self._status + + @status.setter + def status(self, status): + """Sets the status of this KubeflowOrgV2alpha1TrainJob. + + + :param status: The status of this KubeflowOrgV2alpha1TrainJob. # noqa: E501 + :type: KubeflowOrgV2alpha1TrainJobStatus + """ + + self._status = status + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, KubeflowOrgV2alpha1TrainJob): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, KubeflowOrgV2alpha1TrainJob): + return True + + return self.to_dict() != other.to_dict() diff --git a/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_train_job_list.py b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_train_job_list.py new file mode 100644 index 0000000000..64d4a8fc50 --- /dev/null +++ b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_train_job_list.py @@ -0,0 +1,205 @@ +# coding: utf-8 + +""" + Kubeflow Training OpenAPI Spec + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from kubeflow.training.configuration import Configuration + + +class KubeflowOrgV2alpha1TrainJobList(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = { + 'api_version': 'str', + 'items': 'list[KubeflowOrgV2alpha1TrainJob]', + 'kind': 'str', + 'metadata': 'V1ListMeta' + } + + attribute_map = { + 'api_version': 'apiVersion', + 'items': 'items', + 'kind': 'kind', + 'metadata': 'metadata' + } + + def __init__(self, api_version=None, items=None, kind=None, metadata=None, local_vars_configuration=None): # noqa: E501 + """KubeflowOrgV2alpha1TrainJobList - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._api_version = None + self._items = None + self._kind = None + self._metadata = None + self.discriminator = None + + if api_version is not None: + self.api_version = api_version + self.items = items + if kind is not None: + self.kind = kind + if metadata is not None: + self.metadata = metadata + + @property + def api_version(self): + """Gets the api_version of this KubeflowOrgV2alpha1TrainJobList. # noqa: E501 + + APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources # noqa: E501 + + :return: The api_version of this KubeflowOrgV2alpha1TrainJobList. # noqa: E501 + :rtype: str + """ + return self._api_version + + @api_version.setter + def api_version(self, api_version): + """Sets the api_version of this KubeflowOrgV2alpha1TrainJobList. + + APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources # noqa: E501 + + :param api_version: The api_version of this KubeflowOrgV2alpha1TrainJobList. # noqa: E501 + :type: str + """ + + self._api_version = api_version + + @property + def items(self): + """Gets the items of this KubeflowOrgV2alpha1TrainJobList. # noqa: E501 + + List of TrainJobs. # noqa: E501 + + :return: The items of this KubeflowOrgV2alpha1TrainJobList. # noqa: E501 + :rtype: list[KubeflowOrgV2alpha1TrainJob] + """ + return self._items + + @items.setter + def items(self, items): + """Sets the items of this KubeflowOrgV2alpha1TrainJobList. + + List of TrainJobs. # noqa: E501 + + :param items: The items of this KubeflowOrgV2alpha1TrainJobList. # noqa: E501 + :type: list[KubeflowOrgV2alpha1TrainJob] + """ + if self.local_vars_configuration.client_side_validation and items is None: # noqa: E501 + raise ValueError("Invalid value for `items`, must not be `None`") # noqa: E501 + + self._items = items + + @property + def kind(self): + """Gets the kind of this KubeflowOrgV2alpha1TrainJobList. # noqa: E501 + + Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds # noqa: E501 + + :return: The kind of this KubeflowOrgV2alpha1TrainJobList. # noqa: E501 + :rtype: str + """ + return self._kind + + @kind.setter + def kind(self, kind): + """Sets the kind of this KubeflowOrgV2alpha1TrainJobList. + + Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds # noqa: E501 + + :param kind: The kind of this KubeflowOrgV2alpha1TrainJobList. # noqa: E501 + :type: str + """ + + self._kind = kind + + @property + def metadata(self): + """Gets the metadata of this KubeflowOrgV2alpha1TrainJobList. # noqa: E501 + + + :return: The metadata of this KubeflowOrgV2alpha1TrainJobList. # noqa: E501 + :rtype: V1ListMeta + """ + return self._metadata + + @metadata.setter + def metadata(self, metadata): + """Sets the metadata of this KubeflowOrgV2alpha1TrainJobList. + + + :param metadata: The metadata of this KubeflowOrgV2alpha1TrainJobList. # noqa: E501 + :type: V1ListMeta + """ + + self._metadata = metadata + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, KubeflowOrgV2alpha1TrainJobList): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, KubeflowOrgV2alpha1TrainJobList): + return True + + return self.to_dict() != other.to_dict() diff --git a/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_train_job_spec.py b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_train_job_spec.py new file mode 100644 index 0000000000..f639e91d33 --- /dev/null +++ b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_train_job_spec.py @@ -0,0 +1,339 @@ +# coding: utf-8 + +""" + Kubeflow Training OpenAPI Spec + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from kubeflow.training.configuration import Configuration + + +class KubeflowOrgV2alpha1TrainJobSpec(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = { + 'annotations': 'dict(str, str)', + 'dataset_config': 'KubeflowOrgV2alpha1DatasetConfig', + 'labels': 'dict(str, str)', + 'managed_by': 'str', + 'model_config': 'KubeflowOrgV2alpha1ModelConfig', + 'pod_spec_overrides': 'list[KubeflowOrgV2alpha1PodSpecOverride]', + 'runtime_ref': 'KubeflowOrgV2alpha1RuntimeRef', + 'suspend': 'bool', + 'trainer': 'KubeflowOrgV2alpha1Trainer' + } + + attribute_map = { + 'annotations': 'annotations', + 'dataset_config': 'datasetConfig', + 'labels': 'labels', + 'managed_by': 'managedBy', + 'model_config': 'modelConfig', + 'pod_spec_overrides': 'podSpecOverrides', + 'runtime_ref': 'runtimeRef', + 'suspend': 'suspend', + 'trainer': 'trainer' + } + + def __init__(self, annotations=None, dataset_config=None, labels=None, managed_by=None, model_config=None, pod_spec_overrides=None, runtime_ref=None, suspend=None, trainer=None, local_vars_configuration=None): # noqa: E501 + """KubeflowOrgV2alpha1TrainJobSpec - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._annotations = None + self._dataset_config = None + self._labels = None + self._managed_by = None + self._model_config = None + self._pod_spec_overrides = None + self._runtime_ref = None + self._suspend = None + self._trainer = None + self.discriminator = None + + if annotations is not None: + self.annotations = annotations + if dataset_config is not None: + self.dataset_config = dataset_config + if labels is not None: + self.labels = labels + if managed_by is not None: + self.managed_by = managed_by + if model_config is not None: + self.model_config = model_config + if pod_spec_overrides is not None: + self.pod_spec_overrides = pod_spec_overrides + self.runtime_ref = runtime_ref + if suspend is not None: + self.suspend = suspend + if trainer is not None: + self.trainer = trainer + + @property + def annotations(self): + """Gets the annotations of this KubeflowOrgV2alpha1TrainJobSpec. # noqa: E501 + + Annotations to apply for the derivative JobSet and Jobs. They will be merged with the TrainingRuntime values. # noqa: E501 + + :return: The annotations of this KubeflowOrgV2alpha1TrainJobSpec. # noqa: E501 + :rtype: dict(str, str) + """ + return self._annotations + + @annotations.setter + def annotations(self, annotations): + """Sets the annotations of this KubeflowOrgV2alpha1TrainJobSpec. + + Annotations to apply for the derivative JobSet and Jobs. They will be merged with the TrainingRuntime values. # noqa: E501 + + :param annotations: The annotations of this KubeflowOrgV2alpha1TrainJobSpec. # noqa: E501 + :type: dict(str, str) + """ + + self._annotations = annotations + + @property + def dataset_config(self): + """Gets the dataset_config of this KubeflowOrgV2alpha1TrainJobSpec. # noqa: E501 + + + :return: The dataset_config of this KubeflowOrgV2alpha1TrainJobSpec. # noqa: E501 + :rtype: KubeflowOrgV2alpha1DatasetConfig + """ + return self._dataset_config + + @dataset_config.setter + def dataset_config(self, dataset_config): + """Sets the dataset_config of this KubeflowOrgV2alpha1TrainJobSpec. + + + :param dataset_config: The dataset_config of this KubeflowOrgV2alpha1TrainJobSpec. # noqa: E501 + :type: KubeflowOrgV2alpha1DatasetConfig + """ + + self._dataset_config = dataset_config + + @property + def labels(self): + """Gets the labels of this KubeflowOrgV2alpha1TrainJobSpec. # noqa: E501 + + Labels to apply for the derivative JobSet and Jobs. They will be merged with the TrainingRuntime values. # noqa: E501 + + :return: The labels of this KubeflowOrgV2alpha1TrainJobSpec. # noqa: E501 + :rtype: dict(str, str) + """ + return self._labels + + @labels.setter + def labels(self, labels): + """Sets the labels of this KubeflowOrgV2alpha1TrainJobSpec. + + Labels to apply for the derivative JobSet and Jobs. They will be merged with the TrainingRuntime values. # noqa: E501 + + :param labels: The labels of this KubeflowOrgV2alpha1TrainJobSpec. # noqa: E501 + :type: dict(str, str) + """ + + self._labels = labels + + @property + def managed_by(self): + """Gets the managed_by of this KubeflowOrgV2alpha1TrainJobSpec. # noqa: E501 + + ManagedBy is used to indicate the controller or entity that manages a TrainJob. The value must be either an empty, `kubeflow.org/trainjob-controller` or `kueue.x-k8s.io/multikueue`. The built-in TrainJob controller reconciles TrainJob which don't have this field at all or the field value is the reserved string `kubeflow.org/trainjob-controller`, but delegates reconciling TrainJobs with a 'kueue.x-k8s.io/multikueue' to the Kueue. The field is immutable. Defaults to `kubeflow.org/trainjob-controller` # noqa: E501 + + :return: The managed_by of this KubeflowOrgV2alpha1TrainJobSpec. # noqa: E501 + :rtype: str + """ + return self._managed_by + + @managed_by.setter + def managed_by(self, managed_by): + """Sets the managed_by of this KubeflowOrgV2alpha1TrainJobSpec. + + ManagedBy is used to indicate the controller or entity that manages a TrainJob. The value must be either an empty, `kubeflow.org/trainjob-controller` or `kueue.x-k8s.io/multikueue`. The built-in TrainJob controller reconciles TrainJob which don't have this field at all or the field value is the reserved string `kubeflow.org/trainjob-controller`, but delegates reconciling TrainJobs with a 'kueue.x-k8s.io/multikueue' to the Kueue. The field is immutable. Defaults to `kubeflow.org/trainjob-controller` # noqa: E501 + + :param managed_by: The managed_by of this KubeflowOrgV2alpha1TrainJobSpec. # noqa: E501 + :type: str + """ + + self._managed_by = managed_by + + @property + def model_config(self): + """Gets the model_config of this KubeflowOrgV2alpha1TrainJobSpec. # noqa: E501 + + + :return: The model_config of this KubeflowOrgV2alpha1TrainJobSpec. # noqa: E501 + :rtype: KubeflowOrgV2alpha1ModelConfig + """ + return self._model_config + + @model_config.setter + def model_config(self, model_config): + """Sets the model_config of this KubeflowOrgV2alpha1TrainJobSpec. + + + :param model_config: The model_config of this KubeflowOrgV2alpha1TrainJobSpec. # noqa: E501 + :type: KubeflowOrgV2alpha1ModelConfig + """ + + self._model_config = model_config + + @property + def pod_spec_overrides(self): + """Gets the pod_spec_overrides of this KubeflowOrgV2alpha1TrainJobSpec. # noqa: E501 + + Custom overrides for the training runtime. # noqa: E501 + + :return: The pod_spec_overrides of this KubeflowOrgV2alpha1TrainJobSpec. # noqa: E501 + :rtype: list[KubeflowOrgV2alpha1PodSpecOverride] + """ + return self._pod_spec_overrides + + @pod_spec_overrides.setter + def pod_spec_overrides(self, pod_spec_overrides): + """Sets the pod_spec_overrides of this KubeflowOrgV2alpha1TrainJobSpec. + + Custom overrides for the training runtime. # noqa: E501 + + :param pod_spec_overrides: The pod_spec_overrides of this KubeflowOrgV2alpha1TrainJobSpec. # noqa: E501 + :type: list[KubeflowOrgV2alpha1PodSpecOverride] + """ + + self._pod_spec_overrides = pod_spec_overrides + + @property + def runtime_ref(self): + """Gets the runtime_ref of this KubeflowOrgV2alpha1TrainJobSpec. # noqa: E501 + + + :return: The runtime_ref of this KubeflowOrgV2alpha1TrainJobSpec. # noqa: E501 + :rtype: KubeflowOrgV2alpha1RuntimeRef + """ + return self._runtime_ref + + @runtime_ref.setter + def runtime_ref(self, runtime_ref): + """Sets the runtime_ref of this KubeflowOrgV2alpha1TrainJobSpec. + + + :param runtime_ref: The runtime_ref of this KubeflowOrgV2alpha1TrainJobSpec. # noqa: E501 + :type: KubeflowOrgV2alpha1RuntimeRef + """ + if self.local_vars_configuration.client_side_validation and runtime_ref is None: # noqa: E501 + raise ValueError("Invalid value for `runtime_ref`, must not be `None`") # noqa: E501 + + self._runtime_ref = runtime_ref + + @property + def suspend(self): + """Gets the suspend of this KubeflowOrgV2alpha1TrainJobSpec. # noqa: E501 + + Whether the controller should suspend the running TrainJob. Defaults to false. # noqa: E501 + + :return: The suspend of this KubeflowOrgV2alpha1TrainJobSpec. # noqa: E501 + :rtype: bool + """ + return self._suspend + + @suspend.setter + def suspend(self, suspend): + """Sets the suspend of this KubeflowOrgV2alpha1TrainJobSpec. + + Whether the controller should suspend the running TrainJob. Defaults to false. # noqa: E501 + + :param suspend: The suspend of this KubeflowOrgV2alpha1TrainJobSpec. # noqa: E501 + :type: bool + """ + + self._suspend = suspend + + @property + def trainer(self): + """Gets the trainer of this KubeflowOrgV2alpha1TrainJobSpec. # noqa: E501 + + + :return: The trainer of this KubeflowOrgV2alpha1TrainJobSpec. # noqa: E501 + :rtype: KubeflowOrgV2alpha1Trainer + """ + return self._trainer + + @trainer.setter + def trainer(self, trainer): + """Sets the trainer of this KubeflowOrgV2alpha1TrainJobSpec. + + + :param trainer: The trainer of this KubeflowOrgV2alpha1TrainJobSpec. # noqa: E501 + :type: KubeflowOrgV2alpha1Trainer + """ + + self._trainer = trainer + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, KubeflowOrgV2alpha1TrainJobSpec): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, KubeflowOrgV2alpha1TrainJobSpec): + return True + + return self.to_dict() != other.to_dict() diff --git a/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_train_job_status.py b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_train_job_status.py new file mode 100644 index 0000000000..c1bea06b54 --- /dev/null +++ b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_train_job_status.py @@ -0,0 +1,150 @@ +# coding: utf-8 + +""" + Kubeflow Training OpenAPI Spec + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from kubeflow.training.configuration import Configuration + + +class KubeflowOrgV2alpha1TrainJobStatus(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = { + 'conditions': 'list[V1Condition]', + 'jobs_status': 'list[KubeflowOrgV2alpha1JobStatus]' + } + + attribute_map = { + 'conditions': 'conditions', + 'jobs_status': 'jobsStatus' + } + + def __init__(self, conditions=None, jobs_status=None, local_vars_configuration=None): # noqa: E501 + """KubeflowOrgV2alpha1TrainJobStatus - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._conditions = None + self._jobs_status = None + self.discriminator = None + + if conditions is not None: + self.conditions = conditions + if jobs_status is not None: + self.jobs_status = jobs_status + + @property + def conditions(self): + """Gets the conditions of this KubeflowOrgV2alpha1TrainJobStatus. # noqa: E501 + + Conditions for the TrainJob. # noqa: E501 + + :return: The conditions of this KubeflowOrgV2alpha1TrainJobStatus. # noqa: E501 + :rtype: list[V1Condition] + """ + return self._conditions + + @conditions.setter + def conditions(self, conditions): + """Sets the conditions of this KubeflowOrgV2alpha1TrainJobStatus. + + Conditions for the TrainJob. # noqa: E501 + + :param conditions: The conditions of this KubeflowOrgV2alpha1TrainJobStatus. # noqa: E501 + :type: list[V1Condition] + """ + + self._conditions = conditions + + @property + def jobs_status(self): + """Gets the jobs_status of this KubeflowOrgV2alpha1TrainJobStatus. # noqa: E501 + + JobsStatus tracks the child Jobs in TrainJob. # noqa: E501 + + :return: The jobs_status of this KubeflowOrgV2alpha1TrainJobStatus. # noqa: E501 + :rtype: list[KubeflowOrgV2alpha1JobStatus] + """ + return self._jobs_status + + @jobs_status.setter + def jobs_status(self, jobs_status): + """Sets the jobs_status of this KubeflowOrgV2alpha1TrainJobStatus. + + JobsStatus tracks the child Jobs in TrainJob. # noqa: E501 + + :param jobs_status: The jobs_status of this KubeflowOrgV2alpha1TrainJobStatus. # noqa: E501 + :type: list[KubeflowOrgV2alpha1JobStatus] + """ + + self._jobs_status = jobs_status + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, KubeflowOrgV2alpha1TrainJobStatus): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, KubeflowOrgV2alpha1TrainJobStatus): + return True + + return self.to_dict() != other.to_dict() diff --git a/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_trainer.py b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_trainer.py new file mode 100644 index 0000000000..e82d160b96 --- /dev/null +++ b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_trainer.py @@ -0,0 +1,288 @@ +# coding: utf-8 + +""" + Kubeflow Training OpenAPI Spec + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from kubeflow.training.configuration import Configuration + + +class KubeflowOrgV2alpha1Trainer(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = { + 'args': 'list[str]', + 'command': 'list[str]', + 'env': 'list[V1EnvVar]', + 'image': 'str', + 'num_nodes': 'int', + 'num_proc_per_node': 'str', + 'resources_per_node': 'V1ResourceRequirements' + } + + attribute_map = { + 'args': 'args', + 'command': 'command', + 'env': 'env', + 'image': 'image', + 'num_nodes': 'numNodes', + 'num_proc_per_node': 'numProcPerNode', + 'resources_per_node': 'resourcesPerNode' + } + + def __init__(self, args=None, command=None, env=None, image=None, num_nodes=None, num_proc_per_node=None, resources_per_node=None, local_vars_configuration=None): # noqa: E501 + """KubeflowOrgV2alpha1Trainer - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._args = None + self._command = None + self._env = None + self._image = None + self._num_nodes = None + self._num_proc_per_node = None + self._resources_per_node = None + self.discriminator = None + + if args is not None: + self.args = args + if command is not None: + self.command = command + if env is not None: + self.env = env + if image is not None: + self.image = image + if num_nodes is not None: + self.num_nodes = num_nodes + if num_proc_per_node is not None: + self.num_proc_per_node = num_proc_per_node + if resources_per_node is not None: + self.resources_per_node = resources_per_node + + @property + def args(self): + """Gets the args of this KubeflowOrgV2alpha1Trainer. # noqa: E501 + + Arguments to the entrypoint for the training container. # noqa: E501 + + :return: The args of this KubeflowOrgV2alpha1Trainer. # noqa: E501 + :rtype: list[str] + """ + return self._args + + @args.setter + def args(self, args): + """Sets the args of this KubeflowOrgV2alpha1Trainer. + + Arguments to the entrypoint for the training container. # noqa: E501 + + :param args: The args of this KubeflowOrgV2alpha1Trainer. # noqa: E501 + :type: list[str] + """ + + self._args = args + + @property + def command(self): + """Gets the command of this KubeflowOrgV2alpha1Trainer. # noqa: E501 + + Entrypoint commands for the training container. # noqa: E501 + + :return: The command of this KubeflowOrgV2alpha1Trainer. # noqa: E501 + :rtype: list[str] + """ + return self._command + + @command.setter + def command(self, command): + """Sets the command of this KubeflowOrgV2alpha1Trainer. + + Entrypoint commands for the training container. # noqa: E501 + + :param command: The command of this KubeflowOrgV2alpha1Trainer. # noqa: E501 + :type: list[str] + """ + + self._command = command + + @property + def env(self): + """Gets the env of this KubeflowOrgV2alpha1Trainer. # noqa: E501 + + List of environment variables to set in the training container. These values will be merged with the TrainingRuntime's trainer environments. # noqa: E501 + + :return: The env of this KubeflowOrgV2alpha1Trainer. # noqa: E501 + :rtype: list[V1EnvVar] + """ + return self._env + + @env.setter + def env(self, env): + """Sets the env of this KubeflowOrgV2alpha1Trainer. + + List of environment variables to set in the training container. These values will be merged with the TrainingRuntime's trainer environments. # noqa: E501 + + :param env: The env of this KubeflowOrgV2alpha1Trainer. # noqa: E501 + :type: list[V1EnvVar] + """ + + self._env = env + + @property + def image(self): + """Gets the image of this KubeflowOrgV2alpha1Trainer. # noqa: E501 + + Docker image for the training container. # noqa: E501 + + :return: The image of this KubeflowOrgV2alpha1Trainer. # noqa: E501 + :rtype: str + """ + return self._image + + @image.setter + def image(self, image): + """Sets the image of this KubeflowOrgV2alpha1Trainer. + + Docker image for the training container. # noqa: E501 + + :param image: The image of this KubeflowOrgV2alpha1Trainer. # noqa: E501 + :type: str + """ + + self._image = image + + @property + def num_nodes(self): + """Gets the num_nodes of this KubeflowOrgV2alpha1Trainer. # noqa: E501 + + Number of training nodes. # noqa: E501 + + :return: The num_nodes of this KubeflowOrgV2alpha1Trainer. # noqa: E501 + :rtype: int + """ + return self._num_nodes + + @num_nodes.setter + def num_nodes(self, num_nodes): + """Sets the num_nodes of this KubeflowOrgV2alpha1Trainer. + + Number of training nodes. # noqa: E501 + + :param num_nodes: The num_nodes of this KubeflowOrgV2alpha1Trainer. # noqa: E501 + :type: int + """ + + self._num_nodes = num_nodes + + @property + def num_proc_per_node(self): + """Gets the num_proc_per_node of this KubeflowOrgV2alpha1Trainer. # noqa: E501 + + Number of processes/workers/slots on every training node. For the Torch runtime: `auto`, `cpu`, `gpu`, or int value can be set. For the MPI runtime only int value can be set. # noqa: E501 + + :return: The num_proc_per_node of this KubeflowOrgV2alpha1Trainer. # noqa: E501 + :rtype: str + """ + return self._num_proc_per_node + + @num_proc_per_node.setter + def num_proc_per_node(self, num_proc_per_node): + """Sets the num_proc_per_node of this KubeflowOrgV2alpha1Trainer. + + Number of processes/workers/slots on every training node. For the Torch runtime: `auto`, `cpu`, `gpu`, or int value can be set. For the MPI runtime only int value can be set. # noqa: E501 + + :param num_proc_per_node: The num_proc_per_node of this KubeflowOrgV2alpha1Trainer. # noqa: E501 + :type: str + """ + + self._num_proc_per_node = num_proc_per_node + + @property + def resources_per_node(self): + """Gets the resources_per_node of this KubeflowOrgV2alpha1Trainer. # noqa: E501 + + + :return: The resources_per_node of this KubeflowOrgV2alpha1Trainer. # noqa: E501 + :rtype: V1ResourceRequirements + """ + return self._resources_per_node + + @resources_per_node.setter + def resources_per_node(self, resources_per_node): + """Sets the resources_per_node of this KubeflowOrgV2alpha1Trainer. + + + :param resources_per_node: The resources_per_node of this KubeflowOrgV2alpha1Trainer. # noqa: E501 + :type: V1ResourceRequirements + """ + + self._resources_per_node = resources_per_node + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, KubeflowOrgV2alpha1Trainer): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, KubeflowOrgV2alpha1Trainer): + return True + + return self.to_dict() != other.to_dict() diff --git a/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_training_runtime.py b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_training_runtime.py new file mode 100644 index 0000000000..561067b006 --- /dev/null +++ b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_training_runtime.py @@ -0,0 +1,202 @@ +# coding: utf-8 + +""" + Kubeflow Training OpenAPI Spec + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from kubeflow.training.configuration import Configuration + + +class KubeflowOrgV2alpha1TrainingRuntime(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = { + 'api_version': 'str', + 'kind': 'str', + 'metadata': 'V1ObjectMeta', + 'spec': 'KubeflowOrgV2alpha1TrainingRuntimeSpec' + } + + attribute_map = { + 'api_version': 'apiVersion', + 'kind': 'kind', + 'metadata': 'metadata', + 'spec': 'spec' + } + + def __init__(self, api_version=None, kind=None, metadata=None, spec=None, local_vars_configuration=None): # noqa: E501 + """KubeflowOrgV2alpha1TrainingRuntime - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._api_version = None + self._kind = None + self._metadata = None + self._spec = None + self.discriminator = None + + if api_version is not None: + self.api_version = api_version + if kind is not None: + self.kind = kind + if metadata is not None: + self.metadata = metadata + if spec is not None: + self.spec = spec + + @property + def api_version(self): + """Gets the api_version of this KubeflowOrgV2alpha1TrainingRuntime. # noqa: E501 + + APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources # noqa: E501 + + :return: The api_version of this KubeflowOrgV2alpha1TrainingRuntime. # noqa: E501 + :rtype: str + """ + return self._api_version + + @api_version.setter + def api_version(self, api_version): + """Sets the api_version of this KubeflowOrgV2alpha1TrainingRuntime. + + APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources # noqa: E501 + + :param api_version: The api_version of this KubeflowOrgV2alpha1TrainingRuntime. # noqa: E501 + :type: str + """ + + self._api_version = api_version + + @property + def kind(self): + """Gets the kind of this KubeflowOrgV2alpha1TrainingRuntime. # noqa: E501 + + Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds # noqa: E501 + + :return: The kind of this KubeflowOrgV2alpha1TrainingRuntime. # noqa: E501 + :rtype: str + """ + return self._kind + + @kind.setter + def kind(self, kind): + """Sets the kind of this KubeflowOrgV2alpha1TrainingRuntime. + + Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds # noqa: E501 + + :param kind: The kind of this KubeflowOrgV2alpha1TrainingRuntime. # noqa: E501 + :type: str + """ + + self._kind = kind + + @property + def metadata(self): + """Gets the metadata of this KubeflowOrgV2alpha1TrainingRuntime. # noqa: E501 + + + :return: The metadata of this KubeflowOrgV2alpha1TrainingRuntime. # noqa: E501 + :rtype: V1ObjectMeta + """ + return self._metadata + + @metadata.setter + def metadata(self, metadata): + """Sets the metadata of this KubeflowOrgV2alpha1TrainingRuntime. + + + :param metadata: The metadata of this KubeflowOrgV2alpha1TrainingRuntime. # noqa: E501 + :type: V1ObjectMeta + """ + + self._metadata = metadata + + @property + def spec(self): + """Gets the spec of this KubeflowOrgV2alpha1TrainingRuntime. # noqa: E501 + + + :return: The spec of this KubeflowOrgV2alpha1TrainingRuntime. # noqa: E501 + :rtype: KubeflowOrgV2alpha1TrainingRuntimeSpec + """ + return self._spec + + @spec.setter + def spec(self, spec): + """Sets the spec of this KubeflowOrgV2alpha1TrainingRuntime. + + + :param spec: The spec of this KubeflowOrgV2alpha1TrainingRuntime. # noqa: E501 + :type: KubeflowOrgV2alpha1TrainingRuntimeSpec + """ + + self._spec = spec + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, KubeflowOrgV2alpha1TrainingRuntime): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, KubeflowOrgV2alpha1TrainingRuntime): + return True + + return self.to_dict() != other.to_dict() diff --git a/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_training_runtime_list.py b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_training_runtime_list.py new file mode 100644 index 0000000000..4e0536522e --- /dev/null +++ b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_training_runtime_list.py @@ -0,0 +1,205 @@ +# coding: utf-8 + +""" + Kubeflow Training OpenAPI Spec + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from kubeflow.training.configuration import Configuration + + +class KubeflowOrgV2alpha1TrainingRuntimeList(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = { + 'api_version': 'str', + 'items': 'list[KubeflowOrgV2alpha1TrainingRuntime]', + 'kind': 'str', + 'metadata': 'V1ListMeta' + } + + attribute_map = { + 'api_version': 'apiVersion', + 'items': 'items', + 'kind': 'kind', + 'metadata': 'metadata' + } + + def __init__(self, api_version=None, items=None, kind=None, metadata=None, local_vars_configuration=None): # noqa: E501 + """KubeflowOrgV2alpha1TrainingRuntimeList - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._api_version = None + self._items = None + self._kind = None + self._metadata = None + self.discriminator = None + + if api_version is not None: + self.api_version = api_version + self.items = items + if kind is not None: + self.kind = kind + if metadata is not None: + self.metadata = metadata + + @property + def api_version(self): + """Gets the api_version of this KubeflowOrgV2alpha1TrainingRuntimeList. # noqa: E501 + + APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources # noqa: E501 + + :return: The api_version of this KubeflowOrgV2alpha1TrainingRuntimeList. # noqa: E501 + :rtype: str + """ + return self._api_version + + @api_version.setter + def api_version(self, api_version): + """Sets the api_version of this KubeflowOrgV2alpha1TrainingRuntimeList. + + APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources # noqa: E501 + + :param api_version: The api_version of this KubeflowOrgV2alpha1TrainingRuntimeList. # noqa: E501 + :type: str + """ + + self._api_version = api_version + + @property + def items(self): + """Gets the items of this KubeflowOrgV2alpha1TrainingRuntimeList. # noqa: E501 + + List of TrainingRuntimes. # noqa: E501 + + :return: The items of this KubeflowOrgV2alpha1TrainingRuntimeList. # noqa: E501 + :rtype: list[KubeflowOrgV2alpha1TrainingRuntime] + """ + return self._items + + @items.setter + def items(self, items): + """Sets the items of this KubeflowOrgV2alpha1TrainingRuntimeList. + + List of TrainingRuntimes. # noqa: E501 + + :param items: The items of this KubeflowOrgV2alpha1TrainingRuntimeList. # noqa: E501 + :type: list[KubeflowOrgV2alpha1TrainingRuntime] + """ + if self.local_vars_configuration.client_side_validation and items is None: # noqa: E501 + raise ValueError("Invalid value for `items`, must not be `None`") # noqa: E501 + + self._items = items + + @property + def kind(self): + """Gets the kind of this KubeflowOrgV2alpha1TrainingRuntimeList. # noqa: E501 + + Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds # noqa: E501 + + :return: The kind of this KubeflowOrgV2alpha1TrainingRuntimeList. # noqa: E501 + :rtype: str + """ + return self._kind + + @kind.setter + def kind(self, kind): + """Sets the kind of this KubeflowOrgV2alpha1TrainingRuntimeList. + + Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds # noqa: E501 + + :param kind: The kind of this KubeflowOrgV2alpha1TrainingRuntimeList. # noqa: E501 + :type: str + """ + + self._kind = kind + + @property + def metadata(self): + """Gets the metadata of this KubeflowOrgV2alpha1TrainingRuntimeList. # noqa: E501 + + + :return: The metadata of this KubeflowOrgV2alpha1TrainingRuntimeList. # noqa: E501 + :rtype: V1ListMeta + """ + return self._metadata + + @metadata.setter + def metadata(self, metadata): + """Sets the metadata of this KubeflowOrgV2alpha1TrainingRuntimeList. + + + :param metadata: The metadata of this KubeflowOrgV2alpha1TrainingRuntimeList. # noqa: E501 + :type: V1ListMeta + """ + + self._metadata = metadata + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, KubeflowOrgV2alpha1TrainingRuntimeList): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, KubeflowOrgV2alpha1TrainingRuntimeList): + return True + + return self.to_dict() != other.to_dict() diff --git a/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_training_runtime_spec.py b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_training_runtime_spec.py new file mode 100644 index 0000000000..5669df5552 --- /dev/null +++ b/sdk_v2/kubeflow/training/models/kubeflow_org_v2alpha1_training_runtime_spec.py @@ -0,0 +1,173 @@ +# coding: utf-8 + +""" + Kubeflow Training OpenAPI Spec + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from kubeflow.training.configuration import Configuration + + +class KubeflowOrgV2alpha1TrainingRuntimeSpec(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = { + 'ml_policy': 'KubeflowOrgV2alpha1MLPolicy', + 'pod_group_policy': 'KubeflowOrgV2alpha1PodGroupPolicy', + 'template': 'KubeflowOrgV2alpha1JobSetTemplateSpec' + } + + attribute_map = { + 'ml_policy': 'mlPolicy', + 'pod_group_policy': 'podGroupPolicy', + 'template': 'template' + } + + def __init__(self, ml_policy=None, pod_group_policy=None, template=None, local_vars_configuration=None): # noqa: E501 + """KubeflowOrgV2alpha1TrainingRuntimeSpec - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._ml_policy = None + self._pod_group_policy = None + self._template = None + self.discriminator = None + + if ml_policy is not None: + self.ml_policy = ml_policy + if pod_group_policy is not None: + self.pod_group_policy = pod_group_policy + self.template = template + + @property + def ml_policy(self): + """Gets the ml_policy of this KubeflowOrgV2alpha1TrainingRuntimeSpec. # noqa: E501 + + + :return: The ml_policy of this KubeflowOrgV2alpha1TrainingRuntimeSpec. # noqa: E501 + :rtype: KubeflowOrgV2alpha1MLPolicy + """ + return self._ml_policy + + @ml_policy.setter + def ml_policy(self, ml_policy): + """Sets the ml_policy of this KubeflowOrgV2alpha1TrainingRuntimeSpec. + + + :param ml_policy: The ml_policy of this KubeflowOrgV2alpha1TrainingRuntimeSpec. # noqa: E501 + :type: KubeflowOrgV2alpha1MLPolicy + """ + + self._ml_policy = ml_policy + + @property + def pod_group_policy(self): + """Gets the pod_group_policy of this KubeflowOrgV2alpha1TrainingRuntimeSpec. # noqa: E501 + + + :return: The pod_group_policy of this KubeflowOrgV2alpha1TrainingRuntimeSpec. # noqa: E501 + :rtype: KubeflowOrgV2alpha1PodGroupPolicy + """ + return self._pod_group_policy + + @pod_group_policy.setter + def pod_group_policy(self, pod_group_policy): + """Sets the pod_group_policy of this KubeflowOrgV2alpha1TrainingRuntimeSpec. + + + :param pod_group_policy: The pod_group_policy of this KubeflowOrgV2alpha1TrainingRuntimeSpec. # noqa: E501 + :type: KubeflowOrgV2alpha1PodGroupPolicy + """ + + self._pod_group_policy = pod_group_policy + + @property + def template(self): + """Gets the template of this KubeflowOrgV2alpha1TrainingRuntimeSpec. # noqa: E501 + + + :return: The template of this KubeflowOrgV2alpha1TrainingRuntimeSpec. # noqa: E501 + :rtype: KubeflowOrgV2alpha1JobSetTemplateSpec + """ + return self._template + + @template.setter + def template(self, template): + """Sets the template of this KubeflowOrgV2alpha1TrainingRuntimeSpec. + + + :param template: The template of this KubeflowOrgV2alpha1TrainingRuntimeSpec. # noqa: E501 + :type: KubeflowOrgV2alpha1JobSetTemplateSpec + """ + if self.local_vars_configuration.client_side_validation and template is None: # noqa: E501 + raise ValueError("Invalid value for `template`, must not be `None`") # noqa: E501 + + self._template = template + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, KubeflowOrgV2alpha1TrainingRuntimeSpec): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, KubeflowOrgV2alpha1TrainingRuntimeSpec): + return True + + return self.to_dict() != other.to_dict() diff --git a/sdk_v2/kubeflow/training/rest.py b/sdk_v2/kubeflow/training/rest.py new file mode 100644 index 0000000000..10f00d096d --- /dev/null +++ b/sdk_v2/kubeflow/training/rest.py @@ -0,0 +1,291 @@ +# coding: utf-8 + +""" + Kubeflow Training OpenAPI Spec + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import io +import json +import logging +import re +import ssl + +import certifi +# python 2 and python 3 compatibility library +import six +from six.moves.urllib.parse import urlencode +import urllib3 + +from kubeflow.training.exceptions import ApiException, ApiValueError + + +logger = logging.getLogger(__name__) + + +class RESTResponse(io.IOBase): + + def __init__(self, resp): + self.urllib3_response = resp + self.status = resp.status + self.reason = resp.reason + self.data = resp.data + + def getheaders(self): + """Returns a dictionary of the response headers.""" + return self.urllib3_response.getheaders() + + def getheader(self, name, default=None): + """Returns a given response header.""" + return self.urllib3_response.getheader(name, default) + + +class RESTClientObject(object): + + def __init__(self, configuration, pools_size=4, maxsize=None): + # urllib3.PoolManager will pass all kw parameters to connectionpool + # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/poolmanager.py#L75 # noqa: E501 + # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/connectionpool.py#L680 # noqa: E501 + # maxsize is the number of requests to host that are allowed in parallel # noqa: E501 + # Custom SSL certificates and client certificates: http://urllib3.readthedocs.io/en/latest/advanced-usage.html # noqa: E501 + + # cert_reqs + if configuration.verify_ssl: + cert_reqs = ssl.CERT_REQUIRED + else: + cert_reqs = ssl.CERT_NONE + + # ca_certs + if configuration.ssl_ca_cert: + ca_certs = configuration.ssl_ca_cert + else: + # if not set certificate file, use Mozilla's root certificates. + ca_certs = certifi.where() + + addition_pool_args = {} + if configuration.assert_hostname is not None: + addition_pool_args['assert_hostname'] = configuration.assert_hostname # noqa: E501 + + if configuration.retries is not None: + addition_pool_args['retries'] = configuration.retries + + if maxsize is None: + if configuration.connection_pool_maxsize is not None: + maxsize = configuration.connection_pool_maxsize + else: + maxsize = 4 + + # https pool manager + if configuration.proxy: + self.pool_manager = urllib3.ProxyManager( + num_pools=pools_size, + maxsize=maxsize, + cert_reqs=cert_reqs, + ca_certs=ca_certs, + cert_file=configuration.cert_file, + key_file=configuration.key_file, + proxy_url=configuration.proxy, + proxy_headers=configuration.proxy_headers, + **addition_pool_args + ) + else: + self.pool_manager = urllib3.PoolManager( + num_pools=pools_size, + maxsize=maxsize, + cert_reqs=cert_reqs, + ca_certs=ca_certs, + cert_file=configuration.cert_file, + key_file=configuration.key_file, + **addition_pool_args + ) + + def request(self, method, url, query_params=None, headers=None, + body=None, post_params=None, _preload_content=True, + _request_timeout=None): + """Perform requests. + + :param method: http request method + :param url: http request url + :param query_params: query parameters in the url + :param headers: http request headers + :param body: request json body, for `application/json` + :param post_params: request post parameters, + `application/x-www-form-urlencoded` + and `multipart/form-data` + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :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. + """ + method = method.upper() + assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT', + 'PATCH', 'OPTIONS'] + + if post_params and body: + raise ApiValueError( + "body parameter cannot be used with post_params parameter." + ) + + post_params = post_params or {} + headers = headers or {} + + timeout = None + if _request_timeout: + if isinstance(_request_timeout, (int, ) if six.PY3 else (int, long)): # noqa: E501,F821 + timeout = urllib3.Timeout(total=_request_timeout) + elif (isinstance(_request_timeout, tuple) and + len(_request_timeout) == 2): + timeout = urllib3.Timeout( + connect=_request_timeout[0], read=_request_timeout[1]) + + if 'Content-Type' not in headers: + headers['Content-Type'] = 'application/json' + + try: + # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` + if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: + if query_params: + url += '?' + urlencode(query_params) + if re.search('json', headers['Content-Type'], re.IGNORECASE): + request_body = None + if body is not None: + request_body = json.dumps(body) + r = self.pool_manager.request( + method, url, + body=request_body, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501 + r = self.pool_manager.request( + method, url, + fields=post_params, + encode_multipart=False, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + elif headers['Content-Type'] == 'multipart/form-data': + # must del headers['Content-Type'], or the correct + # Content-Type which generated by urllib3 will be + # overwritten. + del headers['Content-Type'] + r = self.pool_manager.request( + method, url, + fields=post_params, + encode_multipart=True, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + # Pass a `string` parameter directly in the body to support + # other content types than Json when `body` argument is + # provided in serialized form + elif isinstance(body, str) or isinstance(body, bytes): + request_body = body + r = self.pool_manager.request( + method, url, + body=request_body, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + else: + # Cannot generate the request from given parameters + msg = """Cannot prepare a request message for provided + arguments. Please check that your arguments match + declared content type.""" + raise ApiException(status=0, reason=msg) + # For `GET`, `HEAD` + else: + r = self.pool_manager.request(method, url, + fields=query_params, + preload_content=_preload_content, + timeout=timeout, + headers=headers) + except urllib3.exceptions.SSLError as e: + msg = "{0}\n{1}".format(type(e).__name__, str(e)) + raise ApiException(status=0, reason=msg) + + if _preload_content: + r = RESTResponse(r) + + # log response body + logger.debug("response body: %s", r.data) + + if not 200 <= r.status <= 299: + raise ApiException(http_resp=r) + + return r + + def GET(self, url, headers=None, query_params=None, _preload_content=True, + _request_timeout=None): + return self.request("GET", url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params) + + def HEAD(self, url, headers=None, query_params=None, _preload_content=True, + _request_timeout=None): + return self.request("HEAD", url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params) + + def OPTIONS(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("OPTIONS", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def DELETE(self, url, headers=None, query_params=None, body=None, + _preload_content=True, _request_timeout=None): + return self.request("DELETE", url, + headers=headers, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def POST(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("POST", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def PUT(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("PUT", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def PATCH(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("PATCH", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) diff --git a/sdk_v2/pyproject.toml b/sdk_v2/pyproject.toml new file mode 100644 index 0000000000..01bdd0f8a4 --- /dev/null +++ b/sdk_v2/pyproject.toml @@ -0,0 +1,44 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +# TODO (andreyvelich): Potentially, we can move our SDK to Kubeflow: https://pypi.org/project/kubeflow/ +name = "kubeflow-training" +dynamic = ["version"] +authors = [ + { name = "The Kubeflow Authors", email = "kubeflow-discuss@googlegroups.com" }, +] +license = { file = "../LICENSE" } +description = "Kubeflow Training Python SDK to manage ML training and LLM fine-tuning jobs." +readme = "../README.md" +keywords = ["kubeflow", "training", "model training", "llm", "ai"] +classifiers = [ + "Intended Audience :: Developers", + "Intended Audience :: Education", + "Intended Audience :: Science/Research", + # TODO (andreyvelich): Check Python version for V2. + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "License :: OSI Approved :: Apache Software License", + "Operating System :: OS Independent", + "Topic :: Scientific/Engineering", + "Topic :: Scientific/Engineering :: Artificial Intelligence", + "Topic :: Software Development", + "Topic :: Software Development :: Libraries", + "Topic :: Software Development :: Libraries :: Python Modules", +] +dependencies = ["kubernetes>=27.2.0"] + +[project.urls] +Homepage = "https://github.com/kubeflow/training-operator" +Documentation = "https://www.kubeflow.org/docs/components/training/" +Source = "https://github.com/kubeflow/training-operator" + +[tool.hatch.build.targets.wheel] +packages = ["kubeflow"] + +[tool.hatch.version] +path = "kubeflow/training/__init__.py"