From abe1d456d9b25e7353acc40ec2963417807793f8 Mon Sep 17 00:00:00 2001 From: epicseven-cup Date: Sun, 29 Sep 2024 18:54:10 -0400 Subject: [PATCH 01/14] update gen-sdk.sh to generate sdk using docker container --- hack/python-sdk/gen-sdk.sh | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/hack/python-sdk/gen-sdk.sh b/hack/python-sdk/gen-sdk.sh index e9046198d..a9481621d 100755 --- a/hack/python-sdk/gen-sdk.sh +++ b/hack/python-sdk/gen-sdk.sh @@ -23,8 +23,8 @@ set -x repo_root="$(dirname "${BASH_SOURCE}")/../.." -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="${repo_root}/hack/python-sdk/openapi-generator-cli.jar" +#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="${repo_root}/hack/python-sdk/openapi-generator-cli.jar" SWAGGER_CODEGEN_CONF="${repo_root}/hack/python-sdk/swagger_config.json" SDK_OUTPUT_PATH="${repo_root}/sdk/python" VERSION=0.1.4 @@ -37,17 +37,19 @@ fi echo "Generating OpenAPI specification ..." echo "./hack/update-codegen.sh already help us generate openapi specs ..." -if [[ ! -f "$SWAGGER_CODEGEN_JAR" ]]; then - echo "Downloading the swagger-codegen JAR package ..." - wget -O "${SWAGGER_CODEGEN_JAR}" ${SWAGGER_JAR_URL} -fi +#if [[ ! -f "$SWAGGER_CODEGEN_JAR" ]]; then +# echo "Downloading the swagger-codegen JAR package ..." +# wget -O "${SWAGGER_CODEGEN_JAR}" ${SWAGGER_JAR_URL} +#fi -if [ -z `which java` ]; then - apt-get update -y - # TODO: update this fallback (remove it) when openjdk-11 completely deprecated - echo "Installing OpenJDK 11 with fallback to OpenJDK 17" - apt-get install -y openjdk-11-jdk || apt-get install -y openjdk-17-jdk -fi + +# Currently removed +#if [ -z `which java` ]; then +# apt-get update -y +# # TODO: update this fallback (remove it) when openjdk-11 completely deprecated +# echo "Installing OpenJDK 11 with fallback to OpenJDK 17" +# apt-get install -y openjdk-11-jdk || apt-get install -y openjdk-17-jdk +#fi echo "Generating swagger file ..." go run "${repo_root}"/hack/swagger/main.go ${VERSION} >"${SWAGGER_CODEGEN_FILE}" @@ -56,7 +58,15 @@ echo "Removing previously generated files ..." rm -rf "${SDK_OUTPUT_PATH}"/docs/V1*.md "${SDK_OUTPUT_PATH}"/jobset/models "${SDK_OUTPUT_PATH}"/test/test_*.py echo "Generating Python SDK for JobSet..." -java -jar "${SWAGGER_CODEGEN_JAR}" generate -i ${SWAGGER_CODEGEN_FILE} -g python -o "${SDK_OUTPUT_PATH}" -c "${SWAGGER_CODEGEN_CONF}" +#java -jar "${SWAGGER_CODEGEN_JAR}" generate -i ${SWAGGER_CODEGEN_FILE} -g python -o "${SDK_OUTPUT_PATH}" -c "${SWAGGER_CODEGEN_CONF}" +# Install the skds using docker +docker run --rm \ +# Hooking up the whole repo onto the local folder + -v "${repo_root}":/local openapitools/openapi-generator-cli generate \ + -i /local/ ${SWAGGER_CODEGEN_FILE} \ + -g python \ + -o /local/"${SDK_OUTPUT_PATH}" \ + -c ${SWAGGER_CODEGEN_FILE} echo "Running post-generation script ..." "${repo_root}"/hack/python-sdk/post_gen.py From a4bd93a609f06a5ba05013cb3b681d4093c49436 Mon Sep 17 00:00:00 2001 From: epicseven-cup Date: Sun, 29 Sep 2024 19:06:04 -0400 Subject: [PATCH 02/14] clean up some of the code apt install --- hack/python-sdk/gen-sdk.sh | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/hack/python-sdk/gen-sdk.sh b/hack/python-sdk/gen-sdk.sh index a9481621d..be516659a 100755 --- a/hack/python-sdk/gen-sdk.sh +++ b/hack/python-sdk/gen-sdk.sh @@ -23,8 +23,6 @@ set -x repo_root="$(dirname "${BASH_SOURCE}")/../.." -#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="${repo_root}/hack/python-sdk/openapi-generator-cli.jar" SWAGGER_CODEGEN_CONF="${repo_root}/hack/python-sdk/swagger_config.json" SDK_OUTPUT_PATH="${repo_root}/sdk/python" VERSION=0.1.4 @@ -37,20 +35,6 @@ fi echo "Generating OpenAPI specification ..." echo "./hack/update-codegen.sh already help us generate openapi specs ..." -#if [[ ! -f "$SWAGGER_CODEGEN_JAR" ]]; then -# echo "Downloading the swagger-codegen JAR package ..." -# wget -O "${SWAGGER_CODEGEN_JAR}" ${SWAGGER_JAR_URL} -#fi - - -# Currently removed -#if [ -z `which java` ]; then -# apt-get update -y -# # TODO: update this fallback (remove it) when openjdk-11 completely deprecated -# echo "Installing OpenJDK 11 with fallback to OpenJDK 17" -# apt-get install -y openjdk-11-jdk || apt-get install -y openjdk-17-jdk -#fi - echo "Generating swagger file ..." go run "${repo_root}"/hack/swagger/main.go ${VERSION} >"${SWAGGER_CODEGEN_FILE}" @@ -58,12 +42,11 @@ echo "Removing previously generated files ..." rm -rf "${SDK_OUTPUT_PATH}"/docs/V1*.md "${SDK_OUTPUT_PATH}"/jobset/models "${SDK_OUTPUT_PATH}"/test/test_*.py echo "Generating Python SDK for JobSet..." -#java -jar "${SWAGGER_CODEGEN_JAR}" generate -i ${SWAGGER_CODEGEN_FILE} -g python -o "${SDK_OUTPUT_PATH}" -c "${SWAGGER_CODEGEN_CONF}" -# Install the skds using docker +# Install the sdk using docker docker run --rm \ # Hooking up the whole repo onto the local folder -v "${repo_root}":/local openapitools/openapi-generator-cli generate \ - -i /local/ ${SWAGGER_CODEGEN_FILE} \ + -i /local/${SWAGGER_CODEGEN_FILE} \ -g python \ -o /local/"${SDK_OUTPUT_PATH}" \ -c ${SWAGGER_CODEGEN_FILE} From 04903927e64787dbace6d43dc43e5acf417a250a Mon Sep 17 00:00:00 2001 From: epicseven-cup Date: Sat, 5 Oct 2024 13:51:35 -0400 Subject: [PATCH 03/14] added docker install so gen-sdk script can use docker --- hack/python-sdk/gen-sdk.sh | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/hack/python-sdk/gen-sdk.sh b/hack/python-sdk/gen-sdk.sh index be516659a..318ecb8b9 100755 --- a/hack/python-sdk/gen-sdk.sh +++ b/hack/python-sdk/gen-sdk.sh @@ -42,10 +42,28 @@ echo "Removing previously generated files ..." rm -rf "${SDK_OUTPUT_PATH}"/docs/V1*.md "${SDK_OUTPUT_PATH}"/jobset/models "${SDK_OUTPUT_PATH}"/test/test_*.py echo "Generating Python SDK for JobSet..." + + +# Defaults the container engine to docker +CONTAINER_ENGINE=${CONTAINER_ENGINE:-docker} +# Checking if docker / podman is installed +if ! { [ $(command -v docker &> /dev/null) ] && [ $(command -v podman &> /dev/null) ] }; then + # Install docker + echo "Both Podman and Docker is not installed" + echo "Installing Docker now (Version 17.03.0)" + # Defaulting to 17.03.0 + wget https://download.docker.com/linux/static/stable/x86_64/docker-17.03.0-ce.tgz + tar xzvf docker-17.03.0-ce.tgz + echo "Starting dockerd" + ./docker/dockerd & +elif [ `command -v podman &> /dev/null` ]; then + echo "Found that Podman is installed, using that now" + CONTAINER_ENGINE="podman" +fi + # Install the sdk using docker -docker run --rm \ -# Hooking up the whole repo onto the local folder - -v "${repo_root}":/local openapitools/openapi-generator-cli generate \ +${CONTAINER_ENGINE} run --rm \ + -v docker.io/"${repo_root}":/local openapitools/openapi-generator-cli generate \ -i /local/${SWAGGER_CODEGEN_FILE} \ -g python \ -o /local/"${SDK_OUTPUT_PATH}" \ From b248701795f8acd1e27c55f20f8e0bd497876f43 Mon Sep 17 00:00:00 2001 From: epicseven-cup Date: Sun, 6 Oct 2024 11:56:09 -0400 Subject: [PATCH 04/14] update bash script, doing some quick local testing --- hack/python-sdk/gen-sdk.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hack/python-sdk/gen-sdk.sh b/hack/python-sdk/gen-sdk.sh index 318ecb8b9..086ab7945 100755 --- a/hack/python-sdk/gen-sdk.sh +++ b/hack/python-sdk/gen-sdk.sh @@ -47,7 +47,8 @@ echo "Generating Python SDK for JobSet..." # Defaults the container engine to docker CONTAINER_ENGINE=${CONTAINER_ENGINE:-docker} # Checking if docker / podman is installed -if ! { [ $(command -v docker &> /dev/null) ] && [ $(command -v podman &> /dev/null) ] }; then +# shellcheck disable=SC2046 +if ! [ $(command -v docker &> /dev/null) ] && [ $(command -v podman &> /dev/null) ]; then # Install docker echo "Both Podman and Docker is not installed" echo "Installing Docker now (Version 17.03.0)" @@ -56,7 +57,7 @@ if ! { [ $(command -v docker &> /dev/null) ] && [ $(command -v podman &> /dev/nu tar xzvf docker-17.03.0-ce.tgz echo "Starting dockerd" ./docker/dockerd & -elif [ `command -v podman &> /dev/null` ]; then +elif [ $(command -v podman &> /dev/null) ]; then echo "Found that Podman is installed, using that now" CONTAINER_ENGINE="podman" fi From 9747188f343ff7a166a56a931d2d332660ff5839 Mon Sep 17 00:00:00 2001 From: epicseven-cup Date: Sun, 6 Oct 2024 14:10:43 -0400 Subject: [PATCH 05/14] finish hooking up volumes and the sdk generation --- hack/python-sdk/gen-sdk.sh | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/hack/python-sdk/gen-sdk.sh b/hack/python-sdk/gen-sdk.sh index 086ab7945..c13cae102 100755 --- a/hack/python-sdk/gen-sdk.sh +++ b/hack/python-sdk/gen-sdk.sh @@ -46,9 +46,14 @@ echo "Generating Python SDK for JobSet..." # Defaults the container engine to docker CONTAINER_ENGINE=${CONTAINER_ENGINE:-docker} + +DOCKER_EXIST=$(command -v docker) +PODMAN_EXIST=$(command -v podman) + +echo DOCKER_EXIST +echo PODMAN_EXIST # Checking if docker / podman is installed -# shellcheck disable=SC2046 -if ! [ $(command -v docker &> /dev/null) ] && [ $(command -v podman &> /dev/null) ]; then +if ! [ "$DOCKER_EXIST" ] && ! [ "$PODMAN_EXIST" ]; then # Install docker echo "Both Podman and Docker is not installed" echo "Installing Docker now (Version 17.03.0)" @@ -57,18 +62,18 @@ if ! [ $(command -v docker &> /dev/null) ] && [ $(command -v podman &> /dev/null tar xzvf docker-17.03.0-ce.tgz echo "Starting dockerd" ./docker/dockerd & -elif [ $(command -v podman &> /dev/null) ]; then - echo "Found that Podman is installed, using that now" +elif ! [ "$DOCKER_EXIST" ] && [ "$PODMAN_EXIST" ]; then + echo "Found Podman, switching to Podman" CONTAINER_ENGINE="podman" fi # Install the sdk using docker ${CONTAINER_ENGINE} run --rm \ - -v docker.io/"${repo_root}":/local openapitools/openapi-generator-cli generate \ - -i /local/${SWAGGER_CODEGEN_FILE} \ + -v "${repo_root}":/local docker.io/openapitools/openapi-generator-cli generate \ + -i /local/"${SWAGGER_CODEGEN_FILE}" \ -g python \ -o /local/"${SDK_OUTPUT_PATH}" \ - -c ${SWAGGER_CODEGEN_FILE} + -c local/"${SWAGGER_CODEGEN_FILE}" echo "Running post-generation script ..." "${repo_root}"/hack/python-sdk/post_gen.py From e81b842dda6ce6a3735eded47238fc4f29ef7312 Mon Sep 17 00:00:00 2001 From: epicseven-cup Date: Sun, 6 Oct 2024 16:11:46 -0400 Subject: [PATCH 06/14] adding selection to remove installsation of docker --- hack/python-sdk/gen-sdk.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hack/python-sdk/gen-sdk.sh b/hack/python-sdk/gen-sdk.sh index c13cae102..4baaf0bcd 100755 --- a/hack/python-sdk/gen-sdk.sh +++ b/hack/python-sdk/gen-sdk.sh @@ -75,6 +75,11 @@ ${CONTAINER_ENGINE} run --rm \ -o /local/"${SDK_OUTPUT_PATH}" \ -c local/"${SWAGGER_CODEGEN_FILE}" +if [ -d "docker-17.03.0-ce.tgz" ]; then + echo "Removing docker install folder" + rm -r docker-17.03.0-ce.tgz +fi + echo "Running post-generation script ..." "${repo_root}"/hack/python-sdk/post_gen.py From cdd94dea42dc168df223d01372c0c1423dc41f39 Mon Sep 17 00:00:00 2001 From: epicseven-cup Date: Wed, 9 Oct 2024 21:17:20 -0400 Subject: [PATCH 07/14] ran locally with docker and podman installed --- hack/python-sdk/gen-sdk.sh | 19 +- sdk/python/.github/workflows/python.yml | 38 + sdk/python/.gitlab-ci.yml | 38 +- sdk/python/.openapi-generator/FILES | 58 ++ sdk/python/.openapi-generator/VERSION | 2 +- sdk/python/.travis.yml | 12 +- sdk/python/README.md | 13 +- sdk/python/docs/JobsetV1alpha2Coordinator.md | 19 + .../docs/JobsetV1alpha2FailurePolicy.md | 21 +- .../docs/JobsetV1alpha2FailurePolicyRule.md | 23 +- sdk/python/docs/JobsetV1alpha2JobSet.md | 19 + sdk/python/docs/JobsetV1alpha2JobSetList.md | 21 +- sdk/python/docs/JobsetV1alpha2JobSetSpec.md | 21 +- sdk/python/docs/JobsetV1alpha2JobSetStatus.md | 23 +- sdk/python/docs/JobsetV1alpha2Network.md | 19 + .../docs/JobsetV1alpha2ReplicatedJob.md | 19 + .../docs/JobsetV1alpha2ReplicatedJobStatus.md | 19 + .../docs/JobsetV1alpha2StartupPolicy.md | 19 + .../docs/JobsetV1alpha2SuccessPolicy.md | 21 +- sdk/python/git_push.sh | 7 +- sdk/python/jobset/__init__.py | 12 +- sdk/python/jobset/api/__init__.py | 3 +- sdk/python/jobset/api_client.py | 755 ++++++++++-------- sdk/python/jobset/api_response.py | 21 + sdk/python/jobset/configuration.py | 178 +++-- sdk/python/jobset/exceptions.py | 119 ++- sdk/python/jobset/models/__init__.py | 11 +- .../models/jobset_v1alpha2_coordinator.py | 228 ++---- .../models/jobset_v1alpha2_failure_policy.py | 213 ++--- .../jobset_v1alpha2_failure_policy_rule.py | 267 ++----- .../jobset/models/jobset_v1alpha2_job_set.py | 300 +++---- .../models/jobset_v1alpha2_job_set_list.py | 273 ++----- .../models/jobset_v1alpha2_job_set_spec.py | 439 +++------- .../models/jobset_v1alpha2_job_set_status.py | 308 +++---- .../jobset/models/jobset_v1alpha2_network.py | 227 ++---- .../models/jobset_v1alpha2_replicated_job.py | 238 ++---- .../jobset_v1alpha2_replicated_job_status.py | 331 ++------ .../models/jobset_v1alpha2_startup_policy.py | 156 ++-- .../models/jobset_v1alpha2_success_policy.py | 198 ++--- sdk/python/jobset/py.typed | 0 sdk/python/jobset/rest.py | 306 ++++--- sdk/python/pyproject.toml | 88 +- sdk/python/requirements.txt | 7 +- sdk/python/test-requirements.txt | 4 +- .../test/test_jobset_v1alpha2_coordinator.py | 41 +- .../test_jobset_v1alpha2_failure_policy.py | 43 +- ...est_jobset_v1alpha2_failure_policy_rule.py | 47 +- .../test/test_jobset_v1alpha2_job_set.py | 65 +- .../test/test_jobset_v1alpha2_job_set_list.py | 95 ++- .../test/test_jobset_v1alpha2_job_set_spec.py | 63 +- .../test_jobset_v1alpha2_job_set_status.py | 45 +- .../test/test_jobset_v1alpha2_network.py | 39 +- .../test_jobset_v1alpha2_replicated_job.py | 39 +- ...t_jobset_v1alpha2_replicated_job_status.py | 45 +- .../test_jobset_v1alpha2_startup_policy.py | 37 +- .../test_jobset_v1alpha2_success_policy.py | 39 +- sdk/python/tox.ini | 2 +- 57 files changed, 2537 insertions(+), 3176 deletions(-) create mode 100644 sdk/python/.github/workflows/python.yml create mode 100644 sdk/python/.openapi-generator/FILES create mode 100644 sdk/python/jobset/api_response.py create mode 100644 sdk/python/jobset/py.typed diff --git a/hack/python-sdk/gen-sdk.sh b/hack/python-sdk/gen-sdk.sh index 4baaf0bcd..f1da5c48a 100755 --- a/hack/python-sdk/gen-sdk.sh +++ b/hack/python-sdk/gen-sdk.sh @@ -67,18 +67,13 @@ elif ! [ "$DOCKER_EXIST" ] && [ "$PODMAN_EXIST" ]; then CONTAINER_ENGINE="podman" fi -# Install the sdk using docker -${CONTAINER_ENGINE} run --rm \ +# Install the sdk using docker, using the user that is running the container engine so that files can still be removed +${CONTAINER_ENGINE} run --user $(id -u):$(id -g) --rm \ -v "${repo_root}":/local docker.io/openapitools/openapi-generator-cli generate \ -i /local/"${SWAGGER_CODEGEN_FILE}" \ -g python \ -o /local/"${SDK_OUTPUT_PATH}" \ - -c local/"${SWAGGER_CODEGEN_FILE}" - -if [ -d "docker-17.03.0-ce.tgz" ]; then - echo "Removing docker install folder" - rm -r docker-17.03.0-ce.tgz -fi + -c local/"${SWAGGER_CODEGEN_CONF}" echo "Running post-generation script ..." "${repo_root}"/hack/python-sdk/post_gen.py @@ -86,4 +81,10 @@ echo "Running post-generation script ..." echo "JobSet Python SDK is generated successfully to folder ${SDK_OUTPUT_PATH}/." # Remove setup.py -rm ${SDK_OUTPUT_PATH}/setup.py +rm "${SDK_OUTPUT_PATH}"/setup.py + +# Clean up +if [ -d "docker-17.03.0-ce.tgz" ]; then + echo "Removing docker install folder" + rm -r docker-17.03.0-ce.tgz +fi diff --git a/sdk/python/.github/workflows/python.yml b/sdk/python/.github/workflows/python.yml new file mode 100644 index 000000000..d4a179383 --- /dev/null +++ b/sdk/python/.github/workflows/python.yml @@ -0,0 +1,38 @@ +# NOTE: This file is auto generated by OpenAPI Generator. +# URL: https://openapi-generator.tech +# +# ref: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + +name: jobset Python package + +on: [push, pull_request] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 pytest + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + if [ -f test-requirements.txt ]; then pip install -r test-requirements.txt; fi + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + pytest diff --git a/sdk/python/.gitlab-ci.yml b/sdk/python/.gitlab-ci.yml index 589036f32..f9f9d7cdd 100644 --- a/sdk/python/.gitlab-ci.yml +++ b/sdk/python/.gitlab-ci.yml @@ -1,33 +1,31 @@ +# NOTE: This file is auto generated by OpenAPI Generator. +# URL: https://openapi-generator.tech +# # ref: https://docs.gitlab.com/ee/ci/README.html +# ref: https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Python.gitlab-ci.yml stages: - test -.nosetest: +.pytest: stage: test script: - pip install -r requirements.txt - pip install -r test-requirements.txt - pytest --cov=jobset -nosetest-2.7: - extends: .nosetest - image: python:2.7-alpine -nosetest-3.3: - extends: .nosetest - image: python:3.3-alpine -nosetest-3.4: - extends: .nosetest - image: python:3.4-alpine -nosetest-3.5: - extends: .nosetest - image: python:3.5-alpine -nosetest-3.6: - extends: .nosetest - image: python:3.6-alpine -nosetest-3.7: - extends: .nosetest +pytest-3.7: + extends: .pytest image: python:3.7-alpine -nosetest-3.8: - extends: .nosetest +pytest-3.8: + extends: .pytest image: python:3.8-alpine +pytest-3.9: + extends: .pytest + image: python:3.9-alpine +pytest-3.10: + extends: .pytest + image: python:3.10-alpine +pytest-3.11: + extends: .pytest + image: python:3.11-alpine diff --git a/sdk/python/.openapi-generator/FILES b/sdk/python/.openapi-generator/FILES new file mode 100644 index 000000000..4c21c1644 --- /dev/null +++ b/sdk/python/.openapi-generator/FILES @@ -0,0 +1,58 @@ +.github/workflows/python.yml +.gitignore +.gitlab-ci.yml +.travis.yml +README.md +docs/JobsetV1alpha2Coordinator.md +docs/JobsetV1alpha2FailurePolicy.md +docs/JobsetV1alpha2FailurePolicyRule.md +docs/JobsetV1alpha2JobSet.md +docs/JobsetV1alpha2JobSetList.md +docs/JobsetV1alpha2JobSetSpec.md +docs/JobsetV1alpha2JobSetStatus.md +docs/JobsetV1alpha2Network.md +docs/JobsetV1alpha2ReplicatedJob.md +docs/JobsetV1alpha2ReplicatedJobStatus.md +docs/JobsetV1alpha2StartupPolicy.md +docs/JobsetV1alpha2SuccessPolicy.md +git_push.sh +jobset/__init__.py +jobset/api/__init__.py +jobset/api_client.py +jobset/api_response.py +jobset/configuration.py +jobset/exceptions.py +jobset/models/__init__.py +jobset/models/jobset_v1alpha2_coordinator.py +jobset/models/jobset_v1alpha2_failure_policy.py +jobset/models/jobset_v1alpha2_failure_policy_rule.py +jobset/models/jobset_v1alpha2_job_set.py +jobset/models/jobset_v1alpha2_job_set_list.py +jobset/models/jobset_v1alpha2_job_set_spec.py +jobset/models/jobset_v1alpha2_job_set_status.py +jobset/models/jobset_v1alpha2_network.py +jobset/models/jobset_v1alpha2_replicated_job.py +jobset/models/jobset_v1alpha2_replicated_job_status.py +jobset/models/jobset_v1alpha2_startup_policy.py +jobset/models/jobset_v1alpha2_success_policy.py +jobset/py.typed +jobset/rest.py +pyproject.toml +requirements.txt +setup.cfg +setup.py +test-requirements.txt +test/__init__.py +test/test_jobset_v1alpha2_coordinator.py +test/test_jobset_v1alpha2_failure_policy.py +test/test_jobset_v1alpha2_failure_policy_rule.py +test/test_jobset_v1alpha2_job_set.py +test/test_jobset_v1alpha2_job_set_list.py +test/test_jobset_v1alpha2_job_set_spec.py +test/test_jobset_v1alpha2_job_set_status.py +test/test_jobset_v1alpha2_network.py +test/test_jobset_v1alpha2_replicated_job.py +test/test_jobset_v1alpha2_replicated_job_status.py +test/test_jobset_v1alpha2_startup_policy.py +test/test_jobset_v1alpha2_success_policy.py +tox.ini diff --git a/sdk/python/.openapi-generator/VERSION b/sdk/python/.openapi-generator/VERSION index ecedc98d1..17f2442ff 100644 --- a/sdk/python/.openapi-generator/VERSION +++ b/sdk/python/.openapi-generator/VERSION @@ -1 +1 @@ -4.3.1 \ No newline at end of file +7.9.0-SNAPSHOT diff --git a/sdk/python/.travis.yml b/sdk/python/.travis.yml index 3411bd402..f55392ea9 100644 --- a/sdk/python/.travis.yml +++ b/sdk/python/.travis.yml @@ -1,14 +1,14 @@ # ref: https://docs.travis-ci.com/user/languages/python language: python python: - - "2.7" - - "3.2" - - "3.3" - - "3.4" - - "3.5" - - "3.6" - "3.7" - "3.8" + - "3.9" + - "3.10" + - "3.11" + # uncomment the following if needed + #- "3.11-dev" # 3.11 development branch + #- "nightly" # nightly build # command to install dependencies install: - "pip install -r requirements.txt" diff --git a/sdk/python/README.md b/sdk/python/README.md index 374681a62..d31033066 100644 --- a/sdk/python/README.md +++ b/sdk/python/README.md @@ -5,11 +5,12 @@ This Python package is automatically generated by the [OpenAPI Generator](https: - API version: v0.1.4 - Package version: 0.1.4 +- Generator version: 7.9.0-SNAPSHOT - Build package: org.openapitools.codegen.languages.PythonClientCodegen ## Requirements. -Python 2.7 and 3.4+ +Python 3.7+ ## Installation & Usage ### pip install @@ -40,14 +41,16 @@ Then import the package: import jobset ``` +### Tests + +Execute `pytest` to run the tests. + ## Getting Started Please follow the [installation procedure](#installation--usage) and then run the following: ```python -from __future__ import print_function -import time import jobset from jobset.rest import ApiException from pprint import pprint @@ -78,9 +81,11 @@ Class | Method | HTTP request | Description - [JobsetV1alpha2SuccessPolicy](docs/JobsetV1alpha2SuccessPolicy.md) + ## Documentation For Authorization - All endpoints do not require authorization. +Endpoints do not require authorization. + ## Author diff --git a/sdk/python/docs/JobsetV1alpha2Coordinator.md b/sdk/python/docs/JobsetV1alpha2Coordinator.md index 5c893be6d..ed5322286 100644 --- a/sdk/python/docs/JobsetV1alpha2Coordinator.md +++ b/sdk/python/docs/JobsetV1alpha2Coordinator.md @@ -1,13 +1,32 @@ # JobsetV1alpha2Coordinator Coordinator defines which pod can be marked as the coordinator for the JobSet workload. + ## Properties + Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **job_index** | **int** | JobIndex is the index of Job which contains the coordinator pod (i.e., for a ReplicatedJob with N replicas, there are Job indexes 0 to N-1). | [optional] **pod_index** | **int** | PodIndex is the Job completion index of the coordinator pod. | [optional] **replicated_job** | **str** | ReplicatedJob is the name of the ReplicatedJob which contains the coordinator pod. | [default to ''] +## Example + +```python +from jobset.models.jobset_v1alpha2_coordinator import JobsetV1alpha2Coordinator + +# TODO update the JSON string below +json = "{}" +# create an instance of JobsetV1alpha2Coordinator from a JSON string +jobset_v1alpha2_coordinator_instance = JobsetV1alpha2Coordinator.from_json(json) +# print the JSON string representation of the object +print(JobsetV1alpha2Coordinator.to_json()) + +# convert the object into a dict +jobset_v1alpha2_coordinator_dict = jobset_v1alpha2_coordinator_instance.to_dict() +# create an instance of JobsetV1alpha2Coordinator from a dict +jobset_v1alpha2_coordinator_from_dict = JobsetV1alpha2Coordinator.from_dict(jobset_v1alpha2_coordinator_dict) +``` [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/sdk/python/docs/JobsetV1alpha2FailurePolicy.md b/sdk/python/docs/JobsetV1alpha2FailurePolicy.md index e7b5a2d69..6af95c961 100644 --- a/sdk/python/docs/JobsetV1alpha2FailurePolicy.md +++ b/sdk/python/docs/JobsetV1alpha2FailurePolicy.md @@ -1,11 +1,30 @@ # JobsetV1alpha2FailurePolicy + ## Properties + Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **max_restarts** | **int** | MaxRestarts defines the limit on the number of JobSet restarts. A restart is achieved by recreating all active child jobs. | [optional] -**rules** | [**list[JobsetV1alpha2FailurePolicyRule]**](JobsetV1alpha2FailurePolicyRule.md) | List of failure policy rules for this JobSet. For a given Job failure, the rules will be evaluated in order, and only the first matching rule will be executed. If no matching rule is found, the RestartJobSet action is applied. | [optional] +**rules** | [**List[JobsetV1alpha2FailurePolicyRule]**](JobsetV1alpha2FailurePolicyRule.md) | List of failure policy rules for this JobSet. For a given Job failure, the rules will be evaluated in order, and only the first matching rule will be executed. If no matching rule is found, the RestartJobSet action is applied. | [optional] + +## Example + +```python +from jobset.models.jobset_v1alpha2_failure_policy import JobsetV1alpha2FailurePolicy + +# TODO update the JSON string below +json = "{}" +# create an instance of JobsetV1alpha2FailurePolicy from a JSON string +jobset_v1alpha2_failure_policy_instance = JobsetV1alpha2FailurePolicy.from_json(json) +# print the JSON string representation of the object +print(JobsetV1alpha2FailurePolicy.to_json()) +# convert the object into a dict +jobset_v1alpha2_failure_policy_dict = jobset_v1alpha2_failure_policy_instance.to_dict() +# create an instance of JobsetV1alpha2FailurePolicy from a dict +jobset_v1alpha2_failure_policy_from_dict = JobsetV1alpha2FailurePolicy.from_dict(jobset_v1alpha2_failure_policy_dict) +``` [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/sdk/python/docs/JobsetV1alpha2FailurePolicyRule.md b/sdk/python/docs/JobsetV1alpha2FailurePolicyRule.md index 3f7169a08..4665423ad 100644 --- a/sdk/python/docs/JobsetV1alpha2FailurePolicyRule.md +++ b/sdk/python/docs/JobsetV1alpha2FailurePolicyRule.md @@ -1,14 +1,33 @@ # JobsetV1alpha2FailurePolicyRule FailurePolicyRule defines a FailurePolicyAction to be executed if a child job fails due to a reason listed in OnJobFailureReasons. + ## Properties + Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **action** | **str** | The action to take if the rule is matched. | [default to ''] **name** | **str** | The name of the failure policy rule. The name is defaulted to 'failurePolicyRuleN' where N is the index of the failure policy rule. The name must match the regular expression \"^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$\". | [default to ''] -**on_job_failure_reasons** | **list[str]** | The requirement on the job failure reasons. The requirement is satisfied if at least one reason matches the list. The rules are evaluated in order, and the first matching rule is executed. An empty list applies the rule to any job failure reason. | [optional] -**target_replicated_jobs** | **list[str]** | TargetReplicatedJobs are the names of the replicated jobs the operator applies to. An empty list will apply to all replicatedJobs. | [optional] +**on_job_failure_reasons** | **List[str]** | The requirement on the job failure reasons. The requirement is satisfied if at least one reason matches the list. The rules are evaluated in order, and the first matching rule is executed. An empty list applies the rule to any job failure reason. | [optional] +**target_replicated_jobs** | **List[str]** | TargetReplicatedJobs are the names of the replicated jobs the operator applies to. An empty list will apply to all replicatedJobs. | [optional] + +## Example + +```python +from jobset.models.jobset_v1alpha2_failure_policy_rule import JobsetV1alpha2FailurePolicyRule + +# TODO update the JSON string below +json = "{}" +# create an instance of JobsetV1alpha2FailurePolicyRule from a JSON string +jobset_v1alpha2_failure_policy_rule_instance = JobsetV1alpha2FailurePolicyRule.from_json(json) +# print the JSON string representation of the object +print(JobsetV1alpha2FailurePolicyRule.to_json()) +# convert the object into a dict +jobset_v1alpha2_failure_policy_rule_dict = jobset_v1alpha2_failure_policy_rule_instance.to_dict() +# create an instance of JobsetV1alpha2FailurePolicyRule from a dict +jobset_v1alpha2_failure_policy_rule_from_dict = JobsetV1alpha2FailurePolicyRule.from_dict(jobset_v1alpha2_failure_policy_rule_dict) +``` [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/sdk/python/docs/JobsetV1alpha2JobSet.md b/sdk/python/docs/JobsetV1alpha2JobSet.md index 8669d1acb..c14178872 100644 --- a/sdk/python/docs/JobsetV1alpha2JobSet.md +++ b/sdk/python/docs/JobsetV1alpha2JobSet.md @@ -1,7 +1,9 @@ # JobsetV1alpha2JobSet JobSet is the Schema for the jobsets API + ## 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] @@ -10,6 +12,23 @@ Name | Type | Description | Notes **spec** | [**JobsetV1alpha2JobSetSpec**](JobsetV1alpha2JobSetSpec.md) | | [optional] **status** | [**JobsetV1alpha2JobSetStatus**](JobsetV1alpha2JobSetStatus.md) | | [optional] +## Example + +```python +from jobset.models.jobset_v1alpha2_job_set import JobsetV1alpha2JobSet + +# TODO update the JSON string below +json = "{}" +# create an instance of JobsetV1alpha2JobSet from a JSON string +jobset_v1alpha2_job_set_instance = JobsetV1alpha2JobSet.from_json(json) +# print the JSON string representation of the object +print(JobsetV1alpha2JobSet.to_json()) + +# convert the object into a dict +jobset_v1alpha2_job_set_dict = jobset_v1alpha2_job_set_instance.to_dict() +# create an instance of JobsetV1alpha2JobSet from a dict +jobset_v1alpha2_job_set_from_dict = JobsetV1alpha2JobSet.from_dict(jobset_v1alpha2_job_set_dict) +``` [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/sdk/python/docs/JobsetV1alpha2JobSetList.md b/sdk/python/docs/JobsetV1alpha2JobSetList.md index 9073b4571..c2025ccb1 100644 --- a/sdk/python/docs/JobsetV1alpha2JobSetList.md +++ b/sdk/python/docs/JobsetV1alpha2JobSetList.md @@ -1,14 +1,33 @@ # JobsetV1alpha2JobSetList JobSetList contains a list of JobSet + ## 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[JobsetV1alpha2JobSet]**](JobsetV1alpha2JobSet.md) | | +**items** | [**List[JobsetV1alpha2JobSet]**](JobsetV1alpha2JobSet.md) | | **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] +## Example + +```python +from jobset.models.jobset_v1alpha2_job_set_list import JobsetV1alpha2JobSetList + +# TODO update the JSON string below +json = "{}" +# create an instance of JobsetV1alpha2JobSetList from a JSON string +jobset_v1alpha2_job_set_list_instance = JobsetV1alpha2JobSetList.from_json(json) +# print the JSON string representation of the object +print(JobsetV1alpha2JobSetList.to_json()) + +# convert the object into a dict +jobset_v1alpha2_job_set_list_dict = jobset_v1alpha2_job_set_list_instance.to_dict() +# create an instance of JobsetV1alpha2JobSetList from a dict +jobset_v1alpha2_job_set_list_from_dict = JobsetV1alpha2JobSetList.from_dict(jobset_v1alpha2_job_set_list_dict) +``` [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/sdk/python/docs/JobsetV1alpha2JobSetSpec.md b/sdk/python/docs/JobsetV1alpha2JobSetSpec.md index 70e46a057..b568e3456 100644 --- a/sdk/python/docs/JobsetV1alpha2JobSetSpec.md +++ b/sdk/python/docs/JobsetV1alpha2JobSetSpec.md @@ -1,19 +1,38 @@ # JobsetV1alpha2JobSetSpec JobSetSpec defines the desired state of JobSet + ## Properties + Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **coordinator** | [**JobsetV1alpha2Coordinator**](JobsetV1alpha2Coordinator.md) | | [optional] **failure_policy** | [**JobsetV1alpha2FailurePolicy**](JobsetV1alpha2FailurePolicy.md) | | [optional] **managed_by** | **str** | ManagedBy is used to indicate the controller or entity that manages a JobSet. The built-in JobSet controller reconciles JobSets which don't have this field at all or the field value is the reserved string `jobset.sigs.k8s.io/jobset-controller`, but skips reconciling JobSets with a custom value for this field. The value must be a valid domain-prefixed path (e.g. acme.io/foo) - all characters before the first \"/\" must be a valid subdomain as defined by RFC 1123. All characters trailing the first \"/\" must be valid HTTP Path characters as defined by RFC 3986. The value cannot exceed 63 characters. The field is immutable. | [optional] **network** | [**JobsetV1alpha2Network**](JobsetV1alpha2Network.md) | | [optional] -**replicated_jobs** | [**list[JobsetV1alpha2ReplicatedJob]**](JobsetV1alpha2ReplicatedJob.md) | ReplicatedJobs is the group of jobs that will form the set. | [optional] +**replicated_jobs** | [**List[JobsetV1alpha2ReplicatedJob]**](JobsetV1alpha2ReplicatedJob.md) | ReplicatedJobs is the group of jobs that will form the set. | [optional] **startup_policy** | [**JobsetV1alpha2StartupPolicy**](JobsetV1alpha2StartupPolicy.md) | | [optional] **success_policy** | [**JobsetV1alpha2SuccessPolicy**](JobsetV1alpha2SuccessPolicy.md) | | [optional] **suspend** | **bool** | Suspend suspends all running child Jobs when set to true. | [optional] **ttl_seconds_after_finished** | **int** | TTLSecondsAfterFinished limits the lifetime of a JobSet that has finished execution (either Complete or Failed). If this field is set, TTLSecondsAfterFinished after the JobSet finishes, it is eligible to be automatically deleted. When the JobSet is being deleted, its lifecycle guarantees (e.g. finalizers) will be honored. If this field is unset, the JobSet won't be automatically deleted. If this field is set to zero, the JobSet becomes eligible to be deleted immediately after it finishes. | [optional] +## Example + +```python +from jobset.models.jobset_v1alpha2_job_set_spec import JobsetV1alpha2JobSetSpec + +# TODO update the JSON string below +json = "{}" +# create an instance of JobsetV1alpha2JobSetSpec from a JSON string +jobset_v1alpha2_job_set_spec_instance = JobsetV1alpha2JobSetSpec.from_json(json) +# print the JSON string representation of the object +print(JobsetV1alpha2JobSetSpec.to_json()) + +# convert the object into a dict +jobset_v1alpha2_job_set_spec_dict = jobset_v1alpha2_job_set_spec_instance.to_dict() +# create an instance of JobsetV1alpha2JobSetSpec from a dict +jobset_v1alpha2_job_set_spec_from_dict = JobsetV1alpha2JobSetSpec.from_dict(jobset_v1alpha2_job_set_spec_dict) +``` [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/sdk/python/docs/JobsetV1alpha2JobSetStatus.md b/sdk/python/docs/JobsetV1alpha2JobSetStatus.md index f85bde4e4..a6d042367 100644 --- a/sdk/python/docs/JobsetV1alpha2JobSetStatus.md +++ b/sdk/python/docs/JobsetV1alpha2JobSetStatus.md @@ -1,15 +1,34 @@ # JobsetV1alpha2JobSetStatus JobSetStatus defines the observed state of JobSet + ## Properties + Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**conditions** | [**list[V1Condition]**](V1Condition.md) | | [optional] -**replicated_jobs_status** | [**list[JobsetV1alpha2ReplicatedJobStatus]**](JobsetV1alpha2ReplicatedJobStatus.md) | ReplicatedJobsStatus track the number of JobsReady for each replicatedJob. | [optional] +**conditions** | [**List[V1Condition]**](V1Condition.md) | | [optional] +**replicated_jobs_status** | [**List[JobsetV1alpha2ReplicatedJobStatus]**](JobsetV1alpha2ReplicatedJobStatus.md) | ReplicatedJobsStatus track the number of JobsReady for each replicatedJob. | [optional] **restarts** | **int** | Restarts tracks the number of times the JobSet has restarted (i.e. recreated in case of RecreateAll policy). | [optional] **restarts_count_towards_max** | **int** | RestartsCountTowardsMax tracks the number of times the JobSet has restarted that counts towards the maximum allowed number of restarts. | [optional] **terminal_state** | **str** | TerminalState the state of the JobSet when it finishes execution. It can be either Complete or Failed. Otherwise, it is empty by default. | [optional] +## Example + +```python +from jobset.models.jobset_v1alpha2_job_set_status import JobsetV1alpha2JobSetStatus + +# TODO update the JSON string below +json = "{}" +# create an instance of JobsetV1alpha2JobSetStatus from a JSON string +jobset_v1alpha2_job_set_status_instance = JobsetV1alpha2JobSetStatus.from_json(json) +# print the JSON string representation of the object +print(JobsetV1alpha2JobSetStatus.to_json()) + +# convert the object into a dict +jobset_v1alpha2_job_set_status_dict = jobset_v1alpha2_job_set_status_instance.to_dict() +# create an instance of JobsetV1alpha2JobSetStatus from a dict +jobset_v1alpha2_job_set_status_from_dict = JobsetV1alpha2JobSetStatus.from_dict(jobset_v1alpha2_job_set_status_dict) +``` [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/sdk/python/docs/JobsetV1alpha2Network.md b/sdk/python/docs/JobsetV1alpha2Network.md index 32cd4fb11..7ccb4822c 100644 --- a/sdk/python/docs/JobsetV1alpha2Network.md +++ b/sdk/python/docs/JobsetV1alpha2Network.md @@ -1,12 +1,31 @@ # JobsetV1alpha2Network + ## Properties + Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **enable_dns_hostnames** | **bool** | EnableDNSHostnames allows pods to be reached via their hostnames. Pods will be reachable using the fully qualified pod hostname: <jobSet.name>-<spec.replicatedJob.name>-<job-index>-<pod-index>.<subdomain> | [optional] **publish_not_ready_addresses** | **bool** | Indicates if DNS records of pods should be published before the pods are ready. Defaults to True. | [optional] **subdomain** | **str** | Subdomain is an explicit choice for a network subdomain name When set, any replicated job in the set is added to this network. Defaults to <jobSet.name> if not set. | [optional] +## Example + +```python +from jobset.models.jobset_v1alpha2_network import JobsetV1alpha2Network + +# TODO update the JSON string below +json = "{}" +# create an instance of JobsetV1alpha2Network from a JSON string +jobset_v1alpha2_network_instance = JobsetV1alpha2Network.from_json(json) +# print the JSON string representation of the object +print(JobsetV1alpha2Network.to_json()) + +# convert the object into a dict +jobset_v1alpha2_network_dict = jobset_v1alpha2_network_instance.to_dict() +# create an instance of JobsetV1alpha2Network from a dict +jobset_v1alpha2_network_from_dict = JobsetV1alpha2Network.from_dict(jobset_v1alpha2_network_dict) +``` [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/sdk/python/docs/JobsetV1alpha2ReplicatedJob.md b/sdk/python/docs/JobsetV1alpha2ReplicatedJob.md index 780d9e0b1..860e36a87 100644 --- a/sdk/python/docs/JobsetV1alpha2ReplicatedJob.md +++ b/sdk/python/docs/JobsetV1alpha2ReplicatedJob.md @@ -1,12 +1,31 @@ # JobsetV1alpha2ReplicatedJob + ## Properties + Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **name** | **str** | Name is the name of the entry and will be used as a suffix for the Job name. | [default to ''] **replicas** | **int** | Replicas is the number of jobs that will be created from this ReplicatedJob's template. Jobs names will be in the format: <jobSet.name>-<spec.replicatedJob.name>-<job-index> | [optional] **template** | [**V1JobTemplateSpec**](V1JobTemplateSpec.md) | | +## Example + +```python +from jobset.models.jobset_v1alpha2_replicated_job import JobsetV1alpha2ReplicatedJob + +# TODO update the JSON string below +json = "{}" +# create an instance of JobsetV1alpha2ReplicatedJob from a JSON string +jobset_v1alpha2_replicated_job_instance = JobsetV1alpha2ReplicatedJob.from_json(json) +# print the JSON string representation of the object +print(JobsetV1alpha2ReplicatedJob.to_json()) + +# convert the object into a dict +jobset_v1alpha2_replicated_job_dict = jobset_v1alpha2_replicated_job_instance.to_dict() +# create an instance of JobsetV1alpha2ReplicatedJob from a dict +jobset_v1alpha2_replicated_job_from_dict = JobsetV1alpha2ReplicatedJob.from_dict(jobset_v1alpha2_replicated_job_dict) +``` [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/sdk/python/docs/JobsetV1alpha2ReplicatedJobStatus.md b/sdk/python/docs/JobsetV1alpha2ReplicatedJobStatus.md index 09e1dea46..02abbc3e6 100644 --- a/sdk/python/docs/JobsetV1alpha2ReplicatedJobStatus.md +++ b/sdk/python/docs/JobsetV1alpha2ReplicatedJobStatus.md @@ -1,7 +1,9 @@ # JobsetV1alpha2ReplicatedJobStatus ReplicatedJobStatus defines the observed ReplicatedJobs Readiness. + ## 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] @@ -11,6 +13,23 @@ Name | Type | Description | Notes **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] +## Example + +```python +from jobset.models.jobset_v1alpha2_replicated_job_status import JobsetV1alpha2ReplicatedJobStatus + +# TODO update the JSON string below +json = "{}" +# create an instance of JobsetV1alpha2ReplicatedJobStatus from a JSON string +jobset_v1alpha2_replicated_job_status_instance = JobsetV1alpha2ReplicatedJobStatus.from_json(json) +# print the JSON string representation of the object +print(JobsetV1alpha2ReplicatedJobStatus.to_json()) + +# convert the object into a dict +jobset_v1alpha2_replicated_job_status_dict = jobset_v1alpha2_replicated_job_status_instance.to_dict() +# create an instance of JobsetV1alpha2ReplicatedJobStatus from a dict +jobset_v1alpha2_replicated_job_status_from_dict = JobsetV1alpha2ReplicatedJobStatus.from_dict(jobset_v1alpha2_replicated_job_status_dict) +``` [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/sdk/python/docs/JobsetV1alpha2StartupPolicy.md b/sdk/python/docs/JobsetV1alpha2StartupPolicy.md index 58bab97da..32d3eaf13 100644 --- a/sdk/python/docs/JobsetV1alpha2StartupPolicy.md +++ b/sdk/python/docs/JobsetV1alpha2StartupPolicy.md @@ -1,10 +1,29 @@ # JobsetV1alpha2StartupPolicy + ## Properties + Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **startup_policy_order** | **str** | StartupPolicyOrder determines the startup order of the ReplicatedJobs. AnyOrder means to start replicated jobs in any order. InOrder means to start them as they are listed in the JobSet. A ReplicatedJob is started only when all the jobs of the previous one are ready. | [default to ''] +## Example + +```python +from jobset.models.jobset_v1alpha2_startup_policy import JobsetV1alpha2StartupPolicy + +# TODO update the JSON string below +json = "{}" +# create an instance of JobsetV1alpha2StartupPolicy from a JSON string +jobset_v1alpha2_startup_policy_instance = JobsetV1alpha2StartupPolicy.from_json(json) +# print the JSON string representation of the object +print(JobsetV1alpha2StartupPolicy.to_json()) + +# convert the object into a dict +jobset_v1alpha2_startup_policy_dict = jobset_v1alpha2_startup_policy_instance.to_dict() +# create an instance of JobsetV1alpha2StartupPolicy from a dict +jobset_v1alpha2_startup_policy_from_dict = JobsetV1alpha2StartupPolicy.from_dict(jobset_v1alpha2_startup_policy_dict) +``` [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/sdk/python/docs/JobsetV1alpha2SuccessPolicy.md b/sdk/python/docs/JobsetV1alpha2SuccessPolicy.md index a1b34da12..ecfb7c868 100644 --- a/sdk/python/docs/JobsetV1alpha2SuccessPolicy.md +++ b/sdk/python/docs/JobsetV1alpha2SuccessPolicy.md @@ -1,11 +1,30 @@ # JobsetV1alpha2SuccessPolicy + ## Properties + Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **operator** | **str** | Operator determines either All or Any of the selected jobs should succeed to consider the JobSet successful | [default to ''] -**target_replicated_jobs** | **list[str]** | TargetReplicatedJobs are the names of the replicated jobs the operator will apply to. A null or empty list will apply to all replicatedJobs. | [optional] +**target_replicated_jobs** | **List[str]** | TargetReplicatedJobs are the names of the replicated jobs the operator will apply to. A null or empty list will apply to all replicatedJobs. | [optional] + +## Example + +```python +from jobset.models.jobset_v1alpha2_success_policy import JobsetV1alpha2SuccessPolicy + +# TODO update the JSON string below +json = "{}" +# create an instance of JobsetV1alpha2SuccessPolicy from a JSON string +jobset_v1alpha2_success_policy_instance = JobsetV1alpha2SuccessPolicy.from_json(json) +# print the JSON string representation of the object +print(JobsetV1alpha2SuccessPolicy.to_json()) +# convert the object into a dict +jobset_v1alpha2_success_policy_dict = jobset_v1alpha2_success_policy_instance.to_dict() +# create an instance of JobsetV1alpha2SuccessPolicy from a dict +jobset_v1alpha2_success_policy_from_dict = JobsetV1alpha2SuccessPolicy.from_dict(jobset_v1alpha2_success_policy_dict) +``` [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/sdk/python/git_push.sh b/sdk/python/git_push.sh index ced3be2b0..f53a75d4f 100644 --- a/sdk/python/git_push.sh +++ b/sdk/python/git_push.sh @@ -1,7 +1,7 @@ #!/bin/sh # ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ # -# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com" +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" git_user_id=$1 git_repo_id=$2 @@ -38,14 +38,14 @@ git add . git commit -m "$release_note" # Sets the new remote -git_remote=`git remote` +git_remote=$(git remote) if [ "$git_remote" = "" ]; then # git remote not defined if [ "$GIT_TOKEN" = "" ]; then echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git else - git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git + git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git fi fi @@ -55,4 +55,3 @@ git pull origin master # Pushes (Forces) the changes in the local repository up to the remote repository echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" git push origin master 2>&1 | grep -v 'To https' - diff --git a/sdk/python/jobset/__init__.py b/sdk/python/jobset/__init__.py index 1bd1f4f35..479be3a8a 100644 --- a/sdk/python/jobset/__init__.py +++ b/sdk/python/jobset/__init__.py @@ -5,27 +5,30 @@ """ JobSet SDK - Python SDK for the JobSet API # noqa: E501 + Python SDK for the JobSet API The version of the OpenAPI document: v0.1.4 - Generated by: https://openapi-generator.tech -""" + Generated by OpenAPI Generator (https://openapi-generator.tech) + Do not edit the class manually. +""" # noqa: E501 -from __future__ import absolute_import __version__ = "0.1.4" # import apis into sdk package # import ApiClient +from jobset.api_response import ApiResponse from jobset.api_client import ApiClient from jobset.configuration import Configuration from jobset.exceptions import OpenApiException from jobset.exceptions import ApiTypeError from jobset.exceptions import ApiValueError from jobset.exceptions import ApiKeyError +from jobset.exceptions import ApiAttributeError from jobset.exceptions import ApiException + # import models into sdk package from jobset.models.jobset_v1alpha2_coordinator import JobsetV1alpha2Coordinator from jobset.models.jobset_v1alpha2_failure_policy import JobsetV1alpha2FailurePolicy @@ -39,4 +42,3 @@ from jobset.models.jobset_v1alpha2_replicated_job_status import JobsetV1alpha2ReplicatedJobStatus from jobset.models.jobset_v1alpha2_startup_policy import JobsetV1alpha2StartupPolicy from jobset.models.jobset_v1alpha2_success_policy import JobsetV1alpha2SuccessPolicy - diff --git a/sdk/python/jobset/api/__init__.py b/sdk/python/jobset/api/__init__.py index 36dce7fe2..c3bb408f1 100644 --- a/sdk/python/jobset/api/__init__.py +++ b/sdk/python/jobset/api/__init__.py @@ -1,5 +1,4 @@ -from __future__ import absolute_import - # flake8: noqa # import apis into api package + diff --git a/sdk/python/jobset/api_client.py b/sdk/python/jobset/api_client.py index ca5ba1df4..c8ab70fc6 100644 --- a/sdk/python/jobset/api_client.py +++ b/sdk/python/jobset/api_client.py @@ -1,36 +1,48 @@ # coding: utf-8 + """ JobSet SDK - Python SDK for the JobSet API # noqa: E501 + Python SDK for the JobSet API The version of the OpenAPI document: v0.1.4 - Generated by: https://openapi-generator.tech -""" + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 -from __future__ import absolute_import -import atexit import datetime from dateutil.parser import parse +from enum import Enum +import decimal 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 urllib.parse import quote +from typing import Tuple, Optional, List, Dict, Union +from pydantic import SecretStr from jobset.configuration import Configuration +from jobset.api_response import ApiResponse, T as ApiResponseT import jobset.models from jobset import rest -from jobset.exceptions import ApiValueError, ApiException - - -class ApiClient(object): +from jobset.exceptions import ( + ApiValueError, + ApiException, + BadRequestException, + UnauthorizedException, + ForbiddenException, + NotFoundException, + ServiceException +) + +RequestSerialized = Tuple[str, str, Dict[str, str], Optional[str], List[str]] + +class ApiClient: """Generic API client for OpenAPI client library builds. OpenAPI generic API client. This client handles the client- @@ -38,39 +50,39 @@ class ApiClient(object): 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 + PRIMITIVE_TYPES = (float, bool, bytes, str, int) NATIVE_TYPES_MAPPING = { 'int': int, - 'long': int if six.PY3 else long, # noqa: F821 + 'long': int, # TODO remove as only py3 is supported? 'float': float, 'str': str, 'bool': bool, 'date': datetime.date, 'datetime': datetime.datetime, + 'decimal': decimal.Decimal, 'object': object, } _pool = None - def __init__(self, configuration=None, header_name=None, header_value=None, - cookie=None, pool_threads=1): + def __init__( + self, + configuration=None, + header_name=None, + header_value=None, + cookie=None + ) -> None: + # use default configuration if none is provided if configuration is None: - configuration = Configuration.get_default_copy() + configuration = Configuration.get_default() self.configuration = configuration - self.pool_threads = pool_threads self.rest_client = rest.RESTClientObject(configuration) self.default_headers = {} @@ -85,25 +97,7 @@ 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 + pass @property def user_agent(self): @@ -117,12 +111,69 @@ def user_agent(self, 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): + + _default = None + + @classmethod + def get_default(cls): + """Return new instance of ApiClient. + + This method returns newly created, based on default constructor, + object of ApiClient class or returns a copy of default + ApiClient. + + :return: The ApiClient object. + """ + if cls._default is None: + cls._default = ApiClient() + return cls._default + + @classmethod + def set_default(cls, default): + """Set default instance of ApiClient. + + It stores default ApiClient. + + :param default: object of ApiClient. + """ + cls._default = default + + def param_serialize( + self, + method, + resource_path, + path_params=None, + query_params=None, + header_params=None, + body=None, + post_params=None, + files=None, auth_settings=None, + collection_formats=None, + _host=None, + _request_auth=None + ) -> RequestSerialized: + + """Builds the HTTP request params needed by the request. + :param method: Method to call. + :param resource_path: Path to method endpoint. + :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 files dict: key -> filename, value -> filepath, + for `multipart/form-data`. + :param collection_formats: dict of collection formats for path, query, + header, and post parameters. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :return: tuple of form (path, http_method, query_params, header_params, + body, post_params, files) + """ config = self.configuration @@ -133,14 +184,17 @@ def __call_api( 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)) + 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) + 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( @@ -148,80 +202,145 @@ def __call_api( 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)) + post_params = self.parameters_to_tuples( + post_params, + collection_formats + ) + if files: + post_params.extend(self.files_parameters(files)) # auth setting - self.update_params_for_auth(header_params, query_params, auth_settings) + self.update_params_for_auth( + header_params, + query_params, + auth_settings, + resource_path, + method, + body, + request_auth=_request_auth + ) # body if body: body = self.sanitize_for_serialization(body) # request url - if _host is None: + if _host is None or self.configuration.ignore_operation_servers: url = self.configuration.host + resource_path else: # use server/host defined in path or operation instead url = _host + resource_path + # query parameters + if query_params: + query_params = self.sanitize_for_serialization(query_params) + url_query = self.parameters_to_url_query( + query_params, + collection_formats + ) + url += "?" + url_query + + return method, url, header_params, body, post_params + + + def call_api( + self, + method, + url, + header_params=None, + body=None, + post_params=None, + _request_timeout=None + ) -> rest.RESTResponse: + """Makes the HTTP request (synchronous) + :param method: Method to call. + :param url: Path to method endpoint. + :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 _request_timeout: timeout setting for this request. + :return: RESTResponse + """ + 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) + response_data = self.rest_client.request( + method, url, + headers=header_params, + body=body, post_params=post_params, + _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') + return response_data - self.last_response = response_data - - return_data = response_data + def response_deserialize( + self, + response_data: rest.RESTResponse, + response_types_map: Optional[Dict[str, ApiResponseT]]=None + ) -> ApiResponse[ApiResponseT]: + """Deserializes response into an object. + :param response_data: RESTResponse object to be deserialized. + :param response_types_map: dict of response types. + :return: ApiResponse + """ - if not _preload_content: - return return_data + msg = "RESTResponse.read() must be called before passing it to response_deserialize()" + assert response_data.data is not None, msg - 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) + response_type = response_types_map.get(str(response_data.status), None) + if not response_type and isinstance(response_data.status, int) and 100 <= response_data.status <= 599: + # if not found, look for '1XX', '2XX', etc. + response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) # deserialize response data - if response_type: - return_data = self.deserialize(response_data, response_type) - else: - return_data = None + response_text = None + return_data = None + try: + if response_type == "bytearray": + return_data = response_data.data + elif response_type == "file": + return_data = self.__deserialize_file(response_data) + elif response_type is not None: + match = None + content_type = response_data.getheader('content-type') + 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_text = response_data.data.decode(encoding) + return_data = self.deserialize(response_text, response_type, content_type) + finally: + if not 200 <= response_data.status <= 299: + raise ApiException.from_response( + http_resp=response_data, + body=response_text, + data=return_data, + ) - if _return_http_data_only: - return (return_data) - else: - return (return_data, response_data.status, - response_data.getheaders()) + return ApiResponse( + status_code = response_data.status, + data = return_data, + headers = response_data.getheaders(), + raw_data = response_data.data + ) def sanitize_for_serialization(self, obj): """Builds a JSON POST object. If obj is None, return None. + If obj is SecretStr, return obj.get_secret_value() 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 decimal.Decimal return string representation. 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. @@ -231,18 +350,26 @@ def sanitize_for_serialization(self, obj): """ if obj is None: return None + elif isinstance(obj, Enum): + return obj.value + elif isinstance(obj, SecretStr): + return obj.get_secret_value() elif isinstance(obj, self.PRIMITIVE_TYPES): return obj elif isinstance(obj, list): - return [self.sanitize_for_serialization(sub_obj) - for sub_obj in obj] + return [ + self.sanitize_for_serialization(sub_obj) for sub_obj in obj + ] elif isinstance(obj, tuple): - return tuple(self.sanitize_for_serialization(sub_obj) - for sub_obj in obj) + return tuple( + self.sanitize_for_serialization(sub_obj) for sub_obj in obj + ) elif isinstance(obj, (datetime.datetime, datetime.date)): return obj.isoformat() + elif isinstance(obj, decimal.Decimal): + return str(obj) - if isinstance(obj, dict): + elif isinstance(obj, dict): obj_dict = obj else: # Convert model obj to dict except @@ -250,32 +377,45 @@ def sanitize_for_serialization(self, obj): # 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} + if hasattr(obj, 'to_dict') and callable(getattr(obj, 'to_dict')): + obj_dict = obj.to_dict() + else: + obj_dict = obj.__dict__ - return {key: self.sanitize_for_serialization(val) - for key, val in six.iteritems(obj_dict)} + return { + key: self.sanitize_for_serialization(val) + for key, val in obj_dict.items() + } - def deserialize(self, response, response_type): + def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): """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. + :param content_type: content type of response. :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 + if content_type is None: + try: + data = json.loads(response_text) + except ValueError: + data = response_text + elif re.match(r'^application/(json|[\w!#$&.+-^_]+\+json)\s*(;|$)', content_type, re.IGNORECASE): + if response_text == "": + data = "" + else: + data = json.loads(response_text) + elif re.match(r'^text/plain\s*(;|$)', content_type, re.IGNORECASE): + data = response_text + else: + raise ApiException( + status=0, + reason="Unsupported content type: {0}".format(content_type) + ) return self.__deserialize(data, response_type) @@ -290,16 +430,20 @@ def __deserialize(self, data, klass): if data is None: return None - if type(klass) == str: - if klass.startswith('list['): - sub_kls = re.match(r'list\[(.*)\]', klass).group(1) + if isinstance(klass, str): + if klass.startswith('List['): + m = re.match(r'List\[(.*)]', klass) + assert m is not None, "Malformed List type definition" + sub_kls = m.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) + if klass.startswith('Dict['): + m = re.match(r'Dict\[([^,]*), (.*)]', klass) + assert m is not None, "Malformed Dict type definition" + sub_kls = m.group(2) return {k: self.__deserialize(v, sub_kls) - for k, v in six.iteritems(data)} + for k, v in data.items()} # convert str to class if klass in self.NATIVE_TYPES_MAPPING: @@ -315,131 +459,13 @@ def __deserialize(self, data, klass): return self.__deserialize_date(data) elif klass == datetime.datetime: return self.__deserialize_datetime(data) + elif klass == decimal.Decimal: + return decimal.Decimal(data) + elif issubclass(klass, Enum): + return self.__deserialize_enum(data, klass) 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. @@ -447,10 +473,10 @@ def parameters_to_tuples(self, params, collection_formats): :param dict collection_formats: Parameter collection formats :return: Parameters as list of tuples, collections formatted """ - new_params = [] + new_params: List[Tuple[str, str]] = [] if collection_formats is None: collection_formats = {} - for k, v in six.iteritems(params) if isinstance(params, dict) else params: # noqa: E501 + for k, v in params.items() if isinstance(params, dict) else params: if k in collection_formats: collection_format = collection_formats[k] if collection_format == 'multi': @@ -470,45 +496,94 @@ def parameters_to_tuples(self, params, collection_formats): new_params.append((k, v)) return new_params - def files_parameters(self, files=None): + def parameters_to_url_query(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: URL query string (e.g. a=Hello%20World&b=123) + """ + new_params: List[Tuple[str, str]] = [] + if collection_formats is None: + collection_formats = {} + for k, v in params.items() if isinstance(params, dict) else params: + if isinstance(v, bool): + v = str(v).lower() + if isinstance(v, (int, float)): + v = str(v) + if isinstance(v, dict): + v = json.dumps(v) + + if k in collection_formats: + collection_format = collection_formats[k] + if collection_format == 'multi': + new_params.extend((k, str(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(quote(str(value)) for value in v)) + ) + else: + new_params.append((k, quote(str(v)))) + + return "&".join(["=".join(map(str, item)) for item in new_params]) + + def files_parameters( + self, + files: Dict[str, Union[str, bytes, List[str], List[bytes], Tuple[str, bytes]]], + ): """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])])) - + for k, v in files.items(): + if isinstance(v, str): + with open(v, 'rb') as f: + filename = os.path.basename(f.name) + filedata = f.read() + elif isinstance(v, bytes): + filename = k + filedata = v + elif isinstance(v, tuple): + filename, filedata = v + elif isinstance(v, list): + for file_param in v: + params.extend(self.files_parameters({k: file_param})) + continue + else: + raise ValueError("Unsupported file value") + mimetype = ( + mimetypes.guess_type(filename)[0] + or 'application/octet-stream' + ) + params.append( + tuple([k, tuple([filename, filedata, mimetype])]) + ) return params - def select_header_accept(self, accepts): + def select_header_accept(self, accepts: List[str]) -> Optional[str]: """Returns `Accept` based on an array of accepts provided. :param accepts: List of headers. :return: Accept (e.g. application/json). """ if not accepts: - return + return None - accepts = [x.lower() for x in accepts] + for accept in accepts: + if re.search('json', accept, re.IGNORECASE): + return accept - if 'application/json' in accepts: - return 'application/json' - else: - return ', '.join(accepts) + return accepts[0] def select_header_content_type(self, content_types): """Returns `Content-Type` based on an array of content_types provided. @@ -517,45 +592,101 @@ def select_header_content_type(self, 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] + return None - def update_params_for_auth(self, headers, querys, auth_settings): + for content_type in content_types: + if re.search('json', content_type, re.IGNORECASE): + return content_type + + return content_types[0] + + def update_params_for_auth( + self, + headers, + queries, + auth_settings, + resource_path, + method, + body, + request_auth=None + ) -> None: """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 queries: Query parameters tuple list to be updated. :param auth_settings: Authentication setting identifiers list. + :resource_path: A string representation of the HTTP request resource path. + :method: A string representation of the HTTP request method. + :body: A object representing the body of the HTTP request. + The object type is the return value of sanitize_for_serialization(). + :param request_auth: if set, the provided settings will + override the token in the configuration. """ 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`' + if request_auth: + self._apply_auth_params( + headers, + queries, + resource_path, + method, + body, + request_auth + ) + else: + for auth in auth_settings: + auth_setting = self.configuration.auth_settings().get(auth) + if auth_setting: + self._apply_auth_params( + headers, + queries, + resource_path, + method, + body, + auth_setting ) + def _apply_auth_params( + self, + headers, + queries, + resource_path, + method, + body, + auth_setting + ) -> None: + """Updates the request parameters based on a single auth_setting + + :param headers: Header parameters dict to be updated. + :param queries: Query parameters tuple list to be updated. + :resource_path: A string representation of the HTTP request resource path. + :method: A string representation of the HTTP request method. + :body: A object representing the body of the HTTP request. + The object type is the return value of sanitize_for_serialization(). + :param auth_setting: auth settings for the endpoint + """ + if auth_setting['in'] == 'cookie': + headers['Cookie'] = auth_setting['value'] + elif auth_setting['in'] == 'header': + if auth_setting['type'] != 'http-signature': + headers[auth_setting['key']] = auth_setting['value'] + elif auth_setting['in'] == 'query': + queries.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. + handle file downloading + save response body into a tmp file and return the instance + :param response: RESTResponse. :return: file path. """ @@ -565,8 +696,12 @@ def __deserialize_file(self, response): content_disposition = response.getheader("Content-Disposition") if content_disposition: - filename = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', - content_disposition).group(1) + m = re.search( + r'filename=[\'"]?([^\'"\s]+)[\'"]?', + content_disposition + ) + assert m is not None, "Unexpected 'content-disposition' header value" + filename = m.group(1) path = os.path.join(os.path.dirname(path), filename) with open(path, "wb") as f: @@ -585,7 +720,7 @@ def __deserialize_primitive(self, data, klass): try: return klass(data) except UnicodeEncodeError: - return six.text_type(data) + return str(data) except TypeError: return data @@ -633,6 +768,24 @@ def __deserialize_datetime(self, string): ) ) + def __deserialize_enum(self, data, klass): + """Deserializes primitive type to enum. + + :param data: primitive type. + :param klass: class literal. + :return: enum value. + """ + try: + return klass(data) + except ValueError: + raise rest.ApiException( + status=0, + reason=( + "Failed to parse `{0}` as `{1}`" + .format(data, klass) + ) + ) + def __deserialize_model(self, data, klass): """Deserializes list or dict to model. @@ -640,27 +793,5 @@ def __deserialize_model(self, data, klass): :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 + return klass.from_dict(data) diff --git a/sdk/python/jobset/api_response.py b/sdk/python/jobset/api_response.py new file mode 100644 index 000000000..9bc7c11f6 --- /dev/null +++ b/sdk/python/jobset/api_response.py @@ -0,0 +1,21 @@ +"""API response object.""" + +from __future__ import annotations +from typing import Optional, Generic, Mapping, TypeVar +from pydantic import Field, StrictInt, StrictBytes, BaseModel + +T = TypeVar("T") + +class ApiResponse(BaseModel, Generic[T]): + """ + API response object + """ + + status_code: StrictInt = Field(description="HTTP status code") + headers: Optional[Mapping[str, str]] = Field(None, description="HTTP headers") + data: T = Field(description="Deserialized data given the data type") + raw_data: StrictBytes = Field(description="Raw data (HTTP response body)") + + model_config = { + "arbitrary_types_allowed": True + } diff --git a/sdk/python/jobset/configuration.py b/sdk/python/jobset/configuration.py index 75920b63d..6c9802fb6 100644 --- a/sdk/python/jobset/configuration.py +++ b/sdk/python/jobset/configuration.py @@ -3,67 +3,94 @@ """ JobSet SDK - Python SDK for the JobSet API # noqa: E501 + Python SDK for the JobSet API The version of the OpenAPI document: v0.1.4 - Generated by: https://openapi-generator.tech -""" + Generated by OpenAPI Generator (https://openapi-generator.tech) + Do not edit the class manually. +""" # noqa: E501 -from __future__ import absolute_import import copy import logging +from logging import FileHandler import multiprocessing import sys +from typing import Optional import urllib3 -import six -from six.moves import http_client as httplib +import http.client as httplib +JSON_SCHEMA_VALIDATION_KEYWORDS = { + 'multipleOf', 'maximum', 'exclusiveMaximum', + 'minimum', 'exclusiveMinimum', 'maxLength', + 'minLength', 'pattern', 'maxItems', 'minItems' +} -class Configuration(object): - """NOTE: This class is auto generated by OpenAPI Generator - - Ref: https://openapi-generator.tech - Do not edit the class manually. +class Configuration: + """This class contains various settings of the API client. - :param host: Base url + :param host: Base url. + :param ignore_operation_servers + Boolean to ignore operation servers for the API client. + Config will use `host` as the base url regardless of the operation servers. :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) + :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. + :param username: Username for HTTP basic authentication. + :param password: Password for HTTP basic authentication. + :param access_token: Access token. + :param server_index: Index to servers configuration. + :param server_variables: Mapping with string values to replace variables in + templated server configuration. The validation of enums is performed for + variables with defined enum values before. + :param server_operation_index: Mapping from operation ID to an index to server + configuration. + :param server_operation_variables: Mapping from operation ID to a mapping with + string values to replace variables in templated server configuration. + The validation of enums is performed for variables with defined enum + values before. + :param ssl_ca_cert: str - the path to a file of concatenated CA certificates + in PEM format. + :param retries: Number of retries for API requests. """ _default = None - def __init__(self, host="http://localhost", + def __init__(self, host=None, api_key=None, api_key_prefix=None, username=None, password=None, - discard_unknown_keys=False, - ): + access_token=None, + server_index=None, server_variables=None, + server_operation_index=None, server_operation_variables=None, + ignore_operation_servers=False, + ssl_ca_cert=None, + retries=None, + *, + debug: Optional[bool] = None + ) -> None: """Constructor """ - self.host = host + self._base_path = "http://localhost" if host is None else host """Default Base url """ + self.server_index = 0 if server_index is None and host is None else server_index + self.server_operation_index = server_operation_index or {} + """Default server index + """ + self.server_variables = server_variables or {} + self.server_operation_variables = server_operation_variables or {} + """Default server variables + """ + self.ignore_operation_servers = ignore_operation_servers + """Ignore operation servers + """ self.temp_folder_path = None """Temp file folder for downloading files """ @@ -87,7 +114,9 @@ def __init__(self, host="http://localhost", self.password = password """Password for HTTP basic authentication """ - self.discard_unknown_keys = discard_unknown_keys + self.access_token = access_token + """Access token + """ self.logger = {} """Logging Settings """ @@ -99,13 +128,16 @@ def __init__(self, host="http://localhost", self.logger_stream_handler = None """Log stream handler """ - self.logger_file_handler = None + self.logger_file_handler: Optional[FileHandler] = None """Log file handler """ self.logger_file = None """Debug file location """ - self.debug = False + if debug is not None: + self.debug = debug + else: + self.__debug = False """Debug switch """ @@ -114,7 +146,7 @@ def __init__(self, host="http://localhost", Set this to false to skip verifying SSL certificate when calling API from https server. """ - self.ssl_ca_cert = None + self.ssl_ca_cert = ssl_ca_cert """Set this to customize the certificate file to verify the peer. """ self.cert_file = None @@ -126,6 +158,10 @@ def __init__(self, host="http://localhost", self.assert_hostname = None """Set this to True/False to enable/disable SSL hostname verification. """ + self.tls_server_name = None + """SSL/TLS Server Name Indication (SNI) + Set this to the SNI value expected by the server. + """ self.connection_pool_maxsize = multiprocessing.cpu_count() * 5 """urllib3 connection pool's maximum number of connections saved @@ -135,7 +171,7 @@ def __init__(self, host="http://localhost", cpu_count * 5 is used as default value to increase performance. """ - self.proxy = None + self.proxy: Optional[str] = None """Proxy URL """ self.proxy_headers = None @@ -144,12 +180,24 @@ def __init__(self, host="http://localhost", self.safe_chars_for_path_param = '' """Safe chars for path_param """ - self.retries = None + self.retries = retries """Adding retries to override urllib3 default value 3 """ - # Disable client side validation + # Enable client side validation self.client_side_validation = True + self.socket_options = None + """Options to pass down to the underlying urllib3 socket + """ + + self.datetime_format = "%Y-%m-%dT%H:%M:%S.%f%z" + """datetime format + """ + + self.date_format = "%Y-%m-%d" + """date format + """ + def __deepcopy__(self, memo): cls = self.__class__ result = cls.__new__(cls) @@ -176,21 +224,31 @@ def set_default(cls, default): :param default: object of Configuration """ - cls._default = copy.deepcopy(default) + cls._default = default @classmethod def get_default_copy(cls): - """Return new instance of configuration. + """Deprecated. Please use `get_default` instead. + + Deprecated. Please use `get_default` instead. + + :return: The configuration object. + """ + return cls.get_default() + + @classmethod + def get_default(cls): + """Return the default 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. + configuration. :return: The configuration object. """ - if cls._default is not None: - return copy.deepcopy(cls._default) - return Configuration() + if cls._default is None: + cls._default = Configuration() + return cls._default @property def logger_file(self): @@ -220,7 +278,7 @@ def logger_file(self, value): # 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): + for _, logger in self.logger.items(): logger.addHandler(self.logger_file_handler) @property @@ -242,14 +300,14 @@ def debug(self, value): self.__debug = value if self.__debug: # if debug status is True, turn on debug logging - for _, logger in six.iteritems(self.logger): + for _, logger in self.logger.items(): 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): + for _, logger in self.logger.items(): logger.setLevel(logging.WARNING) # turn off httplib debug httplib.HTTPConnection.debuglevel = 0 @@ -277,15 +335,16 @@ def logger_format(self, value): self.__logger_format = value self.logger_formatter = logging.Formatter(self.__logger_format) - def get_api_key_with_prefix(self, identifier): + def get_api_key_with_prefix(self, identifier, alias=None): """Gets API key (with prefix if set). :param identifier: The identifier of apiKey. + :param alias: The alternative 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) + key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None) if key: prefix = self.api_key_prefix.get(identifier) if prefix: @@ -335,19 +394,23 @@ def get_host_settings(self): """ return [ { - 'url': "/", + 'url': "", 'description': "No description provided", } ] - def get_host_from_settings(self, index, variables=None): + def get_host_from_settings(self, index, variables=None, servers=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 + :param servers: an array of host settings or None :return: URL based on host settings """ + if index is None: + return self._base_path + variables = {} if variables is None else variables - servers = self.get_host_settings() + servers = self.get_host_settings() if servers is None else servers try: server = servers[index] @@ -359,7 +422,7 @@ def get_host_from_settings(self, index, variables=None): url = server['url'] # go through variables and replace placeholders - for variable_name, variable in server['variables'].items(): + for variable_name, variable in server.get('variables', {}).items(): used_value = variables.get( variable_name, variable['default_value']) @@ -374,3 +437,14 @@ def get_host_from_settings(self, index, variables=None): url = url.replace("{" + variable_name + "}", used_value) return url + + @property + def host(self): + """Return generated host.""" + return self.get_host_from_settings(self.server_index, variables=self.server_variables) + + @host.setter + def host(self, value): + """Fix base path.""" + self._base_path = value + self.server_index = None diff --git a/sdk/python/jobset/exceptions.py b/sdk/python/jobset/exceptions.py index a4eca1a04..28eb8c540 100644 --- a/sdk/python/jobset/exceptions.py +++ b/sdk/python/jobset/exceptions.py @@ -3,15 +3,16 @@ """ JobSet SDK - Python SDK for the JobSet API # noqa: E501 + Python SDK for the JobSet API The version of the OpenAPI document: v0.1.4 - Generated by: https://openapi-generator.tech -""" - + Generated by OpenAPI Generator (https://openapi-generator.tech) -import six + Do not edit the class manually. +""" # noqa: E501 +from typing import Any, Optional +from typing_extensions import Self class OpenApiException(Exception): """The base exception class for all OpenAPIExceptions""" @@ -19,7 +20,7 @@ class OpenApiException(Exception): class ApiTypeError(OpenApiException, TypeError): def __init__(self, msg, path_to_item=None, valid_classes=None, - key_type=None): + key_type=None) -> None: """ Raises an exception for TypeErrors Args: @@ -47,7 +48,7 @@ def __init__(self, msg, path_to_item=None, valid_classes=None, class ApiValueError(OpenApiException, ValueError): - def __init__(self, msg, path_to_item=None): + def __init__(self, msg, path_to_item=None) -> None: """ Args: msg (str): the exception message @@ -64,8 +65,27 @@ def __init__(self, msg, path_to_item=None): super(ApiValueError, self).__init__(full_msg) +class ApiAttributeError(OpenApiException, AttributeError): + def __init__(self, msg, path_to_item=None) -> None: + """ + Raised when an attribute reference or assignment fails. + + 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(ApiAttributeError, self).__init__(full_msg) + + class ApiKeyError(OpenApiException, KeyError): - def __init__(self, msg, path_to_item=None): + def __init__(self, msg, path_to_item=None) -> None: """ Args: msg (str): the exception message @@ -83,17 +103,56 @@ def __init__(self, msg, path_to_item=None): class ApiException(OpenApiException): - def __init__(self, status=None, reason=None, http_resp=None): + def __init__( + self, + status=None, + reason=None, + http_resp=None, + *, + body: Optional[str] = None, + data: Optional[Any] = None, + ) -> None: + self.status = status + self.reason = reason + self.body = body + self.data = data + self.headers = None + if http_resp: - self.status = http_resp.status - self.reason = http_resp.reason - self.body = http_resp.data + if self.status is None: + self.status = http_resp.status + if self.reason is None: + self.reason = http_resp.reason + if self.body is None: + try: + self.body = http_resp.data.decode('utf-8') + except Exception: + pass self.headers = http_resp.getheaders() - else: - self.status = status - self.reason = reason - self.body = None - self.headers = None + + @classmethod + def from_response( + cls, + *, + http_resp, + body: Optional[str], + data: Optional[Any], + ) -> Self: + if http_resp.status == 400: + raise BadRequestException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 401: + raise UnauthorizedException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 403: + raise ForbiddenException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 404: + raise NotFoundException(http_resp=http_resp, body=body, data=data) + + if 500 <= http_resp.status <= 599: + raise ServiceException(http_resp=http_resp, body=body, data=data) + raise ApiException(http_resp=http_resp, body=body, data=data) def __str__(self): """Custom error messages for exception""" @@ -103,17 +162,37 @@ def __str__(self): error_message += "HTTP response headers: {0}\n".format( self.headers) - if self.body: - error_message += "HTTP response body: {0}\n".format(self.body) + if self.data or self.body: + error_message += "HTTP response body: {0}\n".format(self.data or self.body) return error_message +class BadRequestException(ApiException): + pass + + +class NotFoundException(ApiException): + pass + + +class UnauthorizedException(ApiException): + pass + + +class ForbiddenException(ApiException): + pass + + +class ServiceException(ApiException): + pass + + 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): + if isinstance(pth, int): result += "[{0}]".format(pth) else: result += "['{0}']".format(pth) diff --git a/sdk/python/jobset/models/__init__.py b/sdk/python/jobset/models/__init__.py index 913baa991..825ed79e2 100644 --- a/sdk/python/jobset/models/__init__.py +++ b/sdk/python/jobset/models/__init__.py @@ -4,17 +4,14 @@ """ JobSet SDK - Python SDK for the JobSet API # noqa: E501 + Python SDK for the JobSet API The version of the OpenAPI document: v0.1.4 - Generated by: https://openapi-generator.tech -""" - + Generated by OpenAPI Generator (https://openapi-generator.tech) -from __future__ import absolute_import + Do not edit the class manually. +""" # noqa: E501 -# Import Kubernetes models. -from kubernetes.client import * # import models into model package from jobset.models.jobset_v1alpha2_coordinator import JobsetV1alpha2Coordinator diff --git a/sdk/python/jobset/models/jobset_v1alpha2_coordinator.py b/sdk/python/jobset/models/jobset_v1alpha2_coordinator.py index 44cfce404..87bdac20c 100644 --- a/sdk/python/jobset/models/jobset_v1alpha2_coordinator.py +++ b/sdk/python/jobset/models/jobset_v1alpha2_coordinator.py @@ -3,177 +3,89 @@ """ JobSet SDK - Python SDK for the JobSet API # noqa: E501 + Python SDK for the JobSet API The version of the OpenAPI document: v0.1.4 - Generated by: https://openapi-generator.tech -""" + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 +from __future__ import annotations import pprint import re # noqa: F401 +import json -import six - -from jobset.configuration import Configuration +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self - -class JobsetV1alpha2Coordinator(object): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. +class JobsetV1alpha2Coordinator(BaseModel): """ - - """ - 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 = { - 'job_index': 'int', - 'pod_index': 'int', - 'replicated_job': 'str' - } - - attribute_map = { - 'job_index': 'jobIndex', - 'pod_index': 'podIndex', - 'replicated_job': 'replicatedJob' - } - - def __init__(self, job_index=None, pod_index=None, replicated_job='', local_vars_configuration=None): # noqa: E501 - """JobsetV1alpha2Coordinator - 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._job_index = None - self._pod_index = None - self._replicated_job = None - self.discriminator = None - - if job_index is not None: - self.job_index = job_index - if pod_index is not None: - self.pod_index = pod_index - self.replicated_job = replicated_job - - @property - def job_index(self): - """Gets the job_index of this JobsetV1alpha2Coordinator. # noqa: E501 - - JobIndex is the index of Job which contains the coordinator pod (i.e., for a ReplicatedJob with N replicas, there are Job indexes 0 to N-1). # noqa: E501 - - :return: The job_index of this JobsetV1alpha2Coordinator. # noqa: E501 - :rtype: int - """ - return self._job_index - - @job_index.setter - def job_index(self, job_index): - """Sets the job_index of this JobsetV1alpha2Coordinator. - - JobIndex is the index of Job which contains the coordinator pod (i.e., for a ReplicatedJob with N replicas, there are Job indexes 0 to N-1). # noqa: E501 - - :param job_index: The job_index of this JobsetV1alpha2Coordinator. # noqa: E501 - :type: int + Coordinator defines which pod can be marked as the coordinator for the JobSet workload. + """ # noqa: E501 + job_index: Optional[StrictInt] = Field(default=None, description="JobIndex is the index of Job which contains the coordinator pod (i.e., for a ReplicatedJob with N replicas, there are Job indexes 0 to N-1).", alias="jobIndex") + pod_index: Optional[StrictInt] = Field(default=None, description="PodIndex is the Job completion index of the coordinator pod.", alias="podIndex") + replicated_job: StrictStr = Field(description="ReplicatedJob is the name of the ReplicatedJob which contains the coordinator pod.", alias="replicatedJob") + __properties: ClassVar[List[str]] = ["jobIndex", "podIndex", "replicatedJob"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of JobsetV1alpha2Coordinator from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. """ + excluded_fields: Set[str] = set([ + ]) - self._job_index = job_index - - @property - def pod_index(self): - """Gets the pod_index of this JobsetV1alpha2Coordinator. # noqa: E501 + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict - PodIndex is the Job completion index of the coordinator pod. # noqa: E501 - - :return: The pod_index of this JobsetV1alpha2Coordinator. # noqa: E501 - :rtype: int - """ - return self._pod_index + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of JobsetV1alpha2Coordinator from a dict""" + if obj is None: + return None - @pod_index.setter - def pod_index(self, pod_index): - """Sets the pod_index of this JobsetV1alpha2Coordinator. - - PodIndex is the Job completion index of the coordinator pod. # noqa: E501 - - :param pod_index: The pod_index of this JobsetV1alpha2Coordinator. # noqa: E501 - :type: int - """ + if not isinstance(obj, dict): + return cls.model_validate(obj) - self._pod_index = pod_index + _obj = cls.model_validate({ + "jobIndex": obj.get("jobIndex"), + "podIndex": obj.get("podIndex"), + "replicatedJob": obj.get("replicatedJob") if obj.get("replicatedJob") is not None else '' + }) + return _obj - @property - def replicated_job(self): - """Gets the replicated_job of this JobsetV1alpha2Coordinator. # noqa: E501 - ReplicatedJob is the name of the ReplicatedJob which contains the coordinator pod. # noqa: E501 - - :return: The replicated_job of this JobsetV1alpha2Coordinator. # noqa: E501 - :rtype: str - """ - return self._replicated_job - - @replicated_job.setter - def replicated_job(self, replicated_job): - """Sets the replicated_job of this JobsetV1alpha2Coordinator. - - ReplicatedJob is the name of the ReplicatedJob which contains the coordinator pod. # noqa: E501 - - :param replicated_job: The replicated_job of this JobsetV1alpha2Coordinator. # noqa: E501 - :type: str - """ - if self.local_vars_configuration.client_side_validation and replicated_job is None: # noqa: E501 - raise ValueError("Invalid value for `replicated_job`, must not be `None`") # noqa: E501 - - self._replicated_job = replicated_job - - 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, JobsetV1alpha2Coordinator): - 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, JobsetV1alpha2Coordinator): - return True - - return self.to_dict() != other.to_dict() diff --git a/sdk/python/jobset/models/jobset_v1alpha2_failure_policy.py b/sdk/python/jobset/models/jobset_v1alpha2_failure_policy.py index 0e7680642..9f5a0b977 100644 --- a/sdk/python/jobset/models/jobset_v1alpha2_failure_policy.py +++ b/sdk/python/jobset/models/jobset_v1alpha2_failure_policy.py @@ -3,148 +3,95 @@ """ JobSet SDK - Python SDK for the JobSet API # noqa: E501 + Python SDK for the JobSet API The version of the OpenAPI document: v0.1.4 - Generated by: https://openapi-generator.tech -""" + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 +from __future__ import annotations import pprint import re # noqa: F401 +import json -import six - -from jobset.configuration import Configuration - - -class JobsetV1alpha2FailurePolicy(object): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ +from pydantic import BaseModel, ConfigDict, Field, StrictInt +from typing import Any, ClassVar, Dict, List, Optional +from jobset.models.jobset_v1alpha2_failure_policy_rule import JobsetV1alpha2FailurePolicyRule +from typing import Optional, Set +from typing_extensions import Self +class JobsetV1alpha2FailurePolicy(BaseModel): """ - 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_restarts': 'int', - 'rules': 'list[JobsetV1alpha2FailurePolicyRule]' - } - - attribute_map = { - 'max_restarts': 'maxRestarts', - 'rules': 'rules' - } - - def __init__(self, max_restarts=None, rules=None, local_vars_configuration=None): # noqa: E501 - """JobsetV1alpha2FailurePolicy - 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_restarts = None - self._rules = None - self.discriminator = None - - if max_restarts is not None: - self.max_restarts = max_restarts - if rules is not None: - self.rules = rules - - @property - def max_restarts(self): - """Gets the max_restarts of this JobsetV1alpha2FailurePolicy. # noqa: E501 - - MaxRestarts defines the limit on the number of JobSet restarts. A restart is achieved by recreating all active child jobs. # noqa: E501 - - :return: The max_restarts of this JobsetV1alpha2FailurePolicy. # noqa: E501 - :rtype: int - """ - return self._max_restarts - - @max_restarts.setter - def max_restarts(self, max_restarts): - """Sets the max_restarts of this JobsetV1alpha2FailurePolicy. - - MaxRestarts defines the limit on the number of JobSet restarts. A restart is achieved by recreating all active child jobs. # noqa: E501 - - :param max_restarts: The max_restarts of this JobsetV1alpha2FailurePolicy. # noqa: E501 - :type: int + JobsetV1alpha2FailurePolicy + """ # noqa: E501 + max_restarts: Optional[StrictInt] = Field(default=None, description="MaxRestarts defines the limit on the number of JobSet restarts. A restart is achieved by recreating all active child jobs.", alias="maxRestarts") + rules: Optional[List[JobsetV1alpha2FailurePolicyRule]] = Field(default=None, description="List of failure policy rules for this JobSet. For a given Job failure, the rules will be evaluated in order, and only the first matching rule will be executed. If no matching rule is found, the RestartJobSet action is applied.") + __properties: ClassVar[List[str]] = ["maxRestarts", "rules"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of JobsetV1alpha2FailurePolicy from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in rules (list) + _items = [] + if self.rules: + for _item_rules in self.rules: + if _item_rules: + _items.append(_item_rules.to_dict()) + _dict['rules'] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of JobsetV1alpha2FailurePolicy from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "maxRestarts": obj.get("maxRestarts"), + "rules": [JobsetV1alpha2FailurePolicyRule.from_dict(_item) for _item in obj["rules"]] if obj.get("rules") is not None else None + }) + return _obj - self._max_restarts = max_restarts - - @property - def rules(self): - """Gets the rules of this JobsetV1alpha2FailurePolicy. # noqa: E501 - - List of failure policy rules for this JobSet. For a given Job failure, the rules will be evaluated in order, and only the first matching rule will be executed. If no matching rule is found, the RestartJobSet action is applied. # noqa: E501 - - :return: The rules of this JobsetV1alpha2FailurePolicy. # noqa: E501 - :rtype: list[JobsetV1alpha2FailurePolicyRule] - """ - return self._rules - - @rules.setter - def rules(self, rules): - """Sets the rules of this JobsetV1alpha2FailurePolicy. - - List of failure policy rules for this JobSet. For a given Job failure, the rules will be evaluated in order, and only the first matching rule will be executed. If no matching rule is found, the RestartJobSet action is applied. # noqa: E501 - - :param rules: The rules of this JobsetV1alpha2FailurePolicy. # noqa: E501 - :type: list[JobsetV1alpha2FailurePolicyRule] - """ - self._rules = rules - - 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, JobsetV1alpha2FailurePolicy): - 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, JobsetV1alpha2FailurePolicy): - return True - - return self.to_dict() != other.to_dict() diff --git a/sdk/python/jobset/models/jobset_v1alpha2_failure_policy_rule.py b/sdk/python/jobset/models/jobset_v1alpha2_failure_policy_rule.py index 459eab518..36d0b7847 100644 --- a/sdk/python/jobset/models/jobset_v1alpha2_failure_policy_rule.py +++ b/sdk/python/jobset/models/jobset_v1alpha2_failure_policy_rule.py @@ -3,206 +3,91 @@ """ JobSet SDK - Python SDK for the JobSet API # noqa: E501 + Python SDK for the JobSet API The version of the OpenAPI document: v0.1.4 - Generated by: https://openapi-generator.tech -""" + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 +from __future__ import annotations import pprint import re # noqa: F401 +import json -import six - -from jobset.configuration import Configuration - +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self -class JobsetV1alpha2FailurePolicyRule(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. +class JobsetV1alpha2FailurePolicyRule(BaseModel): """ - openapi_types = { - 'action': 'str', - 'name': 'str', - 'on_job_failure_reasons': 'list[str]', - 'target_replicated_jobs': 'list[str]' - } - - attribute_map = { - 'action': 'action', - 'name': 'name', - 'on_job_failure_reasons': 'onJobFailureReasons', - 'target_replicated_jobs': 'targetReplicatedJobs' - } - - def __init__(self, action='', name='', on_job_failure_reasons=None, target_replicated_jobs=None, local_vars_configuration=None): # noqa: E501 - """JobsetV1alpha2FailurePolicyRule - 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._action = None - self._name = None - self._on_job_failure_reasons = None - self._target_replicated_jobs = None - self.discriminator = None - - self.action = action - self.name = name - if on_job_failure_reasons is not None: - self.on_job_failure_reasons = on_job_failure_reasons - if target_replicated_jobs is not None: - self.target_replicated_jobs = target_replicated_jobs - - @property - def action(self): - """Gets the action of this JobsetV1alpha2FailurePolicyRule. # noqa: E501 - - The action to take if the rule is matched. # noqa: E501 - - :return: The action of this JobsetV1alpha2FailurePolicyRule. # noqa: E501 - :rtype: str - """ - return self._action - - @action.setter - def action(self, action): - """Sets the action of this JobsetV1alpha2FailurePolicyRule. - - The action to take if the rule is matched. # noqa: E501 - - :param action: The action of this JobsetV1alpha2FailurePolicyRule. # noqa: E501 - :type: str - """ - if self.local_vars_configuration.client_side_validation and action is None: # noqa: E501 - raise ValueError("Invalid value for `action`, must not be `None`") # noqa: E501 - - self._action = action - - @property - def name(self): - """Gets the name of this JobsetV1alpha2FailurePolicyRule. # noqa: E501 - - The name of the failure policy rule. The name is defaulted to 'failurePolicyRuleN' where N is the index of the failure policy rule. The name must match the regular expression \"^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$\". # noqa: E501 - - :return: The name of this JobsetV1alpha2FailurePolicyRule. # noqa: E501 - :rtype: str - """ - return self._name - - @name.setter - def name(self, name): - """Sets the name of this JobsetV1alpha2FailurePolicyRule. - - The name of the failure policy rule. The name is defaulted to 'failurePolicyRuleN' where N is the index of the failure policy rule. The name must match the regular expression \"^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$\". # noqa: E501 - - :param name: The name of this JobsetV1alpha2FailurePolicyRule. # 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 on_job_failure_reasons(self): - """Gets the on_job_failure_reasons of this JobsetV1alpha2FailurePolicyRule. # noqa: E501 - - The requirement on the job failure reasons. The requirement is satisfied if at least one reason matches the list. The rules are evaluated in order, and the first matching rule is executed. An empty list applies the rule to any job failure reason. # noqa: E501 - - :return: The on_job_failure_reasons of this JobsetV1alpha2FailurePolicyRule. # noqa: E501 - :rtype: list[str] - """ - return self._on_job_failure_reasons - - @on_job_failure_reasons.setter - def on_job_failure_reasons(self, on_job_failure_reasons): - """Sets the on_job_failure_reasons of this JobsetV1alpha2FailurePolicyRule. - - The requirement on the job failure reasons. The requirement is satisfied if at least one reason matches the list. The rules are evaluated in order, and the first matching rule is executed. An empty list applies the rule to any job failure reason. # noqa: E501 - - :param on_job_failure_reasons: The on_job_failure_reasons of this JobsetV1alpha2FailurePolicyRule. # noqa: E501 - :type: list[str] - """ - - self._on_job_failure_reasons = on_job_failure_reasons - - @property - def target_replicated_jobs(self): - """Gets the target_replicated_jobs of this JobsetV1alpha2FailurePolicyRule. # noqa: E501 - - TargetReplicatedJobs are the names of the replicated jobs the operator applies to. An empty list will apply to all replicatedJobs. # noqa: E501 - - :return: The target_replicated_jobs of this JobsetV1alpha2FailurePolicyRule. # noqa: E501 - :rtype: list[str] + FailurePolicyRule defines a FailurePolicyAction to be executed if a child job fails due to a reason listed in OnJobFailureReasons. + """ # noqa: E501 + action: StrictStr = Field(description="The action to take if the rule is matched.") + name: StrictStr = Field(description="The name of the failure policy rule. The name is defaulted to 'failurePolicyRuleN' where N is the index of the failure policy rule. The name must match the regular expression \"^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$\".") + on_job_failure_reasons: Optional[List[StrictStr]] = Field(default=None, description="The requirement on the job failure reasons. The requirement is satisfied if at least one reason matches the list. The rules are evaluated in order, and the first matching rule is executed. An empty list applies the rule to any job failure reason.", alias="onJobFailureReasons") + target_replicated_jobs: Optional[List[StrictStr]] = Field(default=None, description="TargetReplicatedJobs are the names of the replicated jobs the operator applies to. An empty list will apply to all replicatedJobs.", alias="targetReplicatedJobs") + __properties: ClassVar[List[str]] = ["action", "name", "onJobFailureReasons", "targetReplicatedJobs"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of JobsetV1alpha2FailurePolicyRule from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. """ - return self._target_replicated_jobs - - @target_replicated_jobs.setter - def target_replicated_jobs(self, target_replicated_jobs): - """Sets the target_replicated_jobs of this JobsetV1alpha2FailurePolicyRule. + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of JobsetV1alpha2FailurePolicyRule from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "action": obj.get("action") if obj.get("action") is not None else '', + "name": obj.get("name") if obj.get("name") is not None else '', + "onJobFailureReasons": obj.get("onJobFailureReasons"), + "targetReplicatedJobs": obj.get("targetReplicatedJobs") + }) + return _obj - TargetReplicatedJobs are the names of the replicated jobs the operator applies to. An empty list will apply to all replicatedJobs. # noqa: E501 - - :param target_replicated_jobs: The target_replicated_jobs of this JobsetV1alpha2FailurePolicyRule. # noqa: E501 - :type: list[str] - """ - self._target_replicated_jobs = target_replicated_jobs - - 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, JobsetV1alpha2FailurePolicyRule): - 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, JobsetV1alpha2FailurePolicyRule): - return True - - return self.to_dict() != other.to_dict() diff --git a/sdk/python/jobset/models/jobset_v1alpha2_job_set.py b/sdk/python/jobset/models/jobset_v1alpha2_job_set.py index 7d382b991..879561432 100644 --- a/sdk/python/jobset/models/jobset_v1alpha2_job_set.py +++ b/sdk/python/jobset/models/jobset_v1alpha2_job_set.py @@ -3,226 +3,104 @@ """ JobSet SDK - Python SDK for the JobSet API # noqa: E501 + Python SDK for the JobSet API The version of the OpenAPI document: v0.1.4 - Generated by: https://openapi-generator.tech -""" + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 +from __future__ import annotations import pprint import re # noqa: F401 +import json -import six - -from jobset.configuration import Configuration +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from jobset.models.jobset_v1alpha2_job_set_spec import JobsetV1alpha2JobSetSpec +from jobset.models.jobset_v1alpha2_job_set_status import JobsetV1alpha2JobSetStatus +from typing import Optional, Set +from typing_extensions import Self - -class JobsetV1alpha2JobSet(object): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. +class JobsetV1alpha2JobSet(BaseModel): """ - - """ - 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': 'JobsetV1alpha2JobSetSpec', - 'status': 'JobsetV1alpha2JobSetStatus' - } - - 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 - """JobsetV1alpha2JobSet - 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 JobsetV1alpha2JobSet. # 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 JobsetV1alpha2JobSet. # noqa: E501 - :rtype: str + JobSet is the Schema for the jobsets API + """ # noqa: E501 + api_version: Optional[StrictStr] = Field(default=None, 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", alias="apiVersion") + kind: Optional[StrictStr] = Field(default=None, 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") + metadata: Optional[V1ObjectMeta] = None + spec: Optional[JobsetV1alpha2JobSetSpec] = None + status: Optional[JobsetV1alpha2JobSetStatus] = None + __properties: ClassVar[List[str]] = ["apiVersion", "kind", "metadata", "spec", "status"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of JobsetV1alpha2JobSet from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. """ - return self._api_version - - @api_version.setter - def api_version(self, api_version): - """Sets the api_version of this JobsetV1alpha2JobSet. - - 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 JobsetV1alpha2JobSet. # noqa: E501 - :type: str - """ - - self._api_version = api_version - - @property - def kind(self): - """Gets the kind of this JobsetV1alpha2JobSet. # 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 JobsetV1alpha2JobSet. # noqa: E501 - :rtype: str - """ - return self._kind - - @kind.setter - def kind(self, kind): - """Sets the kind of this JobsetV1alpha2JobSet. - - 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 JobsetV1alpha2JobSet. # noqa: E501 - :type: str - """ - - self._kind = kind - - @property - def metadata(self): - """Gets the metadata of this JobsetV1alpha2JobSet. # noqa: E501 + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of metadata + if self.metadata: + _dict['metadata'] = self.metadata.to_dict() + # override the default output from pydantic by calling `to_dict()` of spec + if self.spec: + _dict['spec'] = self.spec.to_dict() + # override the default output from pydantic by calling `to_dict()` of status + if self.status: + _dict['status'] = self.status.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of JobsetV1alpha2JobSet from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "apiVersion": obj.get("apiVersion"), + "kind": obj.get("kind"), + "metadata": V1ObjectMeta.from_dict(obj["metadata"]) if obj.get("metadata") is not None else None, + "spec": JobsetV1alpha2JobSetSpec.from_dict(obj["spec"]) if obj.get("spec") is not None else None, + "status": JobsetV1alpha2JobSetStatus.from_dict(obj["status"]) if obj.get("status") is not None else None + }) + return _obj - :return: The metadata of this JobsetV1alpha2JobSet. # noqa: E501 - :rtype: V1ObjectMeta - """ - return self._metadata - - @metadata.setter - def metadata(self, metadata): - """Sets the metadata of this JobsetV1alpha2JobSet. - - - :param metadata: The metadata of this JobsetV1alpha2JobSet. # noqa: E501 - :type: V1ObjectMeta - """ - - self._metadata = metadata - - @property - def spec(self): - """Gets the spec of this JobsetV1alpha2JobSet. # noqa: E501 - - - :return: The spec of this JobsetV1alpha2JobSet. # noqa: E501 - :rtype: JobsetV1alpha2JobSetSpec - """ - return self._spec - - @spec.setter - def spec(self, spec): - """Sets the spec of this JobsetV1alpha2JobSet. - - - :param spec: The spec of this JobsetV1alpha2JobSet. # noqa: E501 - :type: JobsetV1alpha2JobSetSpec - """ - - self._spec = spec - - @property - def status(self): - """Gets the status of this JobsetV1alpha2JobSet. # noqa: E501 - - - :return: The status of this JobsetV1alpha2JobSet. # noqa: E501 - :rtype: JobsetV1alpha2JobSetStatus - """ - return self._status - - @status.setter - def status(self, status): - """Sets the status of this JobsetV1alpha2JobSet. - - - :param status: The status of this JobsetV1alpha2JobSet. # noqa: E501 - :type: JobsetV1alpha2JobSetStatus - """ - - 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, JobsetV1alpha2JobSet): - 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, JobsetV1alpha2JobSet): - return True - - return self.to_dict() != other.to_dict() diff --git a/sdk/python/jobset/models/jobset_v1alpha2_job_set_list.py b/sdk/python/jobset/models/jobset_v1alpha2_job_set_list.py index acf0746a1..db7f9ee8f 100644 --- a/sdk/python/jobset/models/jobset_v1alpha2_job_set_list.py +++ b/sdk/python/jobset/models/jobset_v1alpha2_job_set_list.py @@ -3,201 +3,102 @@ """ JobSet SDK - Python SDK for the JobSet API # noqa: E501 + Python SDK for the JobSet API The version of the OpenAPI document: v0.1.4 - Generated by: https://openapi-generator.tech -""" + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 +from __future__ import annotations import pprint import re # noqa: F401 +import json -import six - -from jobset.configuration import Configuration - +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from jobset.models.jobset_v1alpha2_job_set import JobsetV1alpha2JobSet +from typing import Optional, Set +from typing_extensions import Self -class JobsetV1alpha2JobSetList(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. +class JobsetV1alpha2JobSetList(BaseModel): """ - openapi_types = { - 'api_version': 'str', - 'items': 'list[JobsetV1alpha2JobSet]', - '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 - """JobsetV1alpha2JobSetList - 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 JobsetV1alpha2JobSetList. # 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 JobsetV1alpha2JobSetList. # noqa: E501 - :rtype: str - """ - return self._api_version - - @api_version.setter - def api_version(self, api_version): - """Sets the api_version of this JobsetV1alpha2JobSetList. - - 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 JobsetV1alpha2JobSetList. # noqa: E501 - :type: str - """ - - self._api_version = api_version - - @property - def items(self): - """Gets the items of this JobsetV1alpha2JobSetList. # noqa: E501 - - - :return: The items of this JobsetV1alpha2JobSetList. # noqa: E501 - :rtype: list[JobsetV1alpha2JobSet] - """ - return self._items - - @items.setter - def items(self, items): - """Sets the items of this JobsetV1alpha2JobSetList. - - - :param items: The items of this JobsetV1alpha2JobSetList. # noqa: E501 - :type: list[JobsetV1alpha2JobSet] - """ - 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 JobsetV1alpha2JobSetList. # 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 JobsetV1alpha2JobSetList. # noqa: E501 - :rtype: str - """ - return self._kind - - @kind.setter - def kind(self, kind): - """Sets the kind of this JobsetV1alpha2JobSetList. - - 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 JobsetV1alpha2JobSetList. # noqa: E501 - :type: str - """ - - self._kind = kind - - @property - def metadata(self): - """Gets the metadata of this JobsetV1alpha2JobSetList. # noqa: E501 - - - :return: The metadata of this JobsetV1alpha2JobSetList. # noqa: E501 - :rtype: V1ListMeta + JobSetList contains a list of JobSet + """ # noqa: E501 + api_version: Optional[StrictStr] = Field(default=None, 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", alias="apiVersion") + items: List[JobsetV1alpha2JobSet] + kind: Optional[StrictStr] = Field(default=None, 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") + metadata: Optional[V1ListMeta] = None + __properties: ClassVar[List[str]] = ["apiVersion", "items", "kind", "metadata"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of JobsetV1alpha2JobSetList from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. """ - return self._metadata - - @metadata.setter - def metadata(self, metadata): - """Sets the metadata of this JobsetV1alpha2JobSetList. + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in items (list) + _items = [] + if self.items: + for _item_items in self.items: + if _item_items: + _items.append(_item_items.to_dict()) + _dict['items'] = _items + # override the default output from pydantic by calling `to_dict()` of metadata + if self.metadata: + _dict['metadata'] = self.metadata.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of JobsetV1alpha2JobSetList from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "apiVersion": obj.get("apiVersion"), + "items": [JobsetV1alpha2JobSet.from_dict(_item) for _item in obj["items"]] if obj.get("items") is not None else None, + "kind": obj.get("kind"), + "metadata": V1ListMeta.from_dict(obj["metadata"]) if obj.get("metadata") is not None else None + }) + return _obj - :param metadata: The metadata of this JobsetV1alpha2JobSetList. # 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, JobsetV1alpha2JobSetList): - 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, JobsetV1alpha2JobSetList): - return True - - return self.to_dict() != other.to_dict() diff --git a/sdk/python/jobset/models/jobset_v1alpha2_job_set_spec.py b/sdk/python/jobset/models/jobset_v1alpha2_job_set_spec.py index c51885a9c..2817fc956 100644 --- a/sdk/python/jobset/models/jobset_v1alpha2_job_set_spec.py +++ b/sdk/python/jobset/models/jobset_v1alpha2_job_set_spec.py @@ -3,334 +3,129 @@ """ JobSet SDK - Python SDK for the JobSet API # noqa: E501 + Python SDK for the JobSet API The version of the OpenAPI document: v0.1.4 - Generated by: https://openapi-generator.tech -""" + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 +from __future__ import annotations import pprint import re # noqa: F401 - -import six - -from jobset.configuration import Configuration - - -class JobsetV1alpha2JobSetSpec(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. +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from jobset.models.jobset_v1alpha2_coordinator import JobsetV1alpha2Coordinator +from jobset.models.jobset_v1alpha2_failure_policy import JobsetV1alpha2FailurePolicy +from jobset.models.jobset_v1alpha2_network import JobsetV1alpha2Network +from jobset.models.jobset_v1alpha2_replicated_job import JobsetV1alpha2ReplicatedJob +from jobset.models.jobset_v1alpha2_startup_policy import JobsetV1alpha2StartupPolicy +from jobset.models.jobset_v1alpha2_success_policy import JobsetV1alpha2SuccessPolicy +from typing import Optional, Set +from typing_extensions import Self + +class JobsetV1alpha2JobSetSpec(BaseModel): """ - openapi_types = { - 'coordinator': 'JobsetV1alpha2Coordinator', - 'failure_policy': 'JobsetV1alpha2FailurePolicy', - 'managed_by': 'str', - 'network': 'JobsetV1alpha2Network', - 'replicated_jobs': 'list[JobsetV1alpha2ReplicatedJob]', - 'startup_policy': 'JobsetV1alpha2StartupPolicy', - 'success_policy': 'JobsetV1alpha2SuccessPolicy', - 'suspend': 'bool', - 'ttl_seconds_after_finished': 'int' - } - - attribute_map = { - 'coordinator': 'coordinator', - 'failure_policy': 'failurePolicy', - 'managed_by': 'managedBy', - 'network': 'network', - 'replicated_jobs': 'replicatedJobs', - 'startup_policy': 'startupPolicy', - 'success_policy': 'successPolicy', - 'suspend': 'suspend', - 'ttl_seconds_after_finished': 'ttlSecondsAfterFinished' - } - - def __init__(self, coordinator=None, failure_policy=None, managed_by=None, network=None, replicated_jobs=None, startup_policy=None, success_policy=None, suspend=None, ttl_seconds_after_finished=None, local_vars_configuration=None): # noqa: E501 - """JobsetV1alpha2JobSetSpec - 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._coordinator = None - self._failure_policy = None - self._managed_by = None - self._network = None - self._replicated_jobs = None - self._startup_policy = None - self._success_policy = None - self._suspend = None - self._ttl_seconds_after_finished = None - self.discriminator = None - - if coordinator is not None: - self.coordinator = coordinator - if failure_policy is not None: - self.failure_policy = failure_policy - if managed_by is not None: - self.managed_by = managed_by - if network is not None: - self.network = network - if replicated_jobs is not None: - self.replicated_jobs = replicated_jobs - if startup_policy is not None: - self.startup_policy = startup_policy - if success_policy is not None: - self.success_policy = success_policy - if suspend is not None: - self.suspend = suspend - if ttl_seconds_after_finished is not None: - self.ttl_seconds_after_finished = ttl_seconds_after_finished - - @property - def coordinator(self): - """Gets the coordinator of this JobsetV1alpha2JobSetSpec. # noqa: E501 - - - :return: The coordinator of this JobsetV1alpha2JobSetSpec. # noqa: E501 - :rtype: JobsetV1alpha2Coordinator - """ - return self._coordinator - - @coordinator.setter - def coordinator(self, coordinator): - """Sets the coordinator of this JobsetV1alpha2JobSetSpec. - - - :param coordinator: The coordinator of this JobsetV1alpha2JobSetSpec. # noqa: E501 - :type: JobsetV1alpha2Coordinator - """ - - self._coordinator = coordinator - - @property - def failure_policy(self): - """Gets the failure_policy of this JobsetV1alpha2JobSetSpec. # noqa: E501 - - - :return: The failure_policy of this JobsetV1alpha2JobSetSpec. # noqa: E501 - :rtype: JobsetV1alpha2FailurePolicy - """ - return self._failure_policy - - @failure_policy.setter - def failure_policy(self, failure_policy): - """Sets the failure_policy of this JobsetV1alpha2JobSetSpec. - - - :param failure_policy: The failure_policy of this JobsetV1alpha2JobSetSpec. # noqa: E501 - :type: JobsetV1alpha2FailurePolicy - """ - - self._failure_policy = failure_policy - - @property - def managed_by(self): - """Gets the managed_by of this JobsetV1alpha2JobSetSpec. # noqa: E501 - - ManagedBy is used to indicate the controller or entity that manages a JobSet. The built-in JobSet controller reconciles JobSets which don't have this field at all or the field value is the reserved string `jobset.sigs.k8s.io/jobset-controller`, but skips reconciling JobSets with a custom value for this field. The value must be a valid domain-prefixed path (e.g. acme.io/foo) - all characters before the first \"/\" must be a valid subdomain as defined by RFC 1123. All characters trailing the first \"/\" must be valid HTTP Path characters as defined by RFC 3986. The value cannot exceed 63 characters. The field is immutable. # noqa: E501 - - :return: The managed_by of this JobsetV1alpha2JobSetSpec. # noqa: E501 - :rtype: str - """ - return self._managed_by - - @managed_by.setter - def managed_by(self, managed_by): - """Sets the managed_by of this JobsetV1alpha2JobSetSpec. - - ManagedBy is used to indicate the controller or entity that manages a JobSet. The built-in JobSet controller reconciles JobSets which don't have this field at all or the field value is the reserved string `jobset.sigs.k8s.io/jobset-controller`, but skips reconciling JobSets with a custom value for this field. The value must be a valid domain-prefixed path (e.g. acme.io/foo) - all characters before the first \"/\" must be a valid subdomain as defined by RFC 1123. All characters trailing the first \"/\" must be valid HTTP Path characters as defined by RFC 3986. The value cannot exceed 63 characters. The field is immutable. # noqa: E501 - - :param managed_by: The managed_by of this JobsetV1alpha2JobSetSpec. # noqa: E501 - :type: str - """ - - self._managed_by = managed_by - - @property - def network(self): - """Gets the network of this JobsetV1alpha2JobSetSpec. # noqa: E501 - - - :return: The network of this JobsetV1alpha2JobSetSpec. # noqa: E501 - :rtype: JobsetV1alpha2Network - """ - return self._network - - @network.setter - def network(self, network): - """Sets the network of this JobsetV1alpha2JobSetSpec. - - - :param network: The network of this JobsetV1alpha2JobSetSpec. # noqa: E501 - :type: JobsetV1alpha2Network - """ - - self._network = network - - @property - def replicated_jobs(self): - """Gets the replicated_jobs of this JobsetV1alpha2JobSetSpec. # noqa: E501 - - ReplicatedJobs is the group of jobs that will form the set. # noqa: E501 - - :return: The replicated_jobs of this JobsetV1alpha2JobSetSpec. # noqa: E501 - :rtype: list[JobsetV1alpha2ReplicatedJob] - """ - return self._replicated_jobs - - @replicated_jobs.setter - def replicated_jobs(self, replicated_jobs): - """Sets the replicated_jobs of this JobsetV1alpha2JobSetSpec. - - ReplicatedJobs is the group of jobs that will form the set. # noqa: E501 - - :param replicated_jobs: The replicated_jobs of this JobsetV1alpha2JobSetSpec. # noqa: E501 - :type: list[JobsetV1alpha2ReplicatedJob] - """ - - self._replicated_jobs = replicated_jobs - - @property - def startup_policy(self): - """Gets the startup_policy of this JobsetV1alpha2JobSetSpec. # noqa: E501 - - - :return: The startup_policy of this JobsetV1alpha2JobSetSpec. # noqa: E501 - :rtype: JobsetV1alpha2StartupPolicy - """ - return self._startup_policy - - @startup_policy.setter - def startup_policy(self, startup_policy): - """Sets the startup_policy of this JobsetV1alpha2JobSetSpec. - - - :param startup_policy: The startup_policy of this JobsetV1alpha2JobSetSpec. # noqa: E501 - :type: JobsetV1alpha2StartupPolicy - """ - - self._startup_policy = startup_policy - - @property - def success_policy(self): - """Gets the success_policy of this JobsetV1alpha2JobSetSpec. # noqa: E501 - - - :return: The success_policy of this JobsetV1alpha2JobSetSpec. # noqa: E501 - :rtype: JobsetV1alpha2SuccessPolicy - """ - return self._success_policy - - @success_policy.setter - def success_policy(self, success_policy): - """Sets the success_policy of this JobsetV1alpha2JobSetSpec. - - - :param success_policy: The success_policy of this JobsetV1alpha2JobSetSpec. # noqa: E501 - :type: JobsetV1alpha2SuccessPolicy - """ - - self._success_policy = success_policy - - @property - def suspend(self): - """Gets the suspend of this JobsetV1alpha2JobSetSpec. # noqa: E501 - - Suspend suspends all running child Jobs when set to true. # noqa: E501 - - :return: The suspend of this JobsetV1alpha2JobSetSpec. # noqa: E501 - :rtype: bool - """ - return self._suspend - - @suspend.setter - def suspend(self, suspend): - """Sets the suspend of this JobsetV1alpha2JobSetSpec. - - Suspend suspends all running child Jobs when set to true. # noqa: E501 - - :param suspend: The suspend of this JobsetV1alpha2JobSetSpec. # noqa: E501 - :type: bool - """ - - self._suspend = suspend - - @property - def ttl_seconds_after_finished(self): - """Gets the ttl_seconds_after_finished of this JobsetV1alpha2JobSetSpec. # noqa: E501 - - TTLSecondsAfterFinished limits the lifetime of a JobSet that has finished execution (either Complete or Failed). If this field is set, TTLSecondsAfterFinished after the JobSet finishes, it is eligible to be automatically deleted. When the JobSet is being deleted, its lifecycle guarantees (e.g. finalizers) will be honored. If this field is unset, the JobSet won't be automatically deleted. If this field is set to zero, the JobSet becomes eligible to be deleted immediately after it finishes. # noqa: E501 - - :return: The ttl_seconds_after_finished of this JobsetV1alpha2JobSetSpec. # noqa: E501 - :rtype: int - """ - return self._ttl_seconds_after_finished - - @ttl_seconds_after_finished.setter - def ttl_seconds_after_finished(self, ttl_seconds_after_finished): - """Sets the ttl_seconds_after_finished of this JobsetV1alpha2JobSetSpec. - - TTLSecondsAfterFinished limits the lifetime of a JobSet that has finished execution (either Complete or Failed). If this field is set, TTLSecondsAfterFinished after the JobSet finishes, it is eligible to be automatically deleted. When the JobSet is being deleted, its lifecycle guarantees (e.g. finalizers) will be honored. If this field is unset, the JobSet won't be automatically deleted. If this field is set to zero, the JobSet becomes eligible to be deleted immediately after it finishes. # noqa: E501 - - :param ttl_seconds_after_finished: The ttl_seconds_after_finished of this JobsetV1alpha2JobSetSpec. # noqa: E501 - :type: int - """ - - self._ttl_seconds_after_finished = ttl_seconds_after_finished - - 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, JobsetV1alpha2JobSetSpec): - return False - - return self.to_dict() == other.to_dict() + JobSetSpec defines the desired state of JobSet + """ # noqa: E501 + coordinator: Optional[JobsetV1alpha2Coordinator] = None + failure_policy: Optional[JobsetV1alpha2FailurePolicy] = Field(default=None, alias="failurePolicy") + managed_by: Optional[StrictStr] = Field(default=None, description="ManagedBy is used to indicate the controller or entity that manages a JobSet. The built-in JobSet controller reconciles JobSets which don't have this field at all or the field value is the reserved string `jobset.sigs.k8s.io/jobset-controller`, but skips reconciling JobSets with a custom value for this field. The value must be a valid domain-prefixed path (e.g. acme.io/foo) - all characters before the first \"/\" must be a valid subdomain as defined by RFC 1123. All characters trailing the first \"/\" must be valid HTTP Path characters as defined by RFC 3986. The value cannot exceed 63 characters. The field is immutable.", alias="managedBy") + network: Optional[JobsetV1alpha2Network] = None + replicated_jobs: Optional[List[JobsetV1alpha2ReplicatedJob]] = Field(default=None, description="ReplicatedJobs is the group of jobs that will form the set.", alias="replicatedJobs") + startup_policy: Optional[JobsetV1alpha2StartupPolicy] = Field(default=None, alias="startupPolicy") + success_policy: Optional[JobsetV1alpha2SuccessPolicy] = Field(default=None, alias="successPolicy") + suspend: Optional[StrictBool] = Field(default=None, description="Suspend suspends all running child Jobs when set to true.") + ttl_seconds_after_finished: Optional[StrictInt] = Field(default=None, description="TTLSecondsAfterFinished limits the lifetime of a JobSet that has finished execution (either Complete or Failed). If this field is set, TTLSecondsAfterFinished after the JobSet finishes, it is eligible to be automatically deleted. When the JobSet is being deleted, its lifecycle guarantees (e.g. finalizers) will be honored. If this field is unset, the JobSet won't be automatically deleted. If this field is set to zero, the JobSet becomes eligible to be deleted immediately after it finishes.", alias="ttlSecondsAfterFinished") + __properties: ClassVar[List[str]] = ["coordinator", "failurePolicy", "managedBy", "network", "replicatedJobs", "startupPolicy", "successPolicy", "suspend", "ttlSecondsAfterFinished"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of JobsetV1alpha2JobSetSpec from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of coordinator + if self.coordinator: + _dict['coordinator'] = self.coordinator.to_dict() + # override the default output from pydantic by calling `to_dict()` of failure_policy + if self.failure_policy: + _dict['failurePolicy'] = self.failure_policy.to_dict() + # override the default output from pydantic by calling `to_dict()` of network + if self.network: + _dict['network'] = self.network.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in replicated_jobs (list) + _items = [] + if self.replicated_jobs: + for _item_replicated_jobs in self.replicated_jobs: + if _item_replicated_jobs: + _items.append(_item_replicated_jobs.to_dict()) + _dict['replicatedJobs'] = _items + # override the default output from pydantic by calling `to_dict()` of startup_policy + if self.startup_policy: + _dict['startupPolicy'] = self.startup_policy.to_dict() + # override the default output from pydantic by calling `to_dict()` of success_policy + if self.success_policy: + _dict['successPolicy'] = self.success_policy.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of JobsetV1alpha2JobSetSpec from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "coordinator": JobsetV1alpha2Coordinator.from_dict(obj["coordinator"]) if obj.get("coordinator") is not None else None, + "failurePolicy": JobsetV1alpha2FailurePolicy.from_dict(obj["failurePolicy"]) if obj.get("failurePolicy") is not None else None, + "managedBy": obj.get("managedBy"), + "network": JobsetV1alpha2Network.from_dict(obj["network"]) if obj.get("network") is not None else None, + "replicatedJobs": [JobsetV1alpha2ReplicatedJob.from_dict(_item) for _item in obj["replicatedJobs"]] if obj.get("replicatedJobs") is not None else None, + "startupPolicy": JobsetV1alpha2StartupPolicy.from_dict(obj["startupPolicy"]) if obj.get("startupPolicy") is not None else None, + "successPolicy": JobsetV1alpha2SuccessPolicy.from_dict(obj["successPolicy"]) if obj.get("successPolicy") is not None else None, + "suspend": obj.get("suspend"), + "ttlSecondsAfterFinished": obj.get("ttlSecondsAfterFinished") + }) + return _obj - def __ne__(self, other): - """Returns true if both objects are not equal""" - if not isinstance(other, JobsetV1alpha2JobSetSpec): - return True - return self.to_dict() != other.to_dict() diff --git a/sdk/python/jobset/models/jobset_v1alpha2_job_set_status.py b/sdk/python/jobset/models/jobset_v1alpha2_job_set_status.py index d95cfa327..ac6bdd91d 100644 --- a/sdk/python/jobset/models/jobset_v1alpha2_job_set_status.py +++ b/sdk/python/jobset/models/jobset_v1alpha2_job_set_status.py @@ -3,230 +3,108 @@ """ JobSet SDK - Python SDK for the JobSet API # noqa: E501 + Python SDK for the JobSet API The version of the OpenAPI document: v0.1.4 - Generated by: https://openapi-generator.tech -""" + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 +from __future__ import annotations import pprint import re # noqa: F401 +import json -import six - -from jobset.configuration import Configuration +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from jobset.models.jobset_v1alpha2_replicated_job_status import JobsetV1alpha2ReplicatedJobStatus +from typing import Optional, Set +from typing_extensions import Self - -class JobsetV1alpha2JobSetStatus(object): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. +class JobsetV1alpha2JobSetStatus(BaseModel): """ - - """ - 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]', - 'replicated_jobs_status': 'list[JobsetV1alpha2ReplicatedJobStatus]', - 'restarts': 'int', - 'restarts_count_towards_max': 'int', - 'terminal_state': 'str' - } - - attribute_map = { - 'conditions': 'conditions', - 'replicated_jobs_status': 'replicatedJobsStatus', - 'restarts': 'restarts', - 'restarts_count_towards_max': 'restartsCountTowardsMax', - 'terminal_state': 'terminalState' - } - - def __init__(self, conditions=None, replicated_jobs_status=None, restarts=None, restarts_count_towards_max=None, terminal_state=None, local_vars_configuration=None): # noqa: E501 - """JobsetV1alpha2JobSetStatus - 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._replicated_jobs_status = None - self._restarts = None - self._restarts_count_towards_max = None - self._terminal_state = None - self.discriminator = None - - if conditions is not None: - self.conditions = conditions - if replicated_jobs_status is not None: - self.replicated_jobs_status = replicated_jobs_status - if restarts is not None: - self.restarts = restarts - if restarts_count_towards_max is not None: - self.restarts_count_towards_max = restarts_count_towards_max - if terminal_state is not None: - self.terminal_state = terminal_state - - @property - def conditions(self): - """Gets the conditions of this JobsetV1alpha2JobSetStatus. # noqa: E501 - - - :return: The conditions of this JobsetV1alpha2JobSetStatus. # noqa: E501 - :rtype: list[V1Condition] + JobSetStatus defines the observed state of JobSet + """ # noqa: E501 + conditions: Optional[List[V1Condition]] = None + replicated_jobs_status: Optional[List[JobsetV1alpha2ReplicatedJobStatus]] = Field(default=None, description="ReplicatedJobsStatus track the number of JobsReady for each replicatedJob.", alias="replicatedJobsStatus") + restarts: Optional[StrictInt] = Field(default=None, description="Restarts tracks the number of times the JobSet has restarted (i.e. recreated in case of RecreateAll policy).") + restarts_count_towards_max: Optional[StrictInt] = Field(default=None, description="RestartsCountTowardsMax tracks the number of times the JobSet has restarted that counts towards the maximum allowed number of restarts.", alias="restartsCountTowardsMax") + terminal_state: Optional[StrictStr] = Field(default=None, description="TerminalState the state of the JobSet when it finishes execution. It can be either Complete or Failed. Otherwise, it is empty by default.", alias="terminalState") + __properties: ClassVar[List[str]] = ["conditions", "replicatedJobsStatus", "restarts", "restartsCountTowardsMax", "terminalState"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of JobsetV1alpha2JobSetStatus from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. """ - return self._conditions - - @conditions.setter - def conditions(self, conditions): - """Sets the conditions of this JobsetV1alpha2JobSetStatus. - - - :param conditions: The conditions of this JobsetV1alpha2JobSetStatus. # noqa: E501 - :type: list[V1Condition] - """ - - self._conditions = conditions - - @property - def replicated_jobs_status(self): - """Gets the replicated_jobs_status of this JobsetV1alpha2JobSetStatus. # noqa: E501 - - ReplicatedJobsStatus track the number of JobsReady for each replicatedJob. # noqa: E501 - - :return: The replicated_jobs_status of this JobsetV1alpha2JobSetStatus. # noqa: E501 - :rtype: list[JobsetV1alpha2ReplicatedJobStatus] - """ - return self._replicated_jobs_status - - @replicated_jobs_status.setter - def replicated_jobs_status(self, replicated_jobs_status): - """Sets the replicated_jobs_status of this JobsetV1alpha2JobSetStatus. - - ReplicatedJobsStatus track the number of JobsReady for each replicatedJob. # noqa: E501 - - :param replicated_jobs_status: The replicated_jobs_status of this JobsetV1alpha2JobSetStatus. # noqa: E501 - :type: list[JobsetV1alpha2ReplicatedJobStatus] - """ - - self._replicated_jobs_status = replicated_jobs_status - - @property - def restarts(self): - """Gets the restarts of this JobsetV1alpha2JobSetStatus. # noqa: E501 + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in conditions (list) + _items = [] + if self.conditions: + for _item_conditions in self.conditions: + if _item_conditions: + _items.append(_item_conditions.to_dict()) + _dict['conditions'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in replicated_jobs_status (list) + _items = [] + if self.replicated_jobs_status: + for _item_replicated_jobs_status in self.replicated_jobs_status: + if _item_replicated_jobs_status: + _items.append(_item_replicated_jobs_status.to_dict()) + _dict['replicatedJobsStatus'] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of JobsetV1alpha2JobSetStatus from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "conditions": [V1Condition.from_dict(_item) for _item in obj["conditions"]] if obj.get("conditions") is not None else None, + "replicatedJobsStatus": [JobsetV1alpha2ReplicatedJobStatus.from_dict(_item) for _item in obj["replicatedJobsStatus"]] if obj.get("replicatedJobsStatus") is not None else None, + "restarts": obj.get("restarts"), + "restartsCountTowardsMax": obj.get("restartsCountTowardsMax"), + "terminalState": obj.get("terminalState") + }) + return _obj - Restarts tracks the number of times the JobSet has restarted (i.e. recreated in case of RecreateAll policy). # noqa: E501 - - :return: The restarts of this JobsetV1alpha2JobSetStatus. # noqa: E501 - :rtype: int - """ - return self._restarts - - @restarts.setter - def restarts(self, restarts): - """Sets the restarts of this JobsetV1alpha2JobSetStatus. - - Restarts tracks the number of times the JobSet has restarted (i.e. recreated in case of RecreateAll policy). # noqa: E501 - - :param restarts: The restarts of this JobsetV1alpha2JobSetStatus. # noqa: E501 - :type: int - """ - - self._restarts = restarts - - @property - def restarts_count_towards_max(self): - """Gets the restarts_count_towards_max of this JobsetV1alpha2JobSetStatus. # noqa: E501 - - RestartsCountTowardsMax tracks the number of times the JobSet has restarted that counts towards the maximum allowed number of restarts. # noqa: E501 - - :return: The restarts_count_towards_max of this JobsetV1alpha2JobSetStatus. # noqa: E501 - :rtype: int - """ - return self._restarts_count_towards_max - - @restarts_count_towards_max.setter - def restarts_count_towards_max(self, restarts_count_towards_max): - """Sets the restarts_count_towards_max of this JobsetV1alpha2JobSetStatus. - - RestartsCountTowardsMax tracks the number of times the JobSet has restarted that counts towards the maximum allowed number of restarts. # noqa: E501 - - :param restarts_count_towards_max: The restarts_count_towards_max of this JobsetV1alpha2JobSetStatus. # noqa: E501 - :type: int - """ - - self._restarts_count_towards_max = restarts_count_towards_max - - @property - def terminal_state(self): - """Gets the terminal_state of this JobsetV1alpha2JobSetStatus. # noqa: E501 - - TerminalState the state of the JobSet when it finishes execution. It can be either Complete or Failed. Otherwise, it is empty by default. # noqa: E501 - - :return: The terminal_state of this JobsetV1alpha2JobSetStatus. # noqa: E501 - :rtype: str - """ - return self._terminal_state - - @terminal_state.setter - def terminal_state(self, terminal_state): - """Sets the terminal_state of this JobsetV1alpha2JobSetStatus. - - TerminalState the state of the JobSet when it finishes execution. It can be either Complete or Failed. Otherwise, it is empty by default. # noqa: E501 - - :param terminal_state: The terminal_state of this JobsetV1alpha2JobSetStatus. # noqa: E501 - :type: str - """ - self._terminal_state = terminal_state - - 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, JobsetV1alpha2JobSetStatus): - 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, JobsetV1alpha2JobSetStatus): - return True - - return self.to_dict() != other.to_dict() diff --git a/sdk/python/jobset/models/jobset_v1alpha2_network.py b/sdk/python/jobset/models/jobset_v1alpha2_network.py index fe280a1cf..8ff7d1c01 100644 --- a/sdk/python/jobset/models/jobset_v1alpha2_network.py +++ b/sdk/python/jobset/models/jobset_v1alpha2_network.py @@ -3,176 +3,89 @@ """ JobSet SDK - Python SDK for the JobSet API # noqa: E501 + Python SDK for the JobSet API The version of the OpenAPI document: v0.1.4 - Generated by: https://openapi-generator.tech -""" + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 +from __future__ import annotations import pprint import re # noqa: F401 +import json -import six - -from jobset.configuration import Configuration - - -class JobsetV1alpha2Network(object): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self +class JobsetV1alpha2Network(BaseModel): """ - 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 = { - 'enable_dns_hostnames': 'bool', - 'publish_not_ready_addresses': 'bool', - 'subdomain': 'str' - } - - attribute_map = { - 'enable_dns_hostnames': 'enableDNSHostnames', - 'publish_not_ready_addresses': 'publishNotReadyAddresses', - 'subdomain': 'subdomain' - } - - def __init__(self, enable_dns_hostnames=None, publish_not_ready_addresses=None, subdomain=None, local_vars_configuration=None): # noqa: E501 - """JobsetV1alpha2Network - 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._enable_dns_hostnames = None - self._publish_not_ready_addresses = None - self._subdomain = None - self.discriminator = None - - if enable_dns_hostnames is not None: - self.enable_dns_hostnames = enable_dns_hostnames - if publish_not_ready_addresses is not None: - self.publish_not_ready_addresses = publish_not_ready_addresses - if subdomain is not None: - self.subdomain = subdomain - - @property - def enable_dns_hostnames(self): - """Gets the enable_dns_hostnames of this JobsetV1alpha2Network. # noqa: E501 - - EnableDNSHostnames allows pods to be reached via their hostnames. Pods will be reachable using the fully qualified pod hostname: ---. # noqa: E501 - - :return: The enable_dns_hostnames of this JobsetV1alpha2Network. # noqa: E501 - :rtype: bool + JobsetV1alpha2Network + """ # noqa: E501 + enable_dns_hostnames: Optional[StrictBool] = Field(default=None, description="EnableDNSHostnames allows pods to be reached via their hostnames. Pods will be reachable using the fully qualified pod hostname: ---.", alias="enableDNSHostnames") + publish_not_ready_addresses: Optional[StrictBool] = Field(default=None, description="Indicates if DNS records of pods should be published before the pods are ready. Defaults to True.", alias="publishNotReadyAddresses") + subdomain: Optional[StrictStr] = Field(default=None, description="Subdomain is an explicit choice for a network subdomain name When set, any replicated job in the set is added to this network. Defaults to if not set.") + __properties: ClassVar[List[str]] = ["enableDNSHostnames", "publishNotReadyAddresses", "subdomain"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of JobsetV1alpha2Network from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. """ - return self._enable_dns_hostnames + excluded_fields: Set[str] = set([ + ]) - @enable_dns_hostnames.setter - def enable_dns_hostnames(self, enable_dns_hostnames): - """Sets the enable_dns_hostnames of this JobsetV1alpha2Network. + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict - EnableDNSHostnames allows pods to be reached via their hostnames. Pods will be reachable using the fully qualified pod hostname: ---. # noqa: E501 + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of JobsetV1alpha2Network from a dict""" + if obj is None: + return None - :param enable_dns_hostnames: The enable_dns_hostnames of this JobsetV1alpha2Network. # noqa: E501 - :type: bool - """ + if not isinstance(obj, dict): + return cls.model_validate(obj) - self._enable_dns_hostnames = enable_dns_hostnames + _obj = cls.model_validate({ + "enableDNSHostnames": obj.get("enableDNSHostnames"), + "publishNotReadyAddresses": obj.get("publishNotReadyAddresses"), + "subdomain": obj.get("subdomain") + }) + return _obj - @property - def publish_not_ready_addresses(self): - """Gets the publish_not_ready_addresses of this JobsetV1alpha2Network. # noqa: E501 - - Indicates if DNS records of pods should be published before the pods are ready. Defaults to True. # noqa: E501 - - :return: The publish_not_ready_addresses of this JobsetV1alpha2Network. # noqa: E501 - :rtype: bool - """ - return self._publish_not_ready_addresses - - @publish_not_ready_addresses.setter - def publish_not_ready_addresses(self, publish_not_ready_addresses): - """Sets the publish_not_ready_addresses of this JobsetV1alpha2Network. - - Indicates if DNS records of pods should be published before the pods are ready. Defaults to True. # noqa: E501 - - :param publish_not_ready_addresses: The publish_not_ready_addresses of this JobsetV1alpha2Network. # noqa: E501 - :type: bool - """ - - self._publish_not_ready_addresses = publish_not_ready_addresses - - @property - def subdomain(self): - """Gets the subdomain of this JobsetV1alpha2Network. # noqa: E501 - - Subdomain is an explicit choice for a network subdomain name When set, any replicated job in the set is added to this network. Defaults to if not set. # noqa: E501 - - :return: The subdomain of this JobsetV1alpha2Network. # noqa: E501 - :rtype: str - """ - return self._subdomain - - @subdomain.setter - def subdomain(self, subdomain): - """Sets the subdomain of this JobsetV1alpha2Network. - - Subdomain is an explicit choice for a network subdomain name When set, any replicated job in the set is added to this network. Defaults to if not set. # noqa: E501 - - :param subdomain: The subdomain of this JobsetV1alpha2Network. # noqa: E501 - :type: str - """ - self._subdomain = subdomain - - 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, JobsetV1alpha2Network): - 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, JobsetV1alpha2Network): - return True - - return self.to_dict() != other.to_dict() diff --git a/sdk/python/jobset/models/jobset_v1alpha2_replicated_job.py b/sdk/python/jobset/models/jobset_v1alpha2_replicated_job.py index 2ca4f093e..b7840838b 100644 --- a/sdk/python/jobset/models/jobset_v1alpha2_replicated_job.py +++ b/sdk/python/jobset/models/jobset_v1alpha2_replicated_job.py @@ -3,176 +3,92 @@ """ JobSet SDK - Python SDK for the JobSet API # noqa: E501 + Python SDK for the JobSet API The version of the OpenAPI document: v0.1.4 - Generated by: https://openapi-generator.tech -""" + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 +from __future__ import annotations import pprint import re # noqa: F401 +import json -import six - -from jobset.configuration import Configuration +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self - -class JobsetV1alpha2ReplicatedJob(object): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. +class JobsetV1alpha2ReplicatedJob(BaseModel): """ - - """ - 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', - 'replicas': 'int', - 'template': 'V1JobTemplateSpec' - } - - attribute_map = { - 'name': 'name', - 'replicas': 'replicas', - 'template': 'template' - } - - def __init__(self, name='', replicas=None, template=None, local_vars_configuration=None): # noqa: E501 - """JobsetV1alpha2ReplicatedJob - 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._replicas = None - self._template = None - self.discriminator = None - - self.name = name - if replicas is not None: - self.replicas = replicas - self.template = template - - @property - def name(self): - """Gets the name of this JobsetV1alpha2ReplicatedJob. # noqa: E501 - - Name is the name of the entry and will be used as a suffix for the Job name. # noqa: E501 - - :return: The name of this JobsetV1alpha2ReplicatedJob. # noqa: E501 - :rtype: str - """ - return self._name - - @name.setter - def name(self, name): - """Sets the name of this JobsetV1alpha2ReplicatedJob. - - Name is the name of the entry and will be used as a suffix for the Job name. # noqa: E501 - - :param name: The name of this JobsetV1alpha2ReplicatedJob. # 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 replicas(self): - """Gets the replicas of this JobsetV1alpha2ReplicatedJob. # noqa: E501 - - Replicas is the number of jobs that will be created from this ReplicatedJob's template. Jobs names will be in the format: -- # noqa: E501 - - :return: The replicas of this JobsetV1alpha2ReplicatedJob. # noqa: E501 - :rtype: int - """ - return self._replicas - - @replicas.setter - def replicas(self, replicas): - """Sets the replicas of this JobsetV1alpha2ReplicatedJob. - - Replicas is the number of jobs that will be created from this ReplicatedJob's template. Jobs names will be in the format: -- # noqa: E501 - - :param replicas: The replicas of this JobsetV1alpha2ReplicatedJob. # noqa: E501 - :type: int + JobsetV1alpha2ReplicatedJob + """ # noqa: E501 + name: StrictStr = Field(description="Name is the name of the entry and will be used as a suffix for the Job name.") + replicas: Optional[StrictInt] = Field(default=None, description="Replicas is the number of jobs that will be created from this ReplicatedJob's template. Jobs names will be in the format: --") + template: V1JobTemplateSpec + __properties: ClassVar[List[str]] = ["name", "replicas", "template"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of JobsetV1alpha2ReplicatedJob from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of template + if self.template: + _dict['template'] = self.template.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of JobsetV1alpha2ReplicatedJob from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "name": obj.get("name") if obj.get("name") is not None else '', + "replicas": obj.get("replicas"), + "template": V1JobTemplateSpec.from_dict(obj["template"]) if obj.get("template") is not None else None + }) + return _obj - self._replicas = replicas - @property - def template(self): - """Gets the template of this JobsetV1alpha2ReplicatedJob. # noqa: E501 - - - :return: The template of this JobsetV1alpha2ReplicatedJob. # noqa: E501 - :rtype: V1JobTemplateSpec - """ - return self._template - - @template.setter - def template(self, template): - """Sets the template of this JobsetV1alpha2ReplicatedJob. - - - :param template: The template of this JobsetV1alpha2ReplicatedJob. # noqa: E501 - :type: V1JobTemplateSpec - """ - 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, JobsetV1alpha2ReplicatedJob): - 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, JobsetV1alpha2ReplicatedJob): - return True - - return self.to_dict() != other.to_dict() diff --git a/sdk/python/jobset/models/jobset_v1alpha2_replicated_job_status.py b/sdk/python/jobset/models/jobset_v1alpha2_replicated_job_status.py index e278c81e9..9d65f236c 100644 --- a/sdk/python/jobset/models/jobset_v1alpha2_replicated_job_status.py +++ b/sdk/python/jobset/models/jobset_v1alpha2_replicated_job_status.py @@ -3,266 +3,95 @@ """ JobSet SDK - Python SDK for the JobSet API # noqa: E501 + Python SDK for the JobSet API The version of the OpenAPI document: v0.1.4 - Generated by: https://openapi-generator.tech -""" + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 +from __future__ import annotations import pprint import re # noqa: F401 +import json -import six - -from jobset.configuration import Configuration - +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self -class JobsetV1alpha2ReplicatedJobStatus(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. +class JobsetV1alpha2ReplicatedJobStatus(BaseModel): """ - 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 - """JobsetV1alpha2ReplicatedJobStatus - 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 JobsetV1alpha2ReplicatedJobStatus. # 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 JobsetV1alpha2ReplicatedJobStatus. # noqa: E501 - :rtype: int - """ - return self._active - - @active.setter - def active(self, active): - """Sets the active of this JobsetV1alpha2ReplicatedJobStatus. - - 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 JobsetV1alpha2ReplicatedJobStatus. # 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 JobsetV1alpha2ReplicatedJobStatus. # noqa: E501 - - Failed is the number of failed child Jobs. # noqa: E501 - - :return: The failed of this JobsetV1alpha2ReplicatedJobStatus. # noqa: E501 - :rtype: int - """ - return self._failed - - @failed.setter - def failed(self, failed): - """Sets the failed of this JobsetV1alpha2ReplicatedJobStatus. - - Failed is the number of failed child Jobs. # noqa: E501 - - :param failed: The failed of this JobsetV1alpha2ReplicatedJobStatus. # 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 JobsetV1alpha2ReplicatedJobStatus. # noqa: E501 - - Name of the ReplicatedJob. # noqa: E501 - - :return: The name of this JobsetV1alpha2ReplicatedJobStatus. # noqa: E501 - :rtype: str - """ - return self._name - - @name.setter - def name(self, name): - """Sets the name of this JobsetV1alpha2ReplicatedJobStatus. - - Name of the ReplicatedJob. # noqa: E501 - - :param name: The name of this JobsetV1alpha2ReplicatedJobStatus. # 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 JobsetV1alpha2ReplicatedJobStatus. # 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 Job (i.e., the minimum of job.spec.parallelism and job.spec.completions). # noqa: E501 - - :return: The ready of this JobsetV1alpha2ReplicatedJobStatus. # noqa: E501 - :rtype: int + ReplicatedJobStatus defines the observed ReplicatedJobs Readiness. + """ # noqa: E501 + active: StrictInt = Field(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.") + failed: StrictInt = Field(description="Failed is the number of failed child Jobs.") + name: StrictStr = Field(description="Name of the ReplicatedJob.") + ready: StrictInt = Field(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 Job (i.e., the minimum of job.spec.parallelism and job.spec.completions).") + succeeded: StrictInt = Field(description="Succeeded is the number of successfully completed child Jobs.") + suspended: StrictInt = Field(description="Suspended is the number of child Jobs which are in a suspended state.") + __properties: ClassVar[List[str]] = ["active", "failed", "name", "ready", "succeeded", "suspended"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of JobsetV1alpha2ReplicatedJobStatus from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. """ - return self._ready - - @ready.setter - def ready(self, ready): - """Sets the ready of this JobsetV1alpha2ReplicatedJobStatus. - - 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 Job (i.e., the minimum of job.spec.parallelism and job.spec.completions). # noqa: E501 - - :param ready: The ready of this JobsetV1alpha2ReplicatedJobStatus. # 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 JobsetV1alpha2ReplicatedJobStatus. # noqa: E501 - - Succeeded is the number of successfully completed child Jobs. # noqa: E501 - - :return: The succeeded of this JobsetV1alpha2ReplicatedJobStatus. # noqa: E501 - :rtype: int - """ - return self._succeeded - - @succeeded.setter - def succeeded(self, succeeded): - """Sets the succeeded of this JobsetV1alpha2ReplicatedJobStatus. - - Succeeded is the number of successfully completed child Jobs. # noqa: E501 - - :param succeeded: The succeeded of this JobsetV1alpha2ReplicatedJobStatus. # 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 JobsetV1alpha2ReplicatedJobStatus. # noqa: E501 - - Suspended is the number of child Jobs which are in a suspended state. # noqa: E501 - - :return: The suspended of this JobsetV1alpha2ReplicatedJobStatus. # noqa: E501 - :rtype: int - """ - return self._suspended - - @suspended.setter - def suspended(self, suspended): - """Sets the suspended of this JobsetV1alpha2ReplicatedJobStatus. - - Suspended is the number of child Jobs which are in a suspended state. # noqa: E501 - - :param suspended: The suspended of this JobsetV1alpha2ReplicatedJobStatus. # 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, JobsetV1alpha2ReplicatedJobStatus): - return False - - return self.to_dict() == other.to_dict() + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of JobsetV1alpha2ReplicatedJobStatus from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "active": obj.get("active") if obj.get("active") is not None else 0, + "failed": obj.get("failed") if obj.get("failed") is not None else 0, + "name": obj.get("name") if obj.get("name") is not None else '', + "ready": obj.get("ready") if obj.get("ready") is not None else 0, + "succeeded": obj.get("succeeded") if obj.get("succeeded") is not None else 0, + "suspended": obj.get("suspended") if obj.get("suspended") is not None else 0 + }) + return _obj - def __ne__(self, other): - """Returns true if both objects are not equal""" - if not isinstance(other, JobsetV1alpha2ReplicatedJobStatus): - return True - return self.to_dict() != other.to_dict() diff --git a/sdk/python/jobset/models/jobset_v1alpha2_startup_policy.py b/sdk/python/jobset/models/jobset_v1alpha2_startup_policy.py index f47e6daf4..0f2ab03e7 100644 --- a/sdk/python/jobset/models/jobset_v1alpha2_startup_policy.py +++ b/sdk/python/jobset/models/jobset_v1alpha2_startup_policy.py @@ -3,121 +3,85 @@ """ JobSet SDK - Python SDK for the JobSet API # noqa: E501 + Python SDK for the JobSet API The version of the OpenAPI document: v0.1.4 - Generated by: https://openapi-generator.tech -""" + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 +from __future__ import annotations import pprint import re # noqa: F401 +import json -import six +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self -from jobset.configuration import Configuration +class JobsetV1alpha2StartupPolicy(BaseModel): + """ + JobsetV1alpha2StartupPolicy + """ # noqa: E501 + startup_policy_order: StrictStr = Field(description="StartupPolicyOrder determines the startup order of the ReplicatedJobs. AnyOrder means to start replicated jobs in any order. InOrder means to start them as they are listed in the JobSet. A ReplicatedJob is started only when all the jobs of the previous one are ready.", alias="startupPolicyOrder") + __properties: ClassVar[List[str]] = ["startupPolicyOrder"] + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) -class JobsetV1alpha2StartupPolicy(object): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - Do not edit the class manually. - """ + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - """ - 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 = { - 'startup_policy_order': 'str' - } + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) - attribute_map = { - 'startup_policy_order': 'startupPolicyOrder' - } + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of JobsetV1alpha2StartupPolicy from a JSON string""" + return cls.from_dict(json.loads(json_str)) - def __init__(self, startup_policy_order='', local_vars_configuration=None): # noqa: E501 - """JobsetV1alpha2StartupPolicy - a model defined in OpenAPI""" # noqa: E501 - if local_vars_configuration is None: - local_vars_configuration = Configuration() - self.local_vars_configuration = local_vars_configuration + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. - self._startup_policy_order = None - self.discriminator = None + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: - self.startup_policy_order = startup_policy_order + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) - @property - def startup_policy_order(self): - """Gets the startup_policy_order of this JobsetV1alpha2StartupPolicy. # noqa: E501 + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict - StartupPolicyOrder determines the startup order of the ReplicatedJobs. AnyOrder means to start replicated jobs in any order. InOrder means to start them as they are listed in the JobSet. A ReplicatedJob is started only when all the jobs of the previous one are ready. # noqa: E501 + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of JobsetV1alpha2StartupPolicy from a dict""" + if obj is None: + return None - :return: The startup_policy_order of this JobsetV1alpha2StartupPolicy. # noqa: E501 - :rtype: str - """ - return self._startup_policy_order + if not isinstance(obj, dict): + return cls.model_validate(obj) - @startup_policy_order.setter - def startup_policy_order(self, startup_policy_order): - """Sets the startup_policy_order of this JobsetV1alpha2StartupPolicy. + _obj = cls.model_validate({ + "startupPolicyOrder": obj.get("startupPolicyOrder") if obj.get("startupPolicyOrder") is not None else '' + }) + return _obj - StartupPolicyOrder determines the startup order of the ReplicatedJobs. AnyOrder means to start replicated jobs in any order. InOrder means to start them as they are listed in the JobSet. A ReplicatedJob is started only when all the jobs of the previous one are ready. # noqa: E501 - :param startup_policy_order: The startup_policy_order of this JobsetV1alpha2StartupPolicy. # noqa: E501 - :type: str - """ - if self.local_vars_configuration.client_side_validation and startup_policy_order is None: # noqa: E501 - raise ValueError("Invalid value for `startup_policy_order`, must not be `None`") # noqa: E501 - - self._startup_policy_order = startup_policy_order - - 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, JobsetV1alpha2StartupPolicy): - 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, JobsetV1alpha2StartupPolicy): - return True - - return self.to_dict() != other.to_dict() diff --git a/sdk/python/jobset/models/jobset_v1alpha2_success_policy.py b/sdk/python/jobset/models/jobset_v1alpha2_success_policy.py index 350238fd2..fd74815ae 100644 --- a/sdk/python/jobset/models/jobset_v1alpha2_success_policy.py +++ b/sdk/python/jobset/models/jobset_v1alpha2_success_policy.py @@ -3,149 +3,87 @@ """ JobSet SDK - Python SDK for the JobSet API # noqa: E501 + Python SDK for the JobSet API The version of the OpenAPI document: v0.1.4 - Generated by: https://openapi-generator.tech -""" + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 +from __future__ import annotations import pprint import re # noqa: F401 +import json -import six - -from jobset.configuration import Configuration - - -class JobsetV1alpha2SuccessPolicy(object): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self +class JobsetV1alpha2SuccessPolicy(BaseModel): """ - 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 = { - 'operator': 'str', - 'target_replicated_jobs': 'list[str]' - } - - attribute_map = { - 'operator': 'operator', - 'target_replicated_jobs': 'targetReplicatedJobs' - } - - def __init__(self, operator='', target_replicated_jobs=None, local_vars_configuration=None): # noqa: E501 - """JobsetV1alpha2SuccessPolicy - 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._operator = None - self._target_replicated_jobs = None - self.discriminator = None - - self.operator = operator - if target_replicated_jobs is not None: - self.target_replicated_jobs = target_replicated_jobs - - @property - def operator(self): - """Gets the operator of this JobsetV1alpha2SuccessPolicy. # noqa: E501 - - Operator determines either All or Any of the selected jobs should succeed to consider the JobSet successful # noqa: E501 - - :return: The operator of this JobsetV1alpha2SuccessPolicy. # noqa: E501 - :rtype: str + JobsetV1alpha2SuccessPolicy + """ # noqa: E501 + operator: StrictStr = Field(description="Operator determines either All or Any of the selected jobs should succeed to consider the JobSet successful") + target_replicated_jobs: Optional[List[StrictStr]] = Field(default=None, description="TargetReplicatedJobs are the names of the replicated jobs the operator will apply to. A null or empty list will apply to all replicatedJobs.", alias="targetReplicatedJobs") + __properties: ClassVar[List[str]] = ["operator", "targetReplicatedJobs"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of JobsetV1alpha2SuccessPolicy from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. """ - return self._operator - - @operator.setter - def operator(self, operator): - """Sets the operator of this JobsetV1alpha2SuccessPolicy. + excluded_fields: Set[str] = set([ + ]) - Operator determines either All or Any of the selected jobs should succeed to consider the JobSet successful # noqa: E501 + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict - :param operator: The operator of this JobsetV1alpha2SuccessPolicy. # noqa: E501 - :type: str - """ - if self.local_vars_configuration.client_side_validation and operator is None: # noqa: E501 - raise ValueError("Invalid value for `operator`, must not be `None`") # noqa: E501 + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of JobsetV1alpha2SuccessPolicy from a dict""" + if obj is None: + return None - self._operator = operator + if not isinstance(obj, dict): + return cls.model_validate(obj) - @property - def target_replicated_jobs(self): - """Gets the target_replicated_jobs of this JobsetV1alpha2SuccessPolicy. # noqa: E501 + _obj = cls.model_validate({ + "operator": obj.get("operator") if obj.get("operator") is not None else '', + "targetReplicatedJobs": obj.get("targetReplicatedJobs") + }) + return _obj - TargetReplicatedJobs are the names of the replicated jobs the operator will apply to. A null or empty list will apply to all replicatedJobs. # noqa: E501 - - :return: The target_replicated_jobs of this JobsetV1alpha2SuccessPolicy. # noqa: E501 - :rtype: list[str] - """ - return self._target_replicated_jobs - - @target_replicated_jobs.setter - def target_replicated_jobs(self, target_replicated_jobs): - """Sets the target_replicated_jobs of this JobsetV1alpha2SuccessPolicy. - - TargetReplicatedJobs are the names of the replicated jobs the operator will apply to. A null or empty list will apply to all replicatedJobs. # noqa: E501 - - :param target_replicated_jobs: The target_replicated_jobs of this JobsetV1alpha2SuccessPolicy. # noqa: E501 - :type: list[str] - """ - self._target_replicated_jobs = target_replicated_jobs - - 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, JobsetV1alpha2SuccessPolicy): - 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, JobsetV1alpha2SuccessPolicy): - return True - - return self.to_dict() != other.to_dict() diff --git a/sdk/python/jobset/py.typed b/sdk/python/jobset/py.typed new file mode 100644 index 000000000..e69de29bb diff --git a/sdk/python/jobset/rest.py b/sdk/python/jobset/rest.py index 02ed07cae..162618bd6 100644 --- a/sdk/python/jobset/rest.py +++ b/sdk/python/jobset/rest.py @@ -3,57 +3,66 @@ """ JobSet SDK - Python SDK for the JobSet API # noqa: E501 + Python SDK for the JobSet API The version of the OpenAPI document: v0.1.4 - Generated by: https://openapi-generator.tech -""" + Generated by OpenAPI Generator (https://openapi-generator.tech) + Do not edit the class manually. +""" # noqa: E501 -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 jobset.exceptions import ApiException, ApiValueError +SUPPORTED_SOCKS_PROXIES = {"socks5", "socks5h", "socks4", "socks4a"} +RESTResponseType = urllib3.HTTPResponse + -logger = logging.getLogger(__name__) +def is_socks_proxy_url(url): + if url is None: + return False + split_section = url.split("://") + if len(split_section) < 2: + return False + else: + return split_section[0].lower() in SUPPORTED_SOCKS_PROXIES class RESTResponse(io.IOBase): - def __init__(self, resp): - self.urllib3_response = resp + def __init__(self, resp) -> None: + self.response = resp self.status = resp.status self.reason = resp.reason - self.data = resp.data + self.data = None + + def read(self): + if self.data is None: + self.data = self.response.data + return self.data def getheaders(self): """Returns a dictionary of the response headers.""" - return self.urllib3_response.getheaders() + return self.response.headers def getheader(self, name, default=None): """Returns a given response header.""" - return self.urllib3_response.getheader(name, default) + return self.response.headers.get(name, default) -class RESTClientObject(object): +class RESTClientObject: - def __init__(self, configuration, pools_size=4, maxsize=None): + def __init__(self, configuration) -> 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 @@ -62,74 +71,79 @@ def __init__(self, configuration, pools_size=4, maxsize=None): 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 = {} + pool_args = { + "cert_reqs": cert_reqs, + "ca_certs": configuration.ssl_ca_cert, + "cert_file": configuration.cert_file, + "key_file": configuration.key_file, + } if configuration.assert_hostname is not None: - addition_pool_args['assert_hostname'] = configuration.assert_hostname # noqa: E501 + pool_args['assert_hostname'] = ( + configuration.assert_hostname + ) if configuration.retries is not None: - addition_pool_args['retries'] = configuration.retries + 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 + if configuration.tls_server_name: + pool_args['server_hostname'] = configuration.tls_server_name + + + if configuration.socket_options is not None: + pool_args['socket_options'] = configuration.socket_options + + if configuration.connection_pool_maxsize is not None: + pool_args['maxsize'] = configuration.connection_pool_maxsize # https pool manager + self.pool_manager: urllib3.PoolManager + 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 - ) + if is_socks_proxy_url(configuration.proxy): + from urllib3.contrib.socks import SOCKSProxyManager + pool_args["proxy_url"] = configuration.proxy + pool_args["headers"] = configuration.proxy_headers + self.pool_manager = SOCKSProxyManager(**pool_args) + else: + pool_args["proxy_url"] = configuration.proxy + pool_args["proxy_headers"] = configuration.proxy_headers + self.pool_manager = urllib3.ProxyManager(**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): + self.pool_manager = urllib3.PoolManager(**pool_args) + + def request( + self, + method, + url, + headers=None, + body=None, + post_params=None, + _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'] + assert method in [ + 'GET', + 'HEAD', + 'DELETE', + 'POST', + 'PUT', + 'PATCH', + 'OPTIONS' + ] if post_params and body: raise ApiValueError( @@ -141,60 +155,83 @@ def request(self, method, url, query_params=None, headers=None, timeout = None if _request_timeout: - if isinstance(_request_timeout, (int, ) if six.PY3 else (int, long)): # noqa: E501,F821 + if isinstance(_request_timeout, (int, float)): timeout = urllib3.Timeout(total=_request_timeout) - elif (isinstance(_request_timeout, tuple) and - len(_request_timeout) == 2): + 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' + connect=_request_timeout[0], + read=_request_timeout[1] + ) 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): + + # no content type provided or payload is json + content_type = headers.get('Content-Type') + if ( + not content_type + or re.search('json', content_type, re.IGNORECASE) + ): request_body = None if body is not None: request_body = json.dumps(body) r = self.pool_manager.request( - method, url, + method, + url, body=request_body, - preload_content=_preload_content, timeout=timeout, - headers=headers) - elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501 + headers=headers, + preload_content=False + ) + elif content_type == 'application/x-www-form-urlencoded': r = self.pool_manager.request( - method, url, + method, + url, fields=post_params, encode_multipart=False, - preload_content=_preload_content, timeout=timeout, - headers=headers) - elif headers['Content-Type'] == 'multipart/form-data': + headers=headers, + preload_content=False + ) + elif 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'] + # Ensures that dict objects are serialized + post_params = [(a, json.dumps(b)) if isinstance(b, dict) else (a,b) for a, b in post_params] r = self.pool_manager.request( - method, url, + method, + url, fields=post_params, encode_multipart=True, - preload_content=_preload_content, timeout=timeout, - headers=headers) + headers=headers, + preload_content=False + ) # Pass a `string` parameter directly in the body to support - # other content types than Json when `body` argument is - # provided in serialized form + # 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, + method, + url, + body=body, + timeout=timeout, + headers=headers, + preload_content=False + ) + elif headers['Content-Type'] == 'text/plain' and isinstance(body, bool): + request_body = "true" if body else "false" + r = self.pool_manager.request( + method, + url, body=request_body, - preload_content=_preload_content, + preload_content=False, timeout=timeout, headers=headers) else: @@ -205,87 +242,16 @@ def request(self, method, url, query_params=None, headers=None, 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) + r = self.pool_manager.request( + method, + url, + fields={}, + timeout=timeout, + headers=headers, + preload_content=False + ) except urllib3.exceptions.SSLError as e: - msg = "{0}\n{1}".format(type(e).__name__, str(e)) + msg = "\n".join([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) + return RESTResponse(r) diff --git a/sdk/python/pyproject.toml b/sdk/python/pyproject.toml index 921aa1047..9c5188d42 100644 --- a/sdk/python/pyproject.toml +++ b/sdk/python/pyproject.toml @@ -1,27 +1,71 @@ +[tool.poetry] +name = "jobset" +version = "0.1.4" +description = "JobSet SDK" +authors = ["OpenAPI Generator Community "] +license = "NoLicense" +readme = "README.md" +repository = "https://github.com/GIT_USER_ID/GIT_REPO_ID" +keywords = ["OpenAPI", "OpenAPI-Generator", "JobSet SDK"] +include = ["jobset/py.typed"] + +[tool.poetry.dependencies] +python = "^3.8" + +urllib3 = ">= 1.25.3" +python-dateutil = ">=2.8.2" +pydantic = ">=2" +typing-extensions = ">=4.7.1" + +[tool.poetry.dev-dependencies] +pytest = ">=7.2.1" +tox = ">=3.9.0" +flake8 = ">=4.0.0" +types-python-dateutil = ">=2.8.19.14" +mypy = ">=1.5" + + [build-system] -requires = ["setuptools", "setuptools-scm"] +requires = ["setuptools"] build-backend = "setuptools.build_meta" -[project] -name = "jobset" -version = "0.2.0" -authors = [ - {name = "Kubernetes"}, -] -description = "JobSet represents distributed jobs for ML/AI/HPC applications" -requires-python = ">=3.7" -readme = "README.md" -license = {text = "Apache"} -dependencies = [ - "certifi >= 14.05.14", - "six >= 1.10", - "python_dateutil >= 2.5.3", - "setuptools >= 21.0.0", - "urllib3 >= 1.15.1", - "kubernetes", +[tool.pylint.'MESSAGES CONTROL'] +extension-pkg-whitelist = "pydantic" + +[tool.mypy] +files = [ + "jobset", + #"test", # auto-generated tests + "tests", # hand-written tests ] -[project.optional-dependencies] -test = ["pytest>=6.2.5", "pytest-cov>=2.8.1", "pytest-randomly==1.2.3"] +# TODO: enable "strict" once all these individual checks are passing +# strict = true + +# List from: https://mypy.readthedocs.io/en/stable/existing_code.html#introduce-stricter-options +warn_unused_configs = true +warn_redundant_casts = true +warn_unused_ignores = true + +## Getting these passing should be easy +strict_equality = true +strict_concatenate = true + +## Strongly recommend enabling this one as soon as you can +check_untyped_defs = true + +## These shouldn't be too much additional work, but may be tricky to +## get passing if you use a lot of untyped libraries +disallow_subclassing_any = true +disallow_untyped_decorators = true +disallow_any_generics = true -[tool.setuptools] -packages = ["jobset", "jobset.api", "jobset.models"] \ No newline at end of file +### These next few are various gradations of forcing use of type annotations +#disallow_untyped_calls = true +#disallow_incomplete_defs = true +#disallow_untyped_defs = true +# +### This one isn't too hard to get passing, but return on investment is lower +#no_implicit_reexport = true +# +### This one can be tricky to get passing if you use a lot of untyped libraries +#warn_return_any = true diff --git a/sdk/python/requirements.txt b/sdk/python/requirements.txt index eb358efd5..7d45544de 100644 --- a/sdk/python/requirements.txt +++ b/sdk/python/requirements.txt @@ -1,6 +1,5 @@ -certifi >= 14.05.14 -future; python_version<="2.7" -six >= 1.10 python_dateutil >= 2.5.3 setuptools >= 21.0.0 -urllib3 >= 1.15.1 +urllib3 >= 1.25.3, < 3.0.0 +pydantic >= 2 +typing-extensions >= 4.7.1 diff --git a/sdk/python/test-requirements.txt b/sdk/python/test-requirements.txt index 091fa58b0..1f7f2ae43 100644 --- a/sdk/python/test-requirements.txt +++ b/sdk/python/test-requirements.txt @@ -1,4 +1,6 @@ kubernetes pytest>=6.2.5 pytest-cov>=2.8.1 -pytest-randomly==1.2.3 # needed for python 2.7+3.4 +pytest-randomly>=3.12.0 +mypy>=1.4.1 +types-python-dateutil>=2.8.19 diff --git a/sdk/python/test/test_jobset_v1alpha2_coordinator.py b/sdk/python/test/test_jobset_v1alpha2_coordinator.py index 7aae08bd4..4ebc195ea 100644 --- a/sdk/python/test/test_jobset_v1alpha2_coordinator.py +++ b/sdk/python/test/test_jobset_v1alpha2_coordinator.py @@ -3,23 +3,18 @@ """ JobSet SDK - Python SDK for the JobSet API # noqa: E501 + Python SDK for the JobSet API The version of the OpenAPI document: v0.1.4 - Generated by: https://openapi-generator.tech -""" + Generated by OpenAPI Generator (https://openapi-generator.tech) + Do not edit the class manually. +""" # noqa: E501 -from __future__ import absolute_import -# Kubernetes imports -from kubernetes.client.models.v1_job_template_spec import V1JobTemplateSpec import unittest -import datetime -import jobset -from jobset.models.jobset_v1alpha2_coordinator import JobsetV1alpha2Coordinator # noqa: E501 -from jobset.rest import ApiException +from jobset.models.jobset_v1alpha2_coordinator import JobsetV1alpha2Coordinator class TestJobsetV1alpha2Coordinator(unittest.TestCase): """JobsetV1alpha2Coordinator unit test stubs""" @@ -30,28 +25,30 @@ def setUp(self): def tearDown(self): pass - def make_instance(self, include_optional): + def make_instance(self, include_optional) -> JobsetV1alpha2Coordinator: """Test JobsetV1alpha2Coordinator - include_option is a boolean, when False only required + include_optional is a boolean, when False only required params are included, when True both required and optional params are included """ - # model = jobset.models.jobset_v1alpha2_coordinator.JobsetV1alpha2Coordinator() # noqa: E501 - if include_optional : + # uncomment below to create an instance of `JobsetV1alpha2Coordinator` + """ + model = JobsetV1alpha2Coordinator() + if include_optional: return JobsetV1alpha2Coordinator( - job_index = 56, - pod_index = 56, - replicated_job = '0' + job_index = 56, + pod_index = 56, + replicated_job = '' ) - else : + else: return JobsetV1alpha2Coordinator( - replicated_job = '0', + replicated_job = '', ) + """ def testJobsetV1alpha2Coordinator(self): """Test JobsetV1alpha2Coordinator""" - inst_req_only = self.make_instance(include_optional=False) - inst_req_and_optional = self.make_instance(include_optional=True) - + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) if __name__ == '__main__': unittest.main() diff --git a/sdk/python/test/test_jobset_v1alpha2_failure_policy.py b/sdk/python/test/test_jobset_v1alpha2_failure_policy.py index 72e216715..3af6212dc 100644 --- a/sdk/python/test/test_jobset_v1alpha2_failure_policy.py +++ b/sdk/python/test/test_jobset_v1alpha2_failure_policy.py @@ -3,23 +3,18 @@ """ JobSet SDK - Python SDK for the JobSet API # noqa: E501 + Python SDK for the JobSet API The version of the OpenAPI document: v0.1.4 - Generated by: https://openapi-generator.tech -""" + Generated by OpenAPI Generator (https://openapi-generator.tech) + Do not edit the class manually. +""" # noqa: E501 -from __future__ import absolute_import -# Kubernetes imports -from kubernetes.client.models.v1_job_template_spec import V1JobTemplateSpec import unittest -import datetime -import jobset -from jobset.models.jobset_v1alpha2_failure_policy import JobsetV1alpha2FailurePolicy # noqa: E501 -from jobset.rest import ApiException +from jobset.models.jobset_v1alpha2_failure_policy import JobsetV1alpha2FailurePolicy class TestJobsetV1alpha2FailurePolicy(unittest.TestCase): """JobsetV1alpha2FailurePolicy unit test stubs""" @@ -30,36 +25,38 @@ def setUp(self): def tearDown(self): pass - def make_instance(self, include_optional): + def make_instance(self, include_optional) -> JobsetV1alpha2FailurePolicy: """Test JobsetV1alpha2FailurePolicy - include_option is a boolean, when False only required + include_optional is a boolean, when False only required params are included, when True both required and optional params are included """ - # model = jobset.models.jobset_v1alpha2_failure_policy.JobsetV1alpha2FailurePolicy() # noqa: E501 - if include_optional : + # uncomment below to create an instance of `JobsetV1alpha2FailurePolicy` + """ + model = JobsetV1alpha2FailurePolicy() + if include_optional: return JobsetV1alpha2FailurePolicy( - max_restarts = 56, + max_restarts = 56, rules = [ jobset.models.jobset_v1alpha2_failure_policy_rule.JobsetV1alpha2FailurePolicyRule( - action = '0', - name = '0', + action = '', + name = '', on_job_failure_reasons = [ - '0' + '' ], target_replicated_jobs = [ - '0' + '' ], ) ] ) - else : + else: return JobsetV1alpha2FailurePolicy( ) + """ def testJobsetV1alpha2FailurePolicy(self): """Test JobsetV1alpha2FailurePolicy""" - inst_req_only = self.make_instance(include_optional=False) - inst_req_and_optional = self.make_instance(include_optional=True) - + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) if __name__ == '__main__': unittest.main() diff --git a/sdk/python/test/test_jobset_v1alpha2_failure_policy_rule.py b/sdk/python/test/test_jobset_v1alpha2_failure_policy_rule.py index fe706e322..42e3ac991 100644 --- a/sdk/python/test/test_jobset_v1alpha2_failure_policy_rule.py +++ b/sdk/python/test/test_jobset_v1alpha2_failure_policy_rule.py @@ -3,23 +3,18 @@ """ JobSet SDK - Python SDK for the JobSet API # noqa: E501 + Python SDK for the JobSet API The version of the OpenAPI document: v0.1.4 - Generated by: https://openapi-generator.tech -""" + Generated by OpenAPI Generator (https://openapi-generator.tech) + Do not edit the class manually. +""" # noqa: E501 -from __future__ import absolute_import -# Kubernetes imports -from kubernetes.client.models.v1_job_template_spec import V1JobTemplateSpec import unittest -import datetime -import jobset -from jobset.models.jobset_v1alpha2_failure_policy_rule import JobsetV1alpha2FailurePolicyRule # noqa: E501 -from jobset.rest import ApiException +from jobset.models.jobset_v1alpha2_failure_policy_rule import JobsetV1alpha2FailurePolicyRule class TestJobsetV1alpha2FailurePolicyRule(unittest.TestCase): """JobsetV1alpha2FailurePolicyRule unit test stubs""" @@ -30,34 +25,36 @@ def setUp(self): def tearDown(self): pass - def make_instance(self, include_optional): + def make_instance(self, include_optional) -> JobsetV1alpha2FailurePolicyRule: """Test JobsetV1alpha2FailurePolicyRule - include_option is a boolean, when False only required + include_optional is a boolean, when False only required params are included, when True both required and optional params are included """ - # model = jobset.models.jobset_v1alpha2_failure_policy_rule.JobsetV1alpha2FailurePolicyRule() # noqa: E501 - if include_optional : + # uncomment below to create an instance of `JobsetV1alpha2FailurePolicyRule` + """ + model = JobsetV1alpha2FailurePolicyRule() + if include_optional: return JobsetV1alpha2FailurePolicyRule( - action = '0', - name = '0', + action = '', + name = '', on_job_failure_reasons = [ - '0' - ], + '' + ], target_replicated_jobs = [ - '0' + '' ] ) - else : + else: return JobsetV1alpha2FailurePolicyRule( - action = '0', - name = '0', + action = '', + name = '', ) + """ def testJobsetV1alpha2FailurePolicyRule(self): """Test JobsetV1alpha2FailurePolicyRule""" - inst_req_only = self.make_instance(include_optional=False) - inst_req_and_optional = self.make_instance(include_optional=True) - + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) if __name__ == '__main__': unittest.main() diff --git a/sdk/python/test/test_jobset_v1alpha2_job_set.py b/sdk/python/test/test_jobset_v1alpha2_job_set.py index cd37d0dfd..577528d7c 100644 --- a/sdk/python/test/test_jobset_v1alpha2_job_set.py +++ b/sdk/python/test/test_jobset_v1alpha2_job_set.py @@ -3,23 +3,18 @@ """ JobSet SDK - Python SDK for the JobSet API # noqa: E501 + Python SDK for the JobSet API The version of the OpenAPI document: v0.1.4 - Generated by: https://openapi-generator.tech -""" + Generated by OpenAPI Generator (https://openapi-generator.tech) + Do not edit the class manually. +""" # noqa: E501 -from __future__ import absolute_import -# Kubernetes imports -from kubernetes.client.models.v1_job_template_spec import V1JobTemplateSpec import unittest -import datetime -import jobset -from jobset.models.jobset_v1alpha2_job_set import JobsetV1alpha2JobSet # noqa: E501 -from jobset.rest import ApiException +from jobset.models.jobset_v1alpha2_job_set import JobsetV1alpha2JobSet class TestJobsetV1alpha2JobSet(unittest.TestCase): """JobsetV1alpha2JobSet unit test stubs""" @@ -30,52 +25,54 @@ def setUp(self): def tearDown(self): pass - def make_instance(self, include_optional): + def make_instance(self, include_optional) -> JobsetV1alpha2JobSet: """Test JobsetV1alpha2JobSet - include_option is a boolean, when False only required + include_optional is a boolean, when False only required params are included, when True both required and optional params are included """ - # model = jobset.models.jobset_v1alpha2_job_set.JobsetV1alpha2JobSet() # noqa: E501 - if include_optional : + # uncomment below to create an instance of `JobsetV1alpha2JobSet` + """ + model = JobsetV1alpha2JobSet() + if include_optional: return JobsetV1alpha2JobSet( - api_version = '0', - kind = '0', - metadata = None, + api_version = '', + kind = '', + metadata = None, spec = jobset.models.jobset_v1alpha2_job_set_spec.JobsetV1alpha2JobSetSpec( coordinator = jobset.models.jobset_v1alpha2_coordinator.JobsetV1alpha2Coordinator( job_index = 56, pod_index = 56, - replicated_job = '0', ), + replicated_job = '', ), failure_policy = jobset.models.jobset_v1alpha2_failure_policy.JobsetV1alpha2FailurePolicy( max_restarts = 56, rules = [ jobset.models.jobset_v1alpha2_failure_policy_rule.JobsetV1alpha2FailurePolicyRule( - action = '0', - name = '0', + action = '', + name = '', on_job_failure_reasons = [ - '0' + '' ], target_replicated_jobs = [ - '0' + '' ], ) ], ), - managed_by = '0', + managed_by = '', network = jobset.models.jobset_v1alpha2_network.JobsetV1alpha2Network( enable_dns_hostnames = True, publish_not_ready_addresses = True, - subdomain = '0', ), + subdomain = '', ), replicated_jobs = [ jobset.models.jobset_v1alpha2_replicated_job.JobsetV1alpha2ReplicatedJob( - name = '0', + name = '', replicas = 56, template = V1JobTemplateSpec(), ) ], startup_policy = jobset.models.jobset_v1alpha2_startup_policy.JobsetV1alpha2StartupPolicy( - startup_policy_order = '0', ), + startup_policy_order = '', ), success_policy = jobset.models.jobset_v1alpha2_success_policy.JobsetV1alpha2SuccessPolicy( - operator = '0', ), + operator = '', ), suspend = True, - ttl_seconds_after_finished = 56, ), + ttl_seconds_after_finished = 56, ), status = jobset.models.jobset_v1alpha2_job_set_status.JobsetV1alpha2JobSetStatus( conditions = [ None @@ -84,24 +81,24 @@ def make_instance(self, include_optional): jobset.models.jobset_v1alpha2_replicated_job_status.JobsetV1alpha2ReplicatedJobStatus( active = 56, failed = 56, - name = '0', + name = '', ready = 56, succeeded = 56, suspended = 56, ) ], restarts = 56, restarts_count_towards_max = 56, - terminal_state = '0', ) + terminal_state = '', ) ) - else : + else: return JobsetV1alpha2JobSet( ) + """ def testJobsetV1alpha2JobSet(self): """Test JobsetV1alpha2JobSet""" - inst_req_only = self.make_instance(include_optional=False) - inst_req_and_optional = self.make_instance(include_optional=True) - + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) if __name__ == '__main__': unittest.main() diff --git a/sdk/python/test/test_jobset_v1alpha2_job_set_list.py b/sdk/python/test/test_jobset_v1alpha2_job_set_list.py index 30c1eb8de..915b9124a 100644 --- a/sdk/python/test/test_jobset_v1alpha2_job_set_list.py +++ b/sdk/python/test/test_jobset_v1alpha2_job_set_list.py @@ -3,23 +3,18 @@ """ JobSet SDK - Python SDK for the JobSet API # noqa: E501 + Python SDK for the JobSet API The version of the OpenAPI document: v0.1.4 - Generated by: https://openapi-generator.tech -""" + Generated by OpenAPI Generator (https://openapi-generator.tech) + Do not edit the class manually. +""" # noqa: E501 -from __future__ import absolute_import -# Kubernetes imports -from kubernetes.client.models.v1_job_template_spec import V1JobTemplateSpec import unittest -import datetime -import jobset -from jobset.models.jobset_v1alpha2_job_set_list import JobsetV1alpha2JobSetList # noqa: E501 -from jobset.rest import ApiException +from jobset.models.jobset_v1alpha2_job_set_list import JobsetV1alpha2JobSetList class TestJobsetV1alpha2JobSetList(unittest.TestCase): """JobsetV1alpha2JobSetList unit test stubs""" @@ -30,53 +25,55 @@ def setUp(self): def tearDown(self): pass - def make_instance(self, include_optional): + def make_instance(self, include_optional) -> JobsetV1alpha2JobSetList: """Test JobsetV1alpha2JobSetList - include_option is a boolean, when False only required + include_optional is a boolean, when False only required params are included, when True both required and optional params are included """ - # model = jobset.models.jobset_v1alpha2_job_set_list.JobsetV1alpha2JobSetList() # noqa: E501 - if include_optional : + # uncomment below to create an instance of `JobsetV1alpha2JobSetList` + """ + model = JobsetV1alpha2JobSetList() + if include_optional: return JobsetV1alpha2JobSetList( - api_version = '0', + api_version = '', items = [ jobset.models.jobset_v1alpha2_job_set.JobsetV1alpha2JobSet( - api_version = '0', - kind = '0', + api_version = '', + kind = '', metadata = None, spec = jobset.models.jobset_v1alpha2_job_set_spec.JobsetV1alpha2JobSetSpec( coordinator = jobset.models.jobset_v1alpha2_coordinator.JobsetV1alpha2Coordinator( job_index = 56, pod_index = 56, - replicated_job = '0', ), + replicated_job = '', ), failure_policy = jobset.models.jobset_v1alpha2_failure_policy.JobsetV1alpha2FailurePolicy( max_restarts = 56, rules = [ jobset.models.jobset_v1alpha2_failure_policy_rule.JobsetV1alpha2FailurePolicyRule( - action = '0', - name = '0', + action = '', + name = '', on_job_failure_reasons = [ - '0' + '' ], target_replicated_jobs = [ - '0' + '' ], ) ], ), - managed_by = '0', + managed_by = '', network = jobset.models.jobset_v1alpha2_network.JobsetV1alpha2Network( enable_dns_hostnames = True, publish_not_ready_addresses = True, - subdomain = '0', ), + subdomain = '', ), replicated_jobs = [ jobset.models.jobset_v1alpha2_replicated_job.JobsetV1alpha2ReplicatedJob( - name = '0', + name = '', replicas = 56, template = V1JobTemplateSpec(), ) ], startup_policy = jobset.models.jobset_v1alpha2_startup_policy.JobsetV1alpha2StartupPolicy( - startup_policy_order = '0', ), + startup_policy_order = '', ), success_policy = jobset.models.jobset_v1alpha2_success_policy.JobsetV1alpha2SuccessPolicy( - operator = '0', ), + operator = '', ), suspend = True, ttl_seconds_after_finished = 56, ), status = jobset.models.jobset_v1alpha2_job_set_status.JobsetV1alpha2JobSetStatus( @@ -87,58 +84,58 @@ def make_instance(self, include_optional): jobset.models.jobset_v1alpha2_replicated_job_status.JobsetV1alpha2ReplicatedJobStatus( active = 56, failed = 56, - name = '0', + name = '', ready = 56, succeeded = 56, suspended = 56, ) ], restarts = 56, restarts_count_towards_max = 56, - terminal_state = '0', ), ) - ], - kind = '0', + terminal_state = '', ), ) + ], + kind = '', metadata = None ) - else : + else: return JobsetV1alpha2JobSetList( items = [ jobset.models.jobset_v1alpha2_job_set.JobsetV1alpha2JobSet( - api_version = '0', - kind = '0', + api_version = '', + kind = '', metadata = None, spec = jobset.models.jobset_v1alpha2_job_set_spec.JobsetV1alpha2JobSetSpec( coordinator = jobset.models.jobset_v1alpha2_coordinator.JobsetV1alpha2Coordinator( job_index = 56, pod_index = 56, - replicated_job = '0', ), + replicated_job = '', ), failure_policy = jobset.models.jobset_v1alpha2_failure_policy.JobsetV1alpha2FailurePolicy( max_restarts = 56, rules = [ jobset.models.jobset_v1alpha2_failure_policy_rule.JobsetV1alpha2FailurePolicyRule( - action = '0', - name = '0', + action = '', + name = '', on_job_failure_reasons = [ - '0' + '' ], target_replicated_jobs = [ - '0' + '' ], ) ], ), - managed_by = '0', + managed_by = '', network = jobset.models.jobset_v1alpha2_network.JobsetV1alpha2Network( enable_dns_hostnames = True, publish_not_ready_addresses = True, - subdomain = '0', ), + subdomain = '', ), replicated_jobs = [ jobset.models.jobset_v1alpha2_replicated_job.JobsetV1alpha2ReplicatedJob( - name = '0', + name = '', replicas = 56, template = V1JobTemplateSpec(), ) ], startup_policy = jobset.models.jobset_v1alpha2_startup_policy.JobsetV1alpha2StartupPolicy( - startup_policy_order = '0', ), + startup_policy_order = '', ), success_policy = jobset.models.jobset_v1alpha2_success_policy.JobsetV1alpha2SuccessPolicy( - operator = '0', ), + operator = '', ), suspend = True, ttl_seconds_after_finished = 56, ), status = jobset.models.jobset_v1alpha2_job_set_status.JobsetV1alpha2JobSetStatus( @@ -149,22 +146,22 @@ def make_instance(self, include_optional): jobset.models.jobset_v1alpha2_replicated_job_status.JobsetV1alpha2ReplicatedJobStatus( active = 56, failed = 56, - name = '0', + name = '', ready = 56, succeeded = 56, suspended = 56, ) ], restarts = 56, restarts_count_towards_max = 56, - terminal_state = '0', ), ) + terminal_state = '', ), ) ], ) + """ def testJobsetV1alpha2JobSetList(self): """Test JobsetV1alpha2JobSetList""" - inst_req_only = self.make_instance(include_optional=False) - inst_req_and_optional = self.make_instance(include_optional=True) - + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) if __name__ == '__main__': unittest.main() diff --git a/sdk/python/test/test_jobset_v1alpha2_job_set_spec.py b/sdk/python/test/test_jobset_v1alpha2_job_set_spec.py index 35bf8cabf..f3f8a40a8 100644 --- a/sdk/python/test/test_jobset_v1alpha2_job_set_spec.py +++ b/sdk/python/test/test_jobset_v1alpha2_job_set_spec.py @@ -3,23 +3,18 @@ """ JobSet SDK - Python SDK for the JobSet API # noqa: E501 + Python SDK for the JobSet API The version of the OpenAPI document: v0.1.4 - Generated by: https://openapi-generator.tech -""" + Generated by OpenAPI Generator (https://openapi-generator.tech) + Do not edit the class manually. +""" # noqa: E501 -from __future__ import absolute_import -# Kubernetes imports -from kubernetes.client.models.v1_job_template_spec import V1JobTemplateSpec import unittest -import datetime -import jobset -from jobset.models.jobset_v1alpha2_job_set_spec import JobsetV1alpha2JobSetSpec # noqa: E501 -from jobset.rest import ApiException +from jobset.models.jobset_v1alpha2_job_set_spec import JobsetV1alpha2JobSetSpec class TestJobsetV1alpha2JobSetSpec(unittest.TestCase): """JobsetV1alpha2JobSetSpec unit test stubs""" @@ -30,61 +25,63 @@ def setUp(self): def tearDown(self): pass - def make_instance(self, include_optional): + def make_instance(self, include_optional) -> JobsetV1alpha2JobSetSpec: """Test JobsetV1alpha2JobSetSpec - include_option is a boolean, when False only required + include_optional is a boolean, when False only required params are included, when True both required and optional params are included """ - # model = jobset.models.jobset_v1alpha2_job_set_spec.JobsetV1alpha2JobSetSpec() # noqa: E501 - if include_optional : + # uncomment below to create an instance of `JobsetV1alpha2JobSetSpec` + """ + model = JobsetV1alpha2JobSetSpec() + if include_optional: return JobsetV1alpha2JobSetSpec( coordinator = jobset.models.jobset_v1alpha2_coordinator.JobsetV1alpha2Coordinator( job_index = 56, pod_index = 56, - replicated_job = '0', ), + replicated_job = '', ), failure_policy = jobset.models.jobset_v1alpha2_failure_policy.JobsetV1alpha2FailurePolicy( max_restarts = 56, rules = [ jobset.models.jobset_v1alpha2_failure_policy_rule.JobsetV1alpha2FailurePolicyRule( - action = '0', - name = '0', + action = '', + name = '', on_job_failure_reasons = [ - '0' + '' ], target_replicated_jobs = [ - '0' + '' ], ) - ], ), - managed_by = '0', + ], ), + managed_by = '', network = jobset.models.jobset_v1alpha2_network.JobsetV1alpha2Network( enable_dns_hostnames = True, publish_not_ready_addresses = True, - subdomain = '0', ), + subdomain = '', ), replicated_jobs = [ jobset.models.jobset_v1alpha2_replicated_job.JobsetV1alpha2ReplicatedJob( - name = '0', + name = '', replicas = 56, template = V1JobTemplateSpec(), ) - ], + ], startup_policy = jobset.models.jobset_v1alpha2_startup_policy.JobsetV1alpha2StartupPolicy( - startup_policy_order = '0', ), + startup_policy_order = '', ), success_policy = jobset.models.jobset_v1alpha2_success_policy.JobsetV1alpha2SuccessPolicy( - operator = '0', + operator = '', target_replicated_jobs = [ - '0' - ], ), - suspend = True, + '' + ], ), + suspend = True, ttl_seconds_after_finished = 56 ) - else : + else: return JobsetV1alpha2JobSetSpec( ) + """ def testJobsetV1alpha2JobSetSpec(self): """Test JobsetV1alpha2JobSetSpec""" - inst_req_only = self.make_instance(include_optional=False) - inst_req_and_optional = self.make_instance(include_optional=True) - + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) if __name__ == '__main__': unittest.main() diff --git a/sdk/python/test/test_jobset_v1alpha2_job_set_status.py b/sdk/python/test/test_jobset_v1alpha2_job_set_status.py index 345a5b083..c80e1eda7 100644 --- a/sdk/python/test/test_jobset_v1alpha2_job_set_status.py +++ b/sdk/python/test/test_jobset_v1alpha2_job_set_status.py @@ -3,23 +3,18 @@ """ JobSet SDK - Python SDK for the JobSet API # noqa: E501 + Python SDK for the JobSet API The version of the OpenAPI document: v0.1.4 - Generated by: https://openapi-generator.tech -""" + Generated by OpenAPI Generator (https://openapi-generator.tech) + Do not edit the class manually. +""" # noqa: E501 -from __future__ import absolute_import -# Kubernetes imports -from kubernetes.client.models.v1_job_template_spec import V1JobTemplateSpec import unittest -import datetime -import jobset -from jobset.models.jobset_v1alpha2_job_set_status import JobsetV1alpha2JobSetStatus # noqa: E501 -from jobset.rest import ApiException +from jobset.models.jobset_v1alpha2_job_set_status import JobsetV1alpha2JobSetStatus class TestJobsetV1alpha2JobSetStatus(unittest.TestCase): """JobsetV1alpha2JobSetStatus unit test stubs""" @@ -30,39 +25,41 @@ def setUp(self): def tearDown(self): pass - def make_instance(self, include_optional): + def make_instance(self, include_optional) -> JobsetV1alpha2JobSetStatus: """Test JobsetV1alpha2JobSetStatus - include_option is a boolean, when False only required + include_optional is a boolean, when False only required params are included, when True both required and optional params are included """ - # model = jobset.models.jobset_v1alpha2_job_set_status.JobsetV1alpha2JobSetStatus() # noqa: E501 - if include_optional : + # uncomment below to create an instance of `JobsetV1alpha2JobSetStatus` + """ + model = JobsetV1alpha2JobSetStatus() + if include_optional: return JobsetV1alpha2JobSetStatus( conditions = [ None - ], + ], replicated_jobs_status = [ jobset.models.jobset_v1alpha2_replicated_job_status.JobsetV1alpha2ReplicatedJobStatus( active = 56, failed = 56, - name = '0', + name = '', ready = 56, succeeded = 56, suspended = 56, ) - ], - restarts = 56, - restarts_count_towards_max = 56, - terminal_state = '0' + ], + restarts = 56, + restarts_count_towards_max = 56, + terminal_state = '' ) - else : + else: return JobsetV1alpha2JobSetStatus( ) + """ def testJobsetV1alpha2JobSetStatus(self): """Test JobsetV1alpha2JobSetStatus""" - inst_req_only = self.make_instance(include_optional=False) - inst_req_and_optional = self.make_instance(include_optional=True) - + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) if __name__ == '__main__': unittest.main() diff --git a/sdk/python/test/test_jobset_v1alpha2_network.py b/sdk/python/test/test_jobset_v1alpha2_network.py index 5b6a61e95..ee85231f0 100644 --- a/sdk/python/test/test_jobset_v1alpha2_network.py +++ b/sdk/python/test/test_jobset_v1alpha2_network.py @@ -3,23 +3,18 @@ """ JobSet SDK - Python SDK for the JobSet API # noqa: E501 + Python SDK for the JobSet API The version of the OpenAPI document: v0.1.4 - Generated by: https://openapi-generator.tech -""" + Generated by OpenAPI Generator (https://openapi-generator.tech) + Do not edit the class manually. +""" # noqa: E501 -from __future__ import absolute_import -# Kubernetes imports -from kubernetes.client.models.v1_job_template_spec import V1JobTemplateSpec import unittest -import datetime -import jobset -from jobset.models.jobset_v1alpha2_network import JobsetV1alpha2Network # noqa: E501 -from jobset.rest import ApiException +from jobset.models.jobset_v1alpha2_network import JobsetV1alpha2Network class TestJobsetV1alpha2Network(unittest.TestCase): """JobsetV1alpha2Network unit test stubs""" @@ -30,27 +25,29 @@ def setUp(self): def tearDown(self): pass - def make_instance(self, include_optional): + def make_instance(self, include_optional) -> JobsetV1alpha2Network: """Test JobsetV1alpha2Network - include_option is a boolean, when False only required + include_optional is a boolean, when False only required params are included, when True both required and optional params are included """ - # model = jobset.models.jobset_v1alpha2_network.JobsetV1alpha2Network() # noqa: E501 - if include_optional : + # uncomment below to create an instance of `JobsetV1alpha2Network` + """ + model = JobsetV1alpha2Network() + if include_optional: return JobsetV1alpha2Network( - enable_dns_hostnames = True, - publish_not_ready_addresses = True, - subdomain = '0' + enable_dns_hostnames = True, + publish_not_ready_addresses = True, + subdomain = '' ) - else : + else: return JobsetV1alpha2Network( ) + """ def testJobsetV1alpha2Network(self): """Test JobsetV1alpha2Network""" - inst_req_only = self.make_instance(include_optional=False) - inst_req_and_optional = self.make_instance(include_optional=True) - + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) if __name__ == '__main__': unittest.main() diff --git a/sdk/python/test/test_jobset_v1alpha2_replicated_job.py b/sdk/python/test/test_jobset_v1alpha2_replicated_job.py index ac51873f9..158eb2231 100644 --- a/sdk/python/test/test_jobset_v1alpha2_replicated_job.py +++ b/sdk/python/test/test_jobset_v1alpha2_replicated_job.py @@ -3,23 +3,18 @@ """ JobSet SDK - Python SDK for the JobSet API # noqa: E501 + Python SDK for the JobSet API The version of the OpenAPI document: v0.1.4 - Generated by: https://openapi-generator.tech -""" + Generated by OpenAPI Generator (https://openapi-generator.tech) + Do not edit the class manually. +""" # noqa: E501 -from __future__ import absolute_import -# Kubernetes imports -from kubernetes.client.models.v1_job_template_spec import V1JobTemplateSpec import unittest -import datetime -import jobset -from jobset.models.jobset_v1alpha2_replicated_job import JobsetV1alpha2ReplicatedJob # noqa: E501 -from jobset.rest import ApiException +from jobset.models.jobset_v1alpha2_replicated_job import JobsetV1alpha2ReplicatedJob class TestJobsetV1alpha2ReplicatedJob(unittest.TestCase): """JobsetV1alpha2ReplicatedJob unit test stubs""" @@ -30,29 +25,31 @@ def setUp(self): def tearDown(self): pass - def make_instance(self, include_optional): + def make_instance(self, include_optional) -> JobsetV1alpha2ReplicatedJob: """Test JobsetV1alpha2ReplicatedJob - include_option is a boolean, when False only required + include_optional is a boolean, when False only required params are included, when True both required and optional params are included """ - # model = jobset.models.jobset_v1alpha2_replicated_job.JobsetV1alpha2ReplicatedJob() # noqa: E501 - if include_optional : + # uncomment below to create an instance of `JobsetV1alpha2ReplicatedJob` + """ + model = JobsetV1alpha2ReplicatedJob() + if include_optional: return JobsetV1alpha2ReplicatedJob( - name = '0', - replicas = 56, + name = '', + replicas = 56, template = V1JobTemplateSpec() ) - else : + else: return JobsetV1alpha2ReplicatedJob( - name = '0', + name = '', template = V1JobTemplateSpec(), ) + """ def testJobsetV1alpha2ReplicatedJob(self): """Test JobsetV1alpha2ReplicatedJob""" - inst_req_only = self.make_instance(include_optional=False) - inst_req_and_optional = self.make_instance(include_optional=True) - + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) if __name__ == '__main__': unittest.main() diff --git a/sdk/python/test/test_jobset_v1alpha2_replicated_job_status.py b/sdk/python/test/test_jobset_v1alpha2_replicated_job_status.py index bcf087246..638a108c0 100644 --- a/sdk/python/test/test_jobset_v1alpha2_replicated_job_status.py +++ b/sdk/python/test/test_jobset_v1alpha2_replicated_job_status.py @@ -3,23 +3,18 @@ """ JobSet SDK - Python SDK for the JobSet API # noqa: E501 + Python SDK for the JobSet API The version of the OpenAPI document: v0.1.4 - Generated by: https://openapi-generator.tech -""" + Generated by OpenAPI Generator (https://openapi-generator.tech) + Do not edit the class manually. +""" # noqa: E501 -from __future__ import absolute_import -# Kubernetes imports -from kubernetes.client.models.v1_job_template_spec import V1JobTemplateSpec import unittest -import datetime -import jobset -from jobset.models.jobset_v1alpha2_replicated_job_status import JobsetV1alpha2ReplicatedJobStatus # noqa: E501 -from jobset.rest import ApiException +from jobset.models.jobset_v1alpha2_replicated_job_status import JobsetV1alpha2ReplicatedJobStatus class TestJobsetV1alpha2ReplicatedJobStatus(unittest.TestCase): """JobsetV1alpha2ReplicatedJobStatus unit test stubs""" @@ -30,36 +25,38 @@ def setUp(self): def tearDown(self): pass - def make_instance(self, include_optional): + def make_instance(self, include_optional) -> JobsetV1alpha2ReplicatedJobStatus: """Test JobsetV1alpha2ReplicatedJobStatus - include_option is a boolean, when False only required + include_optional is a boolean, when False only required params are included, when True both required and optional params are included """ - # model = jobset.models.jobset_v1alpha2_replicated_job_status.JobsetV1alpha2ReplicatedJobStatus() # noqa: E501 - if include_optional : + # uncomment below to create an instance of `JobsetV1alpha2ReplicatedJobStatus` + """ + model = JobsetV1alpha2ReplicatedJobStatus() + if include_optional: return JobsetV1alpha2ReplicatedJobStatus( - active = 56, - failed = 56, - name = '0', - ready = 56, - succeeded = 56, + active = 56, + failed = 56, + name = '', + ready = 56, + succeeded = 56, suspended = 56 ) - else : + else: return JobsetV1alpha2ReplicatedJobStatus( active = 56, failed = 56, - name = '0', + name = '', ready = 56, succeeded = 56, suspended = 56, ) + """ def testJobsetV1alpha2ReplicatedJobStatus(self): """Test JobsetV1alpha2ReplicatedJobStatus""" - inst_req_only = self.make_instance(include_optional=False) - inst_req_and_optional = self.make_instance(include_optional=True) - + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) if __name__ == '__main__': unittest.main() diff --git a/sdk/python/test/test_jobset_v1alpha2_startup_policy.py b/sdk/python/test/test_jobset_v1alpha2_startup_policy.py index b0eef20e2..fc8e116ed 100644 --- a/sdk/python/test/test_jobset_v1alpha2_startup_policy.py +++ b/sdk/python/test/test_jobset_v1alpha2_startup_policy.py @@ -3,23 +3,18 @@ """ JobSet SDK - Python SDK for the JobSet API # noqa: E501 + Python SDK for the JobSet API The version of the OpenAPI document: v0.1.4 - Generated by: https://openapi-generator.tech -""" + Generated by OpenAPI Generator (https://openapi-generator.tech) + Do not edit the class manually. +""" # noqa: E501 -from __future__ import absolute_import -# Kubernetes imports -from kubernetes.client.models.v1_job_template_spec import V1JobTemplateSpec import unittest -import datetime -import jobset -from jobset.models.jobset_v1alpha2_startup_policy import JobsetV1alpha2StartupPolicy # noqa: E501 -from jobset.rest import ApiException +from jobset.models.jobset_v1alpha2_startup_policy import JobsetV1alpha2StartupPolicy class TestJobsetV1alpha2StartupPolicy(unittest.TestCase): """JobsetV1alpha2StartupPolicy unit test stubs""" @@ -30,26 +25,28 @@ def setUp(self): def tearDown(self): pass - def make_instance(self, include_optional): + def make_instance(self, include_optional) -> JobsetV1alpha2StartupPolicy: """Test JobsetV1alpha2StartupPolicy - include_option is a boolean, when False only required + include_optional is a boolean, when False only required params are included, when True both required and optional params are included """ - # model = jobset.models.jobset_v1alpha2_startup_policy.JobsetV1alpha2StartupPolicy() # noqa: E501 - if include_optional : + # uncomment below to create an instance of `JobsetV1alpha2StartupPolicy` + """ + model = JobsetV1alpha2StartupPolicy() + if include_optional: return JobsetV1alpha2StartupPolicy( - startup_policy_order = '0' + startup_policy_order = '' ) - else : + else: return JobsetV1alpha2StartupPolicy( - startup_policy_order = '0', + startup_policy_order = '', ) + """ def testJobsetV1alpha2StartupPolicy(self): """Test JobsetV1alpha2StartupPolicy""" - inst_req_only = self.make_instance(include_optional=False) - inst_req_and_optional = self.make_instance(include_optional=True) - + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) if __name__ == '__main__': unittest.main() diff --git a/sdk/python/test/test_jobset_v1alpha2_success_policy.py b/sdk/python/test/test_jobset_v1alpha2_success_policy.py index 17eb67faf..c165a7b3d 100644 --- a/sdk/python/test/test_jobset_v1alpha2_success_policy.py +++ b/sdk/python/test/test_jobset_v1alpha2_success_policy.py @@ -3,23 +3,18 @@ """ JobSet SDK - Python SDK for the JobSet API # noqa: E501 + Python SDK for the JobSet API The version of the OpenAPI document: v0.1.4 - Generated by: https://openapi-generator.tech -""" + Generated by OpenAPI Generator (https://openapi-generator.tech) + Do not edit the class manually. +""" # noqa: E501 -from __future__ import absolute_import -# Kubernetes imports -from kubernetes.client.models.v1_job_template_spec import V1JobTemplateSpec import unittest -import datetime -import jobset -from jobset.models.jobset_v1alpha2_success_policy import JobsetV1alpha2SuccessPolicy # noqa: E501 -from jobset.rest import ApiException +from jobset.models.jobset_v1alpha2_success_policy import JobsetV1alpha2SuccessPolicy class TestJobsetV1alpha2SuccessPolicy(unittest.TestCase): """JobsetV1alpha2SuccessPolicy unit test stubs""" @@ -30,29 +25,31 @@ def setUp(self): def tearDown(self): pass - def make_instance(self, include_optional): + def make_instance(self, include_optional) -> JobsetV1alpha2SuccessPolicy: """Test JobsetV1alpha2SuccessPolicy - include_option is a boolean, when False only required + include_optional is a boolean, when False only required params are included, when True both required and optional params are included """ - # model = jobset.models.jobset_v1alpha2_success_policy.JobsetV1alpha2SuccessPolicy() # noqa: E501 - if include_optional : + # uncomment below to create an instance of `JobsetV1alpha2SuccessPolicy` + """ + model = JobsetV1alpha2SuccessPolicy() + if include_optional: return JobsetV1alpha2SuccessPolicy( - operator = '0', + operator = '', target_replicated_jobs = [ - '0' + '' ] ) - else : + else: return JobsetV1alpha2SuccessPolicy( - operator = '0', + operator = '', ) + """ def testJobsetV1alpha2SuccessPolicy(self): """Test JobsetV1alpha2SuccessPolicy""" - inst_req_only = self.make_instance(include_optional=False) - inst_req_and_optional = self.make_instance(include_optional=True) - + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) if __name__ == '__main__': unittest.main() diff --git a/sdk/python/tox.ini b/sdk/python/tox.ini index c9aa1f15d..8a2c6b5ce 100644 --- a/sdk/python/tox.ini +++ b/sdk/python/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27, py3 +envlist = py3 [testenv] deps=-r{toxinidir}/requirements.txt From 16425394e070c29be91faa6a59e5a83691d73906 Mon Sep 17 00:00:00 2001 From: epicseven-cup Date: Wed, 9 Oct 2024 21:34:49 -0400 Subject: [PATCH 08/14] Revert "ran locally with docker and podman installed" This reverts commit cdd94dea42dc168df223d01372c0c1423dc41f39. --- hack/python-sdk/gen-sdk.sh | 19 +- sdk/python/.github/workflows/python.yml | 38 - sdk/python/.gitlab-ci.yml | 38 +- sdk/python/.openapi-generator/FILES | 58 -- sdk/python/.openapi-generator/VERSION | 2 +- sdk/python/.travis.yml | 12 +- sdk/python/README.md | 13 +- sdk/python/docs/JobsetV1alpha2Coordinator.md | 19 - .../docs/JobsetV1alpha2FailurePolicy.md | 21 +- .../docs/JobsetV1alpha2FailurePolicyRule.md | 23 +- sdk/python/docs/JobsetV1alpha2JobSet.md | 19 - sdk/python/docs/JobsetV1alpha2JobSetList.md | 21 +- sdk/python/docs/JobsetV1alpha2JobSetSpec.md | 21 +- sdk/python/docs/JobsetV1alpha2JobSetStatus.md | 23 +- sdk/python/docs/JobsetV1alpha2Network.md | 19 - .../docs/JobsetV1alpha2ReplicatedJob.md | 19 - .../docs/JobsetV1alpha2ReplicatedJobStatus.md | 19 - .../docs/JobsetV1alpha2StartupPolicy.md | 19 - .../docs/JobsetV1alpha2SuccessPolicy.md | 21 +- sdk/python/git_push.sh | 7 +- sdk/python/jobset/__init__.py | 12 +- sdk/python/jobset/api/__init__.py | 3 +- sdk/python/jobset/api_client.py | 755 ++++++++---------- sdk/python/jobset/api_response.py | 21 - sdk/python/jobset/configuration.py | 178 ++--- sdk/python/jobset/exceptions.py | 119 +-- sdk/python/jobset/models/__init__.py | 11 +- .../models/jobset_v1alpha2_coordinator.py | 228 ++++-- .../models/jobset_v1alpha2_failure_policy.py | 213 +++-- .../jobset_v1alpha2_failure_policy_rule.py | 267 +++++-- .../jobset/models/jobset_v1alpha2_job_set.py | 300 ++++--- .../models/jobset_v1alpha2_job_set_list.py | 273 +++++-- .../models/jobset_v1alpha2_job_set_spec.py | 439 +++++++--- .../models/jobset_v1alpha2_job_set_status.py | 308 ++++--- .../jobset/models/jobset_v1alpha2_network.py | 227 ++++-- .../models/jobset_v1alpha2_replicated_job.py | 238 ++++-- .../jobset_v1alpha2_replicated_job_status.py | 331 ++++++-- .../models/jobset_v1alpha2_startup_policy.py | 156 ++-- .../models/jobset_v1alpha2_success_policy.py | 198 +++-- sdk/python/jobset/py.typed | 0 sdk/python/jobset/rest.py | 306 +++---- sdk/python/pyproject.toml | 88 +- sdk/python/requirements.txt | 7 +- sdk/python/test-requirements.txt | 4 +- .../test/test_jobset_v1alpha2_coordinator.py | 41 +- .../test_jobset_v1alpha2_failure_policy.py | 43 +- ...est_jobset_v1alpha2_failure_policy_rule.py | 47 +- .../test/test_jobset_v1alpha2_job_set.py | 65 +- .../test/test_jobset_v1alpha2_job_set_list.py | 95 +-- .../test/test_jobset_v1alpha2_job_set_spec.py | 63 +- .../test_jobset_v1alpha2_job_set_status.py | 45 +- .../test/test_jobset_v1alpha2_network.py | 39 +- .../test_jobset_v1alpha2_replicated_job.py | 39 +- ...t_jobset_v1alpha2_replicated_job_status.py | 45 +- .../test_jobset_v1alpha2_startup_policy.py | 37 +- .../test_jobset_v1alpha2_success_policy.py | 39 +- sdk/python/tox.ini | 2 +- 57 files changed, 3176 insertions(+), 2537 deletions(-) delete mode 100644 sdk/python/.github/workflows/python.yml delete mode 100644 sdk/python/.openapi-generator/FILES delete mode 100644 sdk/python/jobset/api_response.py delete mode 100644 sdk/python/jobset/py.typed diff --git a/hack/python-sdk/gen-sdk.sh b/hack/python-sdk/gen-sdk.sh index f1da5c48a..4baaf0bcd 100755 --- a/hack/python-sdk/gen-sdk.sh +++ b/hack/python-sdk/gen-sdk.sh @@ -67,13 +67,18 @@ elif ! [ "$DOCKER_EXIST" ] && [ "$PODMAN_EXIST" ]; then CONTAINER_ENGINE="podman" fi -# Install the sdk using docker, using the user that is running the container engine so that files can still be removed -${CONTAINER_ENGINE} run --user $(id -u):$(id -g) --rm \ +# Install the sdk using docker +${CONTAINER_ENGINE} run --rm \ -v "${repo_root}":/local docker.io/openapitools/openapi-generator-cli generate \ -i /local/"${SWAGGER_CODEGEN_FILE}" \ -g python \ -o /local/"${SDK_OUTPUT_PATH}" \ - -c local/"${SWAGGER_CODEGEN_CONF}" + -c local/"${SWAGGER_CODEGEN_FILE}" + +if [ -d "docker-17.03.0-ce.tgz" ]; then + echo "Removing docker install folder" + rm -r docker-17.03.0-ce.tgz +fi echo "Running post-generation script ..." "${repo_root}"/hack/python-sdk/post_gen.py @@ -81,10 +86,4 @@ echo "Running post-generation script ..." echo "JobSet Python SDK is generated successfully to folder ${SDK_OUTPUT_PATH}/." # Remove setup.py -rm "${SDK_OUTPUT_PATH}"/setup.py - -# Clean up -if [ -d "docker-17.03.0-ce.tgz" ]; then - echo "Removing docker install folder" - rm -r docker-17.03.0-ce.tgz -fi +rm ${SDK_OUTPUT_PATH}/setup.py diff --git a/sdk/python/.github/workflows/python.yml b/sdk/python/.github/workflows/python.yml deleted file mode 100644 index d4a179383..000000000 --- a/sdk/python/.github/workflows/python.yml +++ /dev/null @@ -1,38 +0,0 @@ -# NOTE: This file is auto generated by OpenAPI Generator. -# URL: https://openapi-generator.tech -# -# ref: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python - -name: jobset Python package - -on: [push, pull_request] - -jobs: - build: - - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] - - steps: - - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install flake8 pytest - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - if [ -f test-requirements.txt ]; then pip install -r test-requirements.txt; fi - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with pytest - run: | - pytest diff --git a/sdk/python/.gitlab-ci.yml b/sdk/python/.gitlab-ci.yml index f9f9d7cdd..589036f32 100644 --- a/sdk/python/.gitlab-ci.yml +++ b/sdk/python/.gitlab-ci.yml @@ -1,31 +1,33 @@ -# NOTE: This file is auto generated by OpenAPI Generator. -# URL: https://openapi-generator.tech -# # ref: https://docs.gitlab.com/ee/ci/README.html -# ref: https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Python.gitlab-ci.yml stages: - test -.pytest: +.nosetest: stage: test script: - pip install -r requirements.txt - pip install -r test-requirements.txt - pytest --cov=jobset -pytest-3.7: - extends: .pytest +nosetest-2.7: + extends: .nosetest + image: python:2.7-alpine +nosetest-3.3: + extends: .nosetest + image: python:3.3-alpine +nosetest-3.4: + extends: .nosetest + image: python:3.4-alpine +nosetest-3.5: + extends: .nosetest + image: python:3.5-alpine +nosetest-3.6: + extends: .nosetest + image: python:3.6-alpine +nosetest-3.7: + extends: .nosetest image: python:3.7-alpine -pytest-3.8: - extends: .pytest +nosetest-3.8: + extends: .nosetest image: python:3.8-alpine -pytest-3.9: - extends: .pytest - image: python:3.9-alpine -pytest-3.10: - extends: .pytest - image: python:3.10-alpine -pytest-3.11: - extends: .pytest - image: python:3.11-alpine diff --git a/sdk/python/.openapi-generator/FILES b/sdk/python/.openapi-generator/FILES deleted file mode 100644 index 4c21c1644..000000000 --- a/sdk/python/.openapi-generator/FILES +++ /dev/null @@ -1,58 +0,0 @@ -.github/workflows/python.yml -.gitignore -.gitlab-ci.yml -.travis.yml -README.md -docs/JobsetV1alpha2Coordinator.md -docs/JobsetV1alpha2FailurePolicy.md -docs/JobsetV1alpha2FailurePolicyRule.md -docs/JobsetV1alpha2JobSet.md -docs/JobsetV1alpha2JobSetList.md -docs/JobsetV1alpha2JobSetSpec.md -docs/JobsetV1alpha2JobSetStatus.md -docs/JobsetV1alpha2Network.md -docs/JobsetV1alpha2ReplicatedJob.md -docs/JobsetV1alpha2ReplicatedJobStatus.md -docs/JobsetV1alpha2StartupPolicy.md -docs/JobsetV1alpha2SuccessPolicy.md -git_push.sh -jobset/__init__.py -jobset/api/__init__.py -jobset/api_client.py -jobset/api_response.py -jobset/configuration.py -jobset/exceptions.py -jobset/models/__init__.py -jobset/models/jobset_v1alpha2_coordinator.py -jobset/models/jobset_v1alpha2_failure_policy.py -jobset/models/jobset_v1alpha2_failure_policy_rule.py -jobset/models/jobset_v1alpha2_job_set.py -jobset/models/jobset_v1alpha2_job_set_list.py -jobset/models/jobset_v1alpha2_job_set_spec.py -jobset/models/jobset_v1alpha2_job_set_status.py -jobset/models/jobset_v1alpha2_network.py -jobset/models/jobset_v1alpha2_replicated_job.py -jobset/models/jobset_v1alpha2_replicated_job_status.py -jobset/models/jobset_v1alpha2_startup_policy.py -jobset/models/jobset_v1alpha2_success_policy.py -jobset/py.typed -jobset/rest.py -pyproject.toml -requirements.txt -setup.cfg -setup.py -test-requirements.txt -test/__init__.py -test/test_jobset_v1alpha2_coordinator.py -test/test_jobset_v1alpha2_failure_policy.py -test/test_jobset_v1alpha2_failure_policy_rule.py -test/test_jobset_v1alpha2_job_set.py -test/test_jobset_v1alpha2_job_set_list.py -test/test_jobset_v1alpha2_job_set_spec.py -test/test_jobset_v1alpha2_job_set_status.py -test/test_jobset_v1alpha2_network.py -test/test_jobset_v1alpha2_replicated_job.py -test/test_jobset_v1alpha2_replicated_job_status.py -test/test_jobset_v1alpha2_startup_policy.py -test/test_jobset_v1alpha2_success_policy.py -tox.ini diff --git a/sdk/python/.openapi-generator/VERSION b/sdk/python/.openapi-generator/VERSION index 17f2442ff..ecedc98d1 100644 --- a/sdk/python/.openapi-generator/VERSION +++ b/sdk/python/.openapi-generator/VERSION @@ -1 +1 @@ -7.9.0-SNAPSHOT +4.3.1 \ No newline at end of file diff --git a/sdk/python/.travis.yml b/sdk/python/.travis.yml index f55392ea9..3411bd402 100644 --- a/sdk/python/.travis.yml +++ b/sdk/python/.travis.yml @@ -1,14 +1,14 @@ # ref: https://docs.travis-ci.com/user/languages/python language: python python: + - "2.7" + - "3.2" + - "3.3" + - "3.4" + - "3.5" + - "3.6" - "3.7" - "3.8" - - "3.9" - - "3.10" - - "3.11" - # uncomment the following if needed - #- "3.11-dev" # 3.11 development branch - #- "nightly" # nightly build # command to install dependencies install: - "pip install -r requirements.txt" diff --git a/sdk/python/README.md b/sdk/python/README.md index d31033066..374681a62 100644 --- a/sdk/python/README.md +++ b/sdk/python/README.md @@ -5,12 +5,11 @@ This Python package is automatically generated by the [OpenAPI Generator](https: - API version: v0.1.4 - Package version: 0.1.4 -- Generator version: 7.9.0-SNAPSHOT - Build package: org.openapitools.codegen.languages.PythonClientCodegen ## Requirements. -Python 3.7+ +Python 2.7 and 3.4+ ## Installation & Usage ### pip install @@ -41,16 +40,14 @@ Then import the package: import jobset ``` -### Tests - -Execute `pytest` to run the tests. - ## Getting Started Please follow the [installation procedure](#installation--usage) and then run the following: ```python +from __future__ import print_function +import time import jobset from jobset.rest import ApiException from pprint import pprint @@ -81,11 +78,9 @@ Class | Method | HTTP request | Description - [JobsetV1alpha2SuccessPolicy](docs/JobsetV1alpha2SuccessPolicy.md) - ## Documentation For Authorization -Endpoints do not require authorization. - + All endpoints do not require authorization. ## Author diff --git a/sdk/python/docs/JobsetV1alpha2Coordinator.md b/sdk/python/docs/JobsetV1alpha2Coordinator.md index ed5322286..5c893be6d 100644 --- a/sdk/python/docs/JobsetV1alpha2Coordinator.md +++ b/sdk/python/docs/JobsetV1alpha2Coordinator.md @@ -1,32 +1,13 @@ # JobsetV1alpha2Coordinator Coordinator defines which pod can be marked as the coordinator for the JobSet workload. - ## Properties - Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **job_index** | **int** | JobIndex is the index of Job which contains the coordinator pod (i.e., for a ReplicatedJob with N replicas, there are Job indexes 0 to N-1). | [optional] **pod_index** | **int** | PodIndex is the Job completion index of the coordinator pod. | [optional] **replicated_job** | **str** | ReplicatedJob is the name of the ReplicatedJob which contains the coordinator pod. | [default to ''] -## Example - -```python -from jobset.models.jobset_v1alpha2_coordinator import JobsetV1alpha2Coordinator - -# TODO update the JSON string below -json = "{}" -# create an instance of JobsetV1alpha2Coordinator from a JSON string -jobset_v1alpha2_coordinator_instance = JobsetV1alpha2Coordinator.from_json(json) -# print the JSON string representation of the object -print(JobsetV1alpha2Coordinator.to_json()) - -# convert the object into a dict -jobset_v1alpha2_coordinator_dict = jobset_v1alpha2_coordinator_instance.to_dict() -# create an instance of JobsetV1alpha2Coordinator from a dict -jobset_v1alpha2_coordinator_from_dict = JobsetV1alpha2Coordinator.from_dict(jobset_v1alpha2_coordinator_dict) -``` [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/sdk/python/docs/JobsetV1alpha2FailurePolicy.md b/sdk/python/docs/JobsetV1alpha2FailurePolicy.md index 6af95c961..e7b5a2d69 100644 --- a/sdk/python/docs/JobsetV1alpha2FailurePolicy.md +++ b/sdk/python/docs/JobsetV1alpha2FailurePolicy.md @@ -1,30 +1,11 @@ # JobsetV1alpha2FailurePolicy - ## Properties - Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **max_restarts** | **int** | MaxRestarts defines the limit on the number of JobSet restarts. A restart is achieved by recreating all active child jobs. | [optional] -**rules** | [**List[JobsetV1alpha2FailurePolicyRule]**](JobsetV1alpha2FailurePolicyRule.md) | List of failure policy rules for this JobSet. For a given Job failure, the rules will be evaluated in order, and only the first matching rule will be executed. If no matching rule is found, the RestartJobSet action is applied. | [optional] - -## Example - -```python -from jobset.models.jobset_v1alpha2_failure_policy import JobsetV1alpha2FailurePolicy - -# TODO update the JSON string below -json = "{}" -# create an instance of JobsetV1alpha2FailurePolicy from a JSON string -jobset_v1alpha2_failure_policy_instance = JobsetV1alpha2FailurePolicy.from_json(json) -# print the JSON string representation of the object -print(JobsetV1alpha2FailurePolicy.to_json()) +**rules** | [**list[JobsetV1alpha2FailurePolicyRule]**](JobsetV1alpha2FailurePolicyRule.md) | List of failure policy rules for this JobSet. For a given Job failure, the rules will be evaluated in order, and only the first matching rule will be executed. If no matching rule is found, the RestartJobSet action is applied. | [optional] -# convert the object into a dict -jobset_v1alpha2_failure_policy_dict = jobset_v1alpha2_failure_policy_instance.to_dict() -# create an instance of JobsetV1alpha2FailurePolicy from a dict -jobset_v1alpha2_failure_policy_from_dict = JobsetV1alpha2FailurePolicy.from_dict(jobset_v1alpha2_failure_policy_dict) -``` [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/sdk/python/docs/JobsetV1alpha2FailurePolicyRule.md b/sdk/python/docs/JobsetV1alpha2FailurePolicyRule.md index 4665423ad..3f7169a08 100644 --- a/sdk/python/docs/JobsetV1alpha2FailurePolicyRule.md +++ b/sdk/python/docs/JobsetV1alpha2FailurePolicyRule.md @@ -1,33 +1,14 @@ # JobsetV1alpha2FailurePolicyRule FailurePolicyRule defines a FailurePolicyAction to be executed if a child job fails due to a reason listed in OnJobFailureReasons. - ## Properties - Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **action** | **str** | The action to take if the rule is matched. | [default to ''] **name** | **str** | The name of the failure policy rule. The name is defaulted to 'failurePolicyRuleN' where N is the index of the failure policy rule. The name must match the regular expression \"^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$\". | [default to ''] -**on_job_failure_reasons** | **List[str]** | The requirement on the job failure reasons. The requirement is satisfied if at least one reason matches the list. The rules are evaluated in order, and the first matching rule is executed. An empty list applies the rule to any job failure reason. | [optional] -**target_replicated_jobs** | **List[str]** | TargetReplicatedJobs are the names of the replicated jobs the operator applies to. An empty list will apply to all replicatedJobs. | [optional] - -## Example - -```python -from jobset.models.jobset_v1alpha2_failure_policy_rule import JobsetV1alpha2FailurePolicyRule - -# TODO update the JSON string below -json = "{}" -# create an instance of JobsetV1alpha2FailurePolicyRule from a JSON string -jobset_v1alpha2_failure_policy_rule_instance = JobsetV1alpha2FailurePolicyRule.from_json(json) -# print the JSON string representation of the object -print(JobsetV1alpha2FailurePolicyRule.to_json()) +**on_job_failure_reasons** | **list[str]** | The requirement on the job failure reasons. The requirement is satisfied if at least one reason matches the list. The rules are evaluated in order, and the first matching rule is executed. An empty list applies the rule to any job failure reason. | [optional] +**target_replicated_jobs** | **list[str]** | TargetReplicatedJobs are the names of the replicated jobs the operator applies to. An empty list will apply to all replicatedJobs. | [optional] -# convert the object into a dict -jobset_v1alpha2_failure_policy_rule_dict = jobset_v1alpha2_failure_policy_rule_instance.to_dict() -# create an instance of JobsetV1alpha2FailurePolicyRule from a dict -jobset_v1alpha2_failure_policy_rule_from_dict = JobsetV1alpha2FailurePolicyRule.from_dict(jobset_v1alpha2_failure_policy_rule_dict) -``` [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/sdk/python/docs/JobsetV1alpha2JobSet.md b/sdk/python/docs/JobsetV1alpha2JobSet.md index c14178872..8669d1acb 100644 --- a/sdk/python/docs/JobsetV1alpha2JobSet.md +++ b/sdk/python/docs/JobsetV1alpha2JobSet.md @@ -1,9 +1,7 @@ # JobsetV1alpha2JobSet JobSet is the Schema for the jobsets API - ## 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] @@ -12,23 +10,6 @@ Name | Type | Description | Notes **spec** | [**JobsetV1alpha2JobSetSpec**](JobsetV1alpha2JobSetSpec.md) | | [optional] **status** | [**JobsetV1alpha2JobSetStatus**](JobsetV1alpha2JobSetStatus.md) | | [optional] -## Example - -```python -from jobset.models.jobset_v1alpha2_job_set import JobsetV1alpha2JobSet - -# TODO update the JSON string below -json = "{}" -# create an instance of JobsetV1alpha2JobSet from a JSON string -jobset_v1alpha2_job_set_instance = JobsetV1alpha2JobSet.from_json(json) -# print the JSON string representation of the object -print(JobsetV1alpha2JobSet.to_json()) - -# convert the object into a dict -jobset_v1alpha2_job_set_dict = jobset_v1alpha2_job_set_instance.to_dict() -# create an instance of JobsetV1alpha2JobSet from a dict -jobset_v1alpha2_job_set_from_dict = JobsetV1alpha2JobSet.from_dict(jobset_v1alpha2_job_set_dict) -``` [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/sdk/python/docs/JobsetV1alpha2JobSetList.md b/sdk/python/docs/JobsetV1alpha2JobSetList.md index c2025ccb1..9073b4571 100644 --- a/sdk/python/docs/JobsetV1alpha2JobSetList.md +++ b/sdk/python/docs/JobsetV1alpha2JobSetList.md @@ -1,33 +1,14 @@ # JobsetV1alpha2JobSetList JobSetList contains a list of JobSet - ## 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[JobsetV1alpha2JobSet]**](JobsetV1alpha2JobSet.md) | | +**items** | [**list[JobsetV1alpha2JobSet]**](JobsetV1alpha2JobSet.md) | | **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] -## Example - -```python -from jobset.models.jobset_v1alpha2_job_set_list import JobsetV1alpha2JobSetList - -# TODO update the JSON string below -json = "{}" -# create an instance of JobsetV1alpha2JobSetList from a JSON string -jobset_v1alpha2_job_set_list_instance = JobsetV1alpha2JobSetList.from_json(json) -# print the JSON string representation of the object -print(JobsetV1alpha2JobSetList.to_json()) - -# convert the object into a dict -jobset_v1alpha2_job_set_list_dict = jobset_v1alpha2_job_set_list_instance.to_dict() -# create an instance of JobsetV1alpha2JobSetList from a dict -jobset_v1alpha2_job_set_list_from_dict = JobsetV1alpha2JobSetList.from_dict(jobset_v1alpha2_job_set_list_dict) -``` [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/sdk/python/docs/JobsetV1alpha2JobSetSpec.md b/sdk/python/docs/JobsetV1alpha2JobSetSpec.md index b568e3456..70e46a057 100644 --- a/sdk/python/docs/JobsetV1alpha2JobSetSpec.md +++ b/sdk/python/docs/JobsetV1alpha2JobSetSpec.md @@ -1,38 +1,19 @@ # JobsetV1alpha2JobSetSpec JobSetSpec defines the desired state of JobSet - ## Properties - Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **coordinator** | [**JobsetV1alpha2Coordinator**](JobsetV1alpha2Coordinator.md) | | [optional] **failure_policy** | [**JobsetV1alpha2FailurePolicy**](JobsetV1alpha2FailurePolicy.md) | | [optional] **managed_by** | **str** | ManagedBy is used to indicate the controller or entity that manages a JobSet. The built-in JobSet controller reconciles JobSets which don't have this field at all or the field value is the reserved string `jobset.sigs.k8s.io/jobset-controller`, but skips reconciling JobSets with a custom value for this field. The value must be a valid domain-prefixed path (e.g. acme.io/foo) - all characters before the first \"/\" must be a valid subdomain as defined by RFC 1123. All characters trailing the first \"/\" must be valid HTTP Path characters as defined by RFC 3986. The value cannot exceed 63 characters. The field is immutable. | [optional] **network** | [**JobsetV1alpha2Network**](JobsetV1alpha2Network.md) | | [optional] -**replicated_jobs** | [**List[JobsetV1alpha2ReplicatedJob]**](JobsetV1alpha2ReplicatedJob.md) | ReplicatedJobs is the group of jobs that will form the set. | [optional] +**replicated_jobs** | [**list[JobsetV1alpha2ReplicatedJob]**](JobsetV1alpha2ReplicatedJob.md) | ReplicatedJobs is the group of jobs that will form the set. | [optional] **startup_policy** | [**JobsetV1alpha2StartupPolicy**](JobsetV1alpha2StartupPolicy.md) | | [optional] **success_policy** | [**JobsetV1alpha2SuccessPolicy**](JobsetV1alpha2SuccessPolicy.md) | | [optional] **suspend** | **bool** | Suspend suspends all running child Jobs when set to true. | [optional] **ttl_seconds_after_finished** | **int** | TTLSecondsAfterFinished limits the lifetime of a JobSet that has finished execution (either Complete or Failed). If this field is set, TTLSecondsAfterFinished after the JobSet finishes, it is eligible to be automatically deleted. When the JobSet is being deleted, its lifecycle guarantees (e.g. finalizers) will be honored. If this field is unset, the JobSet won't be automatically deleted. If this field is set to zero, the JobSet becomes eligible to be deleted immediately after it finishes. | [optional] -## Example - -```python -from jobset.models.jobset_v1alpha2_job_set_spec import JobsetV1alpha2JobSetSpec - -# TODO update the JSON string below -json = "{}" -# create an instance of JobsetV1alpha2JobSetSpec from a JSON string -jobset_v1alpha2_job_set_spec_instance = JobsetV1alpha2JobSetSpec.from_json(json) -# print the JSON string representation of the object -print(JobsetV1alpha2JobSetSpec.to_json()) - -# convert the object into a dict -jobset_v1alpha2_job_set_spec_dict = jobset_v1alpha2_job_set_spec_instance.to_dict() -# create an instance of JobsetV1alpha2JobSetSpec from a dict -jobset_v1alpha2_job_set_spec_from_dict = JobsetV1alpha2JobSetSpec.from_dict(jobset_v1alpha2_job_set_spec_dict) -``` [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/sdk/python/docs/JobsetV1alpha2JobSetStatus.md b/sdk/python/docs/JobsetV1alpha2JobSetStatus.md index a6d042367..f85bde4e4 100644 --- a/sdk/python/docs/JobsetV1alpha2JobSetStatus.md +++ b/sdk/python/docs/JobsetV1alpha2JobSetStatus.md @@ -1,34 +1,15 @@ # JobsetV1alpha2JobSetStatus JobSetStatus defines the observed state of JobSet - ## Properties - Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**conditions** | [**List[V1Condition]**](V1Condition.md) | | [optional] -**replicated_jobs_status** | [**List[JobsetV1alpha2ReplicatedJobStatus]**](JobsetV1alpha2ReplicatedJobStatus.md) | ReplicatedJobsStatus track the number of JobsReady for each replicatedJob. | [optional] +**conditions** | [**list[V1Condition]**](V1Condition.md) | | [optional] +**replicated_jobs_status** | [**list[JobsetV1alpha2ReplicatedJobStatus]**](JobsetV1alpha2ReplicatedJobStatus.md) | ReplicatedJobsStatus track the number of JobsReady for each replicatedJob. | [optional] **restarts** | **int** | Restarts tracks the number of times the JobSet has restarted (i.e. recreated in case of RecreateAll policy). | [optional] **restarts_count_towards_max** | **int** | RestartsCountTowardsMax tracks the number of times the JobSet has restarted that counts towards the maximum allowed number of restarts. | [optional] **terminal_state** | **str** | TerminalState the state of the JobSet when it finishes execution. It can be either Complete or Failed. Otherwise, it is empty by default. | [optional] -## Example - -```python -from jobset.models.jobset_v1alpha2_job_set_status import JobsetV1alpha2JobSetStatus - -# TODO update the JSON string below -json = "{}" -# create an instance of JobsetV1alpha2JobSetStatus from a JSON string -jobset_v1alpha2_job_set_status_instance = JobsetV1alpha2JobSetStatus.from_json(json) -# print the JSON string representation of the object -print(JobsetV1alpha2JobSetStatus.to_json()) - -# convert the object into a dict -jobset_v1alpha2_job_set_status_dict = jobset_v1alpha2_job_set_status_instance.to_dict() -# create an instance of JobsetV1alpha2JobSetStatus from a dict -jobset_v1alpha2_job_set_status_from_dict = JobsetV1alpha2JobSetStatus.from_dict(jobset_v1alpha2_job_set_status_dict) -``` [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/sdk/python/docs/JobsetV1alpha2Network.md b/sdk/python/docs/JobsetV1alpha2Network.md index 7ccb4822c..32cd4fb11 100644 --- a/sdk/python/docs/JobsetV1alpha2Network.md +++ b/sdk/python/docs/JobsetV1alpha2Network.md @@ -1,31 +1,12 @@ # JobsetV1alpha2Network - ## Properties - Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **enable_dns_hostnames** | **bool** | EnableDNSHostnames allows pods to be reached via their hostnames. Pods will be reachable using the fully qualified pod hostname: <jobSet.name>-<spec.replicatedJob.name>-<job-index>-<pod-index>.<subdomain> | [optional] **publish_not_ready_addresses** | **bool** | Indicates if DNS records of pods should be published before the pods are ready. Defaults to True. | [optional] **subdomain** | **str** | Subdomain is an explicit choice for a network subdomain name When set, any replicated job in the set is added to this network. Defaults to <jobSet.name> if not set. | [optional] -## Example - -```python -from jobset.models.jobset_v1alpha2_network import JobsetV1alpha2Network - -# TODO update the JSON string below -json = "{}" -# create an instance of JobsetV1alpha2Network from a JSON string -jobset_v1alpha2_network_instance = JobsetV1alpha2Network.from_json(json) -# print the JSON string representation of the object -print(JobsetV1alpha2Network.to_json()) - -# convert the object into a dict -jobset_v1alpha2_network_dict = jobset_v1alpha2_network_instance.to_dict() -# create an instance of JobsetV1alpha2Network from a dict -jobset_v1alpha2_network_from_dict = JobsetV1alpha2Network.from_dict(jobset_v1alpha2_network_dict) -``` [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/sdk/python/docs/JobsetV1alpha2ReplicatedJob.md b/sdk/python/docs/JobsetV1alpha2ReplicatedJob.md index 860e36a87..780d9e0b1 100644 --- a/sdk/python/docs/JobsetV1alpha2ReplicatedJob.md +++ b/sdk/python/docs/JobsetV1alpha2ReplicatedJob.md @@ -1,31 +1,12 @@ # JobsetV1alpha2ReplicatedJob - ## Properties - Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **name** | **str** | Name is the name of the entry and will be used as a suffix for the Job name. | [default to ''] **replicas** | **int** | Replicas is the number of jobs that will be created from this ReplicatedJob's template. Jobs names will be in the format: <jobSet.name>-<spec.replicatedJob.name>-<job-index> | [optional] **template** | [**V1JobTemplateSpec**](V1JobTemplateSpec.md) | | -## Example - -```python -from jobset.models.jobset_v1alpha2_replicated_job import JobsetV1alpha2ReplicatedJob - -# TODO update the JSON string below -json = "{}" -# create an instance of JobsetV1alpha2ReplicatedJob from a JSON string -jobset_v1alpha2_replicated_job_instance = JobsetV1alpha2ReplicatedJob.from_json(json) -# print the JSON string representation of the object -print(JobsetV1alpha2ReplicatedJob.to_json()) - -# convert the object into a dict -jobset_v1alpha2_replicated_job_dict = jobset_v1alpha2_replicated_job_instance.to_dict() -# create an instance of JobsetV1alpha2ReplicatedJob from a dict -jobset_v1alpha2_replicated_job_from_dict = JobsetV1alpha2ReplicatedJob.from_dict(jobset_v1alpha2_replicated_job_dict) -``` [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/sdk/python/docs/JobsetV1alpha2ReplicatedJobStatus.md b/sdk/python/docs/JobsetV1alpha2ReplicatedJobStatus.md index 02abbc3e6..09e1dea46 100644 --- a/sdk/python/docs/JobsetV1alpha2ReplicatedJobStatus.md +++ b/sdk/python/docs/JobsetV1alpha2ReplicatedJobStatus.md @@ -1,9 +1,7 @@ # JobsetV1alpha2ReplicatedJobStatus ReplicatedJobStatus defines the observed ReplicatedJobs Readiness. - ## 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] @@ -13,23 +11,6 @@ Name | Type | Description | Notes **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] -## Example - -```python -from jobset.models.jobset_v1alpha2_replicated_job_status import JobsetV1alpha2ReplicatedJobStatus - -# TODO update the JSON string below -json = "{}" -# create an instance of JobsetV1alpha2ReplicatedJobStatus from a JSON string -jobset_v1alpha2_replicated_job_status_instance = JobsetV1alpha2ReplicatedJobStatus.from_json(json) -# print the JSON string representation of the object -print(JobsetV1alpha2ReplicatedJobStatus.to_json()) - -# convert the object into a dict -jobset_v1alpha2_replicated_job_status_dict = jobset_v1alpha2_replicated_job_status_instance.to_dict() -# create an instance of JobsetV1alpha2ReplicatedJobStatus from a dict -jobset_v1alpha2_replicated_job_status_from_dict = JobsetV1alpha2ReplicatedJobStatus.from_dict(jobset_v1alpha2_replicated_job_status_dict) -``` [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/sdk/python/docs/JobsetV1alpha2StartupPolicy.md b/sdk/python/docs/JobsetV1alpha2StartupPolicy.md index 32d3eaf13..58bab97da 100644 --- a/sdk/python/docs/JobsetV1alpha2StartupPolicy.md +++ b/sdk/python/docs/JobsetV1alpha2StartupPolicy.md @@ -1,29 +1,10 @@ # JobsetV1alpha2StartupPolicy - ## Properties - Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **startup_policy_order** | **str** | StartupPolicyOrder determines the startup order of the ReplicatedJobs. AnyOrder means to start replicated jobs in any order. InOrder means to start them as they are listed in the JobSet. A ReplicatedJob is started only when all the jobs of the previous one are ready. | [default to ''] -## Example - -```python -from jobset.models.jobset_v1alpha2_startup_policy import JobsetV1alpha2StartupPolicy - -# TODO update the JSON string below -json = "{}" -# create an instance of JobsetV1alpha2StartupPolicy from a JSON string -jobset_v1alpha2_startup_policy_instance = JobsetV1alpha2StartupPolicy.from_json(json) -# print the JSON string representation of the object -print(JobsetV1alpha2StartupPolicy.to_json()) - -# convert the object into a dict -jobset_v1alpha2_startup_policy_dict = jobset_v1alpha2_startup_policy_instance.to_dict() -# create an instance of JobsetV1alpha2StartupPolicy from a dict -jobset_v1alpha2_startup_policy_from_dict = JobsetV1alpha2StartupPolicy.from_dict(jobset_v1alpha2_startup_policy_dict) -``` [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/sdk/python/docs/JobsetV1alpha2SuccessPolicy.md b/sdk/python/docs/JobsetV1alpha2SuccessPolicy.md index ecfb7c868..a1b34da12 100644 --- a/sdk/python/docs/JobsetV1alpha2SuccessPolicy.md +++ b/sdk/python/docs/JobsetV1alpha2SuccessPolicy.md @@ -1,30 +1,11 @@ # JobsetV1alpha2SuccessPolicy - ## Properties - Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **operator** | **str** | Operator determines either All or Any of the selected jobs should succeed to consider the JobSet successful | [default to ''] -**target_replicated_jobs** | **List[str]** | TargetReplicatedJobs are the names of the replicated jobs the operator will apply to. A null or empty list will apply to all replicatedJobs. | [optional] - -## Example - -```python -from jobset.models.jobset_v1alpha2_success_policy import JobsetV1alpha2SuccessPolicy - -# TODO update the JSON string below -json = "{}" -# create an instance of JobsetV1alpha2SuccessPolicy from a JSON string -jobset_v1alpha2_success_policy_instance = JobsetV1alpha2SuccessPolicy.from_json(json) -# print the JSON string representation of the object -print(JobsetV1alpha2SuccessPolicy.to_json()) +**target_replicated_jobs** | **list[str]** | TargetReplicatedJobs are the names of the replicated jobs the operator will apply to. A null or empty list will apply to all replicatedJobs. | [optional] -# convert the object into a dict -jobset_v1alpha2_success_policy_dict = jobset_v1alpha2_success_policy_instance.to_dict() -# create an instance of JobsetV1alpha2SuccessPolicy from a dict -jobset_v1alpha2_success_policy_from_dict = JobsetV1alpha2SuccessPolicy.from_dict(jobset_v1alpha2_success_policy_dict) -``` [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/sdk/python/git_push.sh b/sdk/python/git_push.sh index f53a75d4f..ced3be2b0 100644 --- a/sdk/python/git_push.sh +++ b/sdk/python/git_push.sh @@ -1,7 +1,7 @@ #!/bin/sh # ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ # -# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" +# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com" git_user_id=$1 git_repo_id=$2 @@ -38,14 +38,14 @@ git add . git commit -m "$release_note" # Sets the new remote -git_remote=$(git remote) +git_remote=`git remote` if [ "$git_remote" = "" ]; then # git remote not defined if [ "$GIT_TOKEN" = "" ]; then echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git else - git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git + git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git fi fi @@ -55,3 +55,4 @@ git pull origin master # Pushes (Forces) the changes in the local repository up to the remote repository echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" git push origin master 2>&1 | grep -v 'To https' + diff --git a/sdk/python/jobset/__init__.py b/sdk/python/jobset/__init__.py index 479be3a8a..1bd1f4f35 100644 --- a/sdk/python/jobset/__init__.py +++ b/sdk/python/jobset/__init__.py @@ -5,30 +5,27 @@ """ JobSet SDK - Python SDK for the JobSet API + Python SDK for the JobSet API # noqa: E501 The version of the OpenAPI document: v0.1.4 - Generated by OpenAPI Generator (https://openapi-generator.tech) + Generated by: https://openapi-generator.tech +""" - Do not edit the class manually. -""" # noqa: E501 +from __future__ import absolute_import __version__ = "0.1.4" # import apis into sdk package # import ApiClient -from jobset.api_response import ApiResponse from jobset.api_client import ApiClient from jobset.configuration import Configuration from jobset.exceptions import OpenApiException from jobset.exceptions import ApiTypeError from jobset.exceptions import ApiValueError from jobset.exceptions import ApiKeyError -from jobset.exceptions import ApiAttributeError from jobset.exceptions import ApiException - # import models into sdk package from jobset.models.jobset_v1alpha2_coordinator import JobsetV1alpha2Coordinator from jobset.models.jobset_v1alpha2_failure_policy import JobsetV1alpha2FailurePolicy @@ -42,3 +39,4 @@ from jobset.models.jobset_v1alpha2_replicated_job_status import JobsetV1alpha2ReplicatedJobStatus from jobset.models.jobset_v1alpha2_startup_policy import JobsetV1alpha2StartupPolicy from jobset.models.jobset_v1alpha2_success_policy import JobsetV1alpha2SuccessPolicy + diff --git a/sdk/python/jobset/api/__init__.py b/sdk/python/jobset/api/__init__.py index c3bb408f1..36dce7fe2 100644 --- a/sdk/python/jobset/api/__init__.py +++ b/sdk/python/jobset/api/__init__.py @@ -1,4 +1,5 @@ +from __future__ import absolute_import + # flake8: noqa # import apis into api package - diff --git a/sdk/python/jobset/api_client.py b/sdk/python/jobset/api_client.py index c8ab70fc6..ca5ba1df4 100644 --- a/sdk/python/jobset/api_client.py +++ b/sdk/python/jobset/api_client.py @@ -1,48 +1,36 @@ # coding: utf-8 - """ JobSet SDK - Python SDK for the JobSet API + Python SDK for the JobSet API # noqa: E501 The version of the OpenAPI document: v0.1.4 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 + Generated by: https://openapi-generator.tech +""" +from __future__ import absolute_import +import atexit import datetime from dateutil.parser import parse -from enum import Enum -import decimal import json import mimetypes +from multiprocessing.pool import ThreadPool import os import re import tempfile -from urllib.parse import quote -from typing import Tuple, Optional, List, Dict, Union -from pydantic import SecretStr +# python 2 and python 3 compatibility library +import six +from six.moves.urllib.parse import quote from jobset.configuration import Configuration -from jobset.api_response import ApiResponse, T as ApiResponseT import jobset.models from jobset import rest -from jobset.exceptions import ( - ApiValueError, - ApiException, - BadRequestException, - UnauthorizedException, - ForbiddenException, - NotFoundException, - ServiceException -) - -RequestSerialized = Tuple[str, str, Dict[str, str], Optional[str], List[str]] - -class ApiClient: +from jobset.exceptions import ApiValueError, ApiException + + +class ApiClient(object): """Generic API client for OpenAPI client library builds. OpenAPI generic API client. This client handles the client- @@ -50,39 +38,39 @@ class ApiClient: 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, str, int) + PRIMITIVE_TYPES = (float, bool, bytes, six.text_type) + six.integer_types NATIVE_TYPES_MAPPING = { 'int': int, - 'long': int, # TODO remove as only py3 is supported? + 'long': int if six.PY3 else long, # noqa: F821 'float': float, 'str': str, 'bool': bool, 'date': datetime.date, 'datetime': datetime.datetime, - 'decimal': decimal.Decimal, 'object': object, } _pool = None - def __init__( - self, - configuration=None, - header_name=None, - header_value=None, - cookie=None - ) -> None: - # use default configuration if none is provided + def __init__(self, configuration=None, header_name=None, header_value=None, + cookie=None, pool_threads=1): if configuration is None: - configuration = Configuration.get_default() + configuration = Configuration.get_default_copy() self.configuration = configuration + self.pool_threads = pool_threads self.rest_client = rest.RESTClientObject(configuration) self.default_headers = {} @@ -97,7 +85,25 @@ def __enter__(self): return self def __exit__(self, exc_type, exc_value, traceback): - pass + 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): @@ -111,69 +117,12 @@ def user_agent(self, value): def set_default_header(self, header_name, header_value): self.default_headers[header_name] = header_value - - _default = None - - @classmethod - def get_default(cls): - """Return new instance of ApiClient. - - This method returns newly created, based on default constructor, - object of ApiClient class or returns a copy of default - ApiClient. - - :return: The ApiClient object. - """ - if cls._default is None: - cls._default = ApiClient() - return cls._default - - @classmethod - def set_default(cls, default): - """Set default instance of ApiClient. - - It stores default ApiClient. - - :param default: object of ApiClient. - """ - cls._default = default - - def param_serialize( - self, - method, - resource_path, - path_params=None, - query_params=None, - header_params=None, - body=None, - post_params=None, - files=None, auth_settings=None, - collection_formats=None, - _host=None, - _request_auth=None - ) -> RequestSerialized: - - """Builds the HTTP request params needed by the request. - :param method: Method to call. - :param resource_path: Path to method endpoint. - :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 files dict: key -> filename, value -> filepath, - for `multipart/form-data`. - :param collection_formats: dict of collection formats for path, query, - header, and post parameters. - :param _request_auth: set to override the auth_settings for an a single - request; this effectively ignores the authentication - in the spec for a single request. - :return: tuple of form (path, http_method, query_params, header_params, - body, post_params, files) - """ + 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 @@ -184,17 +133,14 @@ def param_serialize( 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) - ) + 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 - ) + 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( @@ -202,145 +148,80 @@ def param_serialize( 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 - ) - if files: - post_params.extend(self.files_parameters(files)) + 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, - resource_path, - method, - body, - request_auth=_request_auth - ) + 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 or self.configuration.ignore_operation_servers: + if _host is None: url = self.configuration.host + resource_path else: # use server/host defined in path or operation instead url = _host + resource_path - # query parameters - if query_params: - query_params = self.sanitize_for_serialization(query_params) - url_query = self.parameters_to_url_query( - query_params, - collection_formats - ) - url += "?" + url_query - - return method, url, header_params, body, post_params - - - def call_api( - self, - method, - url, - header_params=None, - body=None, - post_params=None, - _request_timeout=None - ) -> rest.RESTResponse: - """Makes the HTTP request (synchronous) - :param method: Method to call. - :param url: Path to method endpoint. - :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 _request_timeout: timeout setting for this request. - :return: RESTResponse - """ - try: # perform request and return response - response_data = self.rest_client.request( - method, url, - headers=header_params, - body=body, post_params=post_params, - _request_timeout=_request_timeout - ) - + 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 - return response_data + content_type = response_data.getheader('content-type') - def response_deserialize( - self, - response_data: rest.RESTResponse, - response_types_map: Optional[Dict[str, ApiResponseT]]=None - ) -> ApiResponse[ApiResponseT]: - """Deserializes response into an object. - :param response_data: RESTResponse object to be deserialized. - :param response_types_map: dict of response types. - :return: ApiResponse - """ + self.last_response = response_data + + return_data = response_data - msg = "RESTResponse.read() must be called before passing it to response_deserialize()" - assert response_data.data is not None, msg + if not _preload_content: + return return_data - response_type = response_types_map.get(str(response_data.status), None) - if not response_type and isinstance(response_data.status, int) and 100 <= response_data.status <= 599: - # if not found, look for '1XX', '2XX', etc. - response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) + 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 - response_text = None - return_data = None - try: - if response_type == "bytearray": - return_data = response_data.data - elif response_type == "file": - return_data = self.__deserialize_file(response_data) - elif response_type is not None: - match = None - content_type = response_data.getheader('content-type') - 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_text = response_data.data.decode(encoding) - return_data = self.deserialize(response_text, response_type, content_type) - finally: - if not 200 <= response_data.status <= 299: - raise ApiException.from_response( - http_resp=response_data, - body=response_text, - data=return_data, - ) + if response_type: + return_data = self.deserialize(response_data, response_type) + else: + return_data = None - return ApiResponse( - status_code = response_data.status, - data = return_data, - headers = response_data.getheaders(), - raw_data = response_data.data - ) + 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 SecretStr, return obj.get_secret_value() 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 decimal.Decimal return string representation. 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. @@ -350,26 +231,18 @@ def sanitize_for_serialization(self, obj): """ if obj is None: return None - elif isinstance(obj, Enum): - return obj.value - elif isinstance(obj, SecretStr): - return obj.get_secret_value() elif isinstance(obj, self.PRIMITIVE_TYPES): return obj elif isinstance(obj, list): - return [ - self.sanitize_for_serialization(sub_obj) for sub_obj in obj - ] + return [self.sanitize_for_serialization(sub_obj) + for sub_obj in obj] elif isinstance(obj, tuple): - return tuple( - self.sanitize_for_serialization(sub_obj) for sub_obj in obj - ) + return tuple(self.sanitize_for_serialization(sub_obj) + for sub_obj in obj) elif isinstance(obj, (datetime.datetime, datetime.date)): return obj.isoformat() - elif isinstance(obj, decimal.Decimal): - return str(obj) - elif isinstance(obj, dict): + if isinstance(obj, dict): obj_dict = obj else: # Convert model obj to dict except @@ -377,45 +250,32 @@ def sanitize_for_serialization(self, obj): # and attributes which value is not None. # Convert attribute name to json key in # model definition for request. - if hasattr(obj, 'to_dict') and callable(getattr(obj, 'to_dict')): - obj_dict = obj.to_dict() - else: - obj_dict = obj.__dict__ + 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 obj_dict.items() - } + return {key: self.sanitize_for_serialization(val) + for key, val in six.iteritems(obj_dict)} - def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]): + 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. - :param content_type: content type of response. :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 - if content_type is None: - try: - data = json.loads(response_text) - except ValueError: - data = response_text - elif re.match(r'^application/(json|[\w!#$&.+-^_]+\+json)\s*(;|$)', content_type, re.IGNORECASE): - if response_text == "": - data = "" - else: - data = json.loads(response_text) - elif re.match(r'^text/plain\s*(;|$)', content_type, re.IGNORECASE): - data = response_text - else: - raise ApiException( - status=0, - reason="Unsupported content type: {0}".format(content_type) - ) + try: + data = json.loads(response.data) + except ValueError: + data = response.data return self.__deserialize(data, response_type) @@ -430,20 +290,16 @@ def __deserialize(self, data, klass): if data is None: return None - if isinstance(klass, str): - if klass.startswith('List['): - m = re.match(r'List\[(.*)]', klass) - assert m is not None, "Malformed List type definition" - sub_kls = m.group(1) + 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['): - m = re.match(r'Dict\[([^,]*), (.*)]', klass) - assert m is not None, "Malformed Dict type definition" - sub_kls = m.group(2) + if klass.startswith('dict('): + sub_kls = re.match(r'dict\(([^,]*), (.*)\)', klass).group(2) return {k: self.__deserialize(v, sub_kls) - for k, v in data.items()} + for k, v in six.iteritems(data)} # convert str to class if klass in self.NATIVE_TYPES_MAPPING: @@ -459,13 +315,131 @@ def __deserialize(self, data, klass): return self.__deserialize_date(data) elif klass == datetime.datetime: return self.__deserialize_datetime(data) - elif klass == decimal.Decimal: - return decimal.Decimal(data) - elif issubclass(klass, Enum): - return self.__deserialize_enum(data, klass) 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. @@ -473,10 +447,10 @@ def parameters_to_tuples(self, params, collection_formats): :param dict collection_formats: Parameter collection formats :return: Parameters as list of tuples, collections formatted """ - new_params: List[Tuple[str, str]] = [] + new_params = [] if collection_formats is None: collection_formats = {} - for k, v in params.items() if isinstance(params, dict) else params: + 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': @@ -496,94 +470,45 @@ def parameters_to_tuples(self, params, collection_formats): new_params.append((k, v)) return new_params - def parameters_to_url_query(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: URL query string (e.g. a=Hello%20World&b=123) - """ - new_params: List[Tuple[str, str]] = [] - if collection_formats is None: - collection_formats = {} - for k, v in params.items() if isinstance(params, dict) else params: - if isinstance(v, bool): - v = str(v).lower() - if isinstance(v, (int, float)): - v = str(v) - if isinstance(v, dict): - v = json.dumps(v) - - if k in collection_formats: - collection_format = collection_formats[k] - if collection_format == 'multi': - new_params.extend((k, str(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(quote(str(value)) for value in v)) - ) - else: - new_params.append((k, quote(str(v)))) - - return "&".join(["=".join(map(str, item)) for item in new_params]) - - def files_parameters( - self, - files: Dict[str, Union[str, bytes, List[str], List[bytes], Tuple[str, bytes]]], - ): + def files_parameters(self, files=None): """Builds form parameters. :param files: File parameters. :return: Form parameters with files. """ params = [] - for k, v in files.items(): - if isinstance(v, str): - with open(v, 'rb') as f: - filename = os.path.basename(f.name) - filedata = f.read() - elif isinstance(v, bytes): - filename = k - filedata = v - elif isinstance(v, tuple): - filename, filedata = v - elif isinstance(v, list): - for file_param in v: - params.extend(self.files_parameters({k: file_param})) - continue - else: - raise ValueError("Unsupported file value") - mimetype = ( - mimetypes.guess_type(filename)[0] - or 'application/octet-stream' - ) - params.append( - tuple([k, tuple([filename, filedata, mimetype])]) - ) + + 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: List[str]) -> Optional[str]: + 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 None + return - for accept in accepts: - if re.search('json', accept, re.IGNORECASE): - return accept + accepts = [x.lower() for x in accepts] - return accepts[0] + 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. @@ -592,101 +517,45 @@ def select_header_content_type(self, content_types): :return: Content-Type (e.g. application/json). """ if not content_types: - return None + return 'application/json' - for content_type in content_types: - if re.search('json', content_type, re.IGNORECASE): - return content_type - - return content_types[0] - - def update_params_for_auth( - self, - headers, - queries, - auth_settings, - resource_path, - method, - body, - request_auth=None - ) -> None: + 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 queries: Query parameters tuple list to be updated. + :param querys: Query parameters tuple list to be updated. :param auth_settings: Authentication setting identifiers list. - :resource_path: A string representation of the HTTP request resource path. - :method: A string representation of the HTTP request method. - :body: A object representing the body of the HTTP request. - The object type is the return value of sanitize_for_serialization(). - :param request_auth: if set, the provided settings will - override the token in the configuration. """ if not auth_settings: return - if request_auth: - self._apply_auth_params( - headers, - queries, - resource_path, - method, - body, - request_auth - ) - else: - for auth in auth_settings: - auth_setting = self.configuration.auth_settings().get(auth) - if auth_setting: - self._apply_auth_params( - headers, - queries, - resource_path, - method, - body, - auth_setting + 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 _apply_auth_params( - self, - headers, - queries, - resource_path, - method, - body, - auth_setting - ) -> None: - """Updates the request parameters based on a single auth_setting - - :param headers: Header parameters dict to be updated. - :param queries: Query parameters tuple list to be updated. - :resource_path: A string representation of the HTTP request resource path. - :method: A string representation of the HTTP request method. - :body: A object representing the body of the HTTP request. - The object type is the return value of sanitize_for_serialization(). - :param auth_setting: auth settings for the endpoint - """ - if auth_setting['in'] == 'cookie': - headers['Cookie'] = auth_setting['value'] - elif auth_setting['in'] == 'header': - if auth_setting['type'] != 'http-signature': - headers[auth_setting['key']] = auth_setting['value'] - elif auth_setting['in'] == 'query': - queries.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. - handle file downloading - save response body into a tmp file and return the instance - :param response: RESTResponse. :return: file path. """ @@ -696,12 +565,8 @@ def __deserialize_file(self, response): content_disposition = response.getheader("Content-Disposition") if content_disposition: - m = re.search( - r'filename=[\'"]?([^\'"\s]+)[\'"]?', - content_disposition - ) - assert m is not None, "Unexpected 'content-disposition' header value" - filename = m.group(1) + 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: @@ -720,7 +585,7 @@ def __deserialize_primitive(self, data, klass): try: return klass(data) except UnicodeEncodeError: - return str(data) + return six.text_type(data) except TypeError: return data @@ -768,24 +633,6 @@ def __deserialize_datetime(self, string): ) ) - def __deserialize_enum(self, data, klass): - """Deserializes primitive type to enum. - - :param data: primitive type. - :param klass: class literal. - :return: enum value. - """ - try: - return klass(data) - except ValueError: - raise rest.ApiException( - status=0, - reason=( - "Failed to parse `{0}` as `{1}`" - .format(data, klass) - ) - ) - def __deserialize_model(self, data, klass): """Deserializes list or dict to model. @@ -793,5 +640,27 @@ def __deserialize_model(self, data, klass): :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 - return klass.from_dict(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/python/jobset/api_response.py b/sdk/python/jobset/api_response.py deleted file mode 100644 index 9bc7c11f6..000000000 --- a/sdk/python/jobset/api_response.py +++ /dev/null @@ -1,21 +0,0 @@ -"""API response object.""" - -from __future__ import annotations -from typing import Optional, Generic, Mapping, TypeVar -from pydantic import Field, StrictInt, StrictBytes, BaseModel - -T = TypeVar("T") - -class ApiResponse(BaseModel, Generic[T]): - """ - API response object - """ - - status_code: StrictInt = Field(description="HTTP status code") - headers: Optional[Mapping[str, str]] = Field(None, description="HTTP headers") - data: T = Field(description="Deserialized data given the data type") - raw_data: StrictBytes = Field(description="Raw data (HTTP response body)") - - model_config = { - "arbitrary_types_allowed": True - } diff --git a/sdk/python/jobset/configuration.py b/sdk/python/jobset/configuration.py index 6c9802fb6..75920b63d 100644 --- a/sdk/python/jobset/configuration.py +++ b/sdk/python/jobset/configuration.py @@ -3,94 +3,67 @@ """ JobSet SDK - Python SDK for the JobSet API + Python SDK for the JobSet API # noqa: E501 The version of the OpenAPI document: v0.1.4 - Generated by OpenAPI Generator (https://openapi-generator.tech) + Generated by: https://openapi-generator.tech +""" - Do not edit the class manually. -""" # noqa: E501 +from __future__ import absolute_import import copy import logging -from logging import FileHandler import multiprocessing import sys -from typing import Optional import urllib3 -import http.client as httplib +import six +from six.moves import http_client as httplib -JSON_SCHEMA_VALIDATION_KEYWORDS = { - 'multipleOf', 'maximum', 'exclusiveMaximum', - 'minimum', 'exclusiveMinimum', 'maxLength', - 'minLength', 'pattern', 'maxItems', 'minItems' -} -class Configuration: - """This class contains various settings of the API client. +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 ignore_operation_servers - Boolean to ignore operation servers for the API client. - Config will use `host` as the base url regardless of the operation servers. + :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). + :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 access_token: Access token. - :param server_index: Index to servers configuration. - :param server_variables: Mapping with string values to replace variables in - templated server configuration. The validation of enums is performed for - variables with defined enum values before. - :param server_operation_index: Mapping from operation ID to an index to server - configuration. - :param server_operation_variables: Mapping from operation ID to a mapping with - string values to replace variables in templated server configuration. - The validation of enums is performed for variables with defined enum - values before. - :param ssl_ca_cert: str - the path to a file of concatenated CA certificates - in PEM format. - :param retries: Number of retries for API requests. + :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=None, + def __init__(self, host="http://localhost", api_key=None, api_key_prefix=None, username=None, password=None, - access_token=None, - server_index=None, server_variables=None, - server_operation_index=None, server_operation_variables=None, - ignore_operation_servers=False, - ssl_ca_cert=None, - retries=None, - *, - debug: Optional[bool] = None - ) -> None: + discard_unknown_keys=False, + ): """Constructor """ - self._base_path = "http://localhost" if host is None else host + self.host = host """Default Base url """ - self.server_index = 0 if server_index is None and host is None else server_index - self.server_operation_index = server_operation_index or {} - """Default server index - """ - self.server_variables = server_variables or {} - self.server_operation_variables = server_operation_variables or {} - """Default server variables - """ - self.ignore_operation_servers = ignore_operation_servers - """Ignore operation servers - """ self.temp_folder_path = None """Temp file folder for downloading files """ @@ -114,9 +87,7 @@ def __init__(self, host=None, self.password = password """Password for HTTP basic authentication """ - self.access_token = access_token - """Access token - """ + self.discard_unknown_keys = discard_unknown_keys self.logger = {} """Logging Settings """ @@ -128,16 +99,13 @@ def __init__(self, host=None, self.logger_stream_handler = None """Log stream handler """ - self.logger_file_handler: Optional[FileHandler] = None + self.logger_file_handler = None """Log file handler """ self.logger_file = None """Debug file location """ - if debug is not None: - self.debug = debug - else: - self.__debug = False + self.debug = False """Debug switch """ @@ -146,7 +114,7 @@ def __init__(self, host=None, Set this to false to skip verifying SSL certificate when calling API from https server. """ - self.ssl_ca_cert = ssl_ca_cert + self.ssl_ca_cert = None """Set this to customize the certificate file to verify the peer. """ self.cert_file = None @@ -158,10 +126,6 @@ def __init__(self, host=None, self.assert_hostname = None """Set this to True/False to enable/disable SSL hostname verification. """ - self.tls_server_name = None - """SSL/TLS Server Name Indication (SNI) - Set this to the SNI value expected by the server. - """ self.connection_pool_maxsize = multiprocessing.cpu_count() * 5 """urllib3 connection pool's maximum number of connections saved @@ -171,7 +135,7 @@ def __init__(self, host=None, cpu_count * 5 is used as default value to increase performance. """ - self.proxy: Optional[str] = None + self.proxy = None """Proxy URL """ self.proxy_headers = None @@ -180,24 +144,12 @@ def __init__(self, host=None, self.safe_chars_for_path_param = '' """Safe chars for path_param """ - self.retries = retries + self.retries = None """Adding retries to override urllib3 default value 3 """ - # Enable client side validation + # Disable client side validation self.client_side_validation = True - self.socket_options = None - """Options to pass down to the underlying urllib3 socket - """ - - self.datetime_format = "%Y-%m-%dT%H:%M:%S.%f%z" - """datetime format - """ - - self.date_format = "%Y-%m-%d" - """date format - """ - def __deepcopy__(self, memo): cls = self.__class__ result = cls.__new__(cls) @@ -224,31 +176,21 @@ def set_default(cls, default): :param default: object of Configuration """ - cls._default = default + cls._default = copy.deepcopy(default) @classmethod def get_default_copy(cls): - """Deprecated. Please use `get_default` instead. - - Deprecated. Please use `get_default` instead. - - :return: The configuration object. - """ - return cls.get_default() - - @classmethod - def get_default(cls): - """Return the default configuration. + """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. + configuration passed by the set_default method. :return: The configuration object. """ - if cls._default is None: - cls._default = Configuration() - return cls._default + if cls._default is not None: + return copy.deepcopy(cls._default) + return Configuration() @property def logger_file(self): @@ -278,7 +220,7 @@ def logger_file(self, value): # 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 self.logger.items(): + for _, logger in six.iteritems(self.logger): logger.addHandler(self.logger_file_handler) @property @@ -300,14 +242,14 @@ def debug(self, value): self.__debug = value if self.__debug: # if debug status is True, turn on debug logging - for _, logger in self.logger.items(): + 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 self.logger.items(): + for _, logger in six.iteritems(self.logger): logger.setLevel(logging.WARNING) # turn off httplib debug httplib.HTTPConnection.debuglevel = 0 @@ -335,16 +277,15 @@ def logger_format(self, value): self.__logger_format = value self.logger_formatter = logging.Formatter(self.__logger_format) - def get_api_key_with_prefix(self, identifier, alias=None): + def get_api_key_with_prefix(self, identifier): """Gets API key (with prefix if set). :param identifier: The identifier of apiKey. - :param alias: The alternative 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, self.api_key.get(alias) if alias is not None else None) + key = self.api_key.get(identifier) if key: prefix = self.api_key_prefix.get(identifier) if prefix: @@ -394,23 +335,19 @@ def get_host_settings(self): """ return [ { - 'url': "", + 'url': "/", 'description': "No description provided", } ] - def get_host_from_settings(self, index, variables=None, servers=None): + 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 - :param servers: an array of host settings or None :return: URL based on host settings """ - if index is None: - return self._base_path - variables = {} if variables is None else variables - servers = self.get_host_settings() if servers is None else servers + servers = self.get_host_settings() try: server = servers[index] @@ -422,7 +359,7 @@ def get_host_from_settings(self, index, variables=None, servers=None): url = server['url'] # go through variables and replace placeholders - for variable_name, variable in server.get('variables', {}).items(): + for variable_name, variable in server['variables'].items(): used_value = variables.get( variable_name, variable['default_value']) @@ -437,14 +374,3 @@ def get_host_from_settings(self, index, variables=None, servers=None): url = url.replace("{" + variable_name + "}", used_value) return url - - @property - def host(self): - """Return generated host.""" - return self.get_host_from_settings(self.server_index, variables=self.server_variables) - - @host.setter - def host(self, value): - """Fix base path.""" - self._base_path = value - self.server_index = None diff --git a/sdk/python/jobset/exceptions.py b/sdk/python/jobset/exceptions.py index 28eb8c540..a4eca1a04 100644 --- a/sdk/python/jobset/exceptions.py +++ b/sdk/python/jobset/exceptions.py @@ -3,16 +3,15 @@ """ JobSet SDK - Python SDK for the JobSet API + Python SDK for the JobSet API # noqa: E501 The version of the OpenAPI document: v0.1.4 - Generated by OpenAPI Generator (https://openapi-generator.tech) + Generated by: https://openapi-generator.tech +""" + - Do not edit the class manually. -""" # noqa: E501 +import six -from typing import Any, Optional -from typing_extensions import Self class OpenApiException(Exception): """The base exception class for all OpenAPIExceptions""" @@ -20,7 +19,7 @@ class OpenApiException(Exception): class ApiTypeError(OpenApiException, TypeError): def __init__(self, msg, path_to_item=None, valid_classes=None, - key_type=None) -> None: + key_type=None): """ Raises an exception for TypeErrors Args: @@ -48,7 +47,7 @@ def __init__(self, msg, path_to_item=None, valid_classes=None, class ApiValueError(OpenApiException, ValueError): - def __init__(self, msg, path_to_item=None) -> None: + def __init__(self, msg, path_to_item=None): """ Args: msg (str): the exception message @@ -65,27 +64,8 @@ def __init__(self, msg, path_to_item=None) -> None: super(ApiValueError, self).__init__(full_msg) -class ApiAttributeError(OpenApiException, AttributeError): - def __init__(self, msg, path_to_item=None) -> None: - """ - Raised when an attribute reference or assignment fails. - - 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(ApiAttributeError, self).__init__(full_msg) - - class ApiKeyError(OpenApiException, KeyError): - def __init__(self, msg, path_to_item=None) -> None: + def __init__(self, msg, path_to_item=None): """ Args: msg (str): the exception message @@ -103,56 +83,17 @@ def __init__(self, msg, path_to_item=None) -> None: class ApiException(OpenApiException): - def __init__( - self, - status=None, - reason=None, - http_resp=None, - *, - body: Optional[str] = None, - data: Optional[Any] = None, - ) -> None: - self.status = status - self.reason = reason - self.body = body - self.data = data - self.headers = None - + def __init__(self, status=None, reason=None, http_resp=None): if http_resp: - if self.status is None: - self.status = http_resp.status - if self.reason is None: - self.reason = http_resp.reason - if self.body is None: - try: - self.body = http_resp.data.decode('utf-8') - except Exception: - pass + self.status = http_resp.status + self.reason = http_resp.reason + self.body = http_resp.data self.headers = http_resp.getheaders() - - @classmethod - def from_response( - cls, - *, - http_resp, - body: Optional[str], - data: Optional[Any], - ) -> Self: - if http_resp.status == 400: - raise BadRequestException(http_resp=http_resp, body=body, data=data) - - if http_resp.status == 401: - raise UnauthorizedException(http_resp=http_resp, body=body, data=data) - - if http_resp.status == 403: - raise ForbiddenException(http_resp=http_resp, body=body, data=data) - - if http_resp.status == 404: - raise NotFoundException(http_resp=http_resp, body=body, data=data) - - if 500 <= http_resp.status <= 599: - raise ServiceException(http_resp=http_resp, body=body, data=data) - raise ApiException(http_resp=http_resp, body=body, data=data) + else: + self.status = status + self.reason = reason + self.body = None + self.headers = None def __str__(self): """Custom error messages for exception""" @@ -162,37 +103,17 @@ def __str__(self): error_message += "HTTP response headers: {0}\n".format( self.headers) - if self.data or self.body: - error_message += "HTTP response body: {0}\n".format(self.data or self.body) + if self.body: + error_message += "HTTP response body: {0}\n".format(self.body) return error_message -class BadRequestException(ApiException): - pass - - -class NotFoundException(ApiException): - pass - - -class UnauthorizedException(ApiException): - pass - - -class ForbiddenException(ApiException): - pass - - -class ServiceException(ApiException): - pass - - def render_path(path_to_item): """Returns a string representation of a path""" result = "" for pth in path_to_item: - if isinstance(pth, int): + if isinstance(pth, six.integer_types): result += "[{0}]".format(pth) else: result += "['{0}']".format(pth) diff --git a/sdk/python/jobset/models/__init__.py b/sdk/python/jobset/models/__init__.py index 825ed79e2..913baa991 100644 --- a/sdk/python/jobset/models/__init__.py +++ b/sdk/python/jobset/models/__init__.py @@ -4,14 +4,17 @@ """ JobSet SDK - Python SDK for the JobSet API + Python SDK for the JobSet API # noqa: E501 The version of the OpenAPI document: v0.1.4 - Generated by OpenAPI Generator (https://openapi-generator.tech) + Generated by: https://openapi-generator.tech +""" + - Do not edit the class manually. -""" # noqa: E501 +from __future__ import absolute_import +# Import Kubernetes models. +from kubernetes.client import * # import models into model package from jobset.models.jobset_v1alpha2_coordinator import JobsetV1alpha2Coordinator diff --git a/sdk/python/jobset/models/jobset_v1alpha2_coordinator.py b/sdk/python/jobset/models/jobset_v1alpha2_coordinator.py index 87bdac20c..44cfce404 100644 --- a/sdk/python/jobset/models/jobset_v1alpha2_coordinator.py +++ b/sdk/python/jobset/models/jobset_v1alpha2_coordinator.py @@ -3,89 +3,177 @@ """ JobSet SDK - Python SDK for the JobSet API + Python SDK for the JobSet API # noqa: E501 The version of the OpenAPI document: v0.1.4 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 + Generated by: https://openapi-generator.tech +""" -from __future__ import annotations import pprint import re # noqa: F401 -import json -from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self +import six + +from jobset.configuration import Configuration -class JobsetV1alpha2Coordinator(BaseModel): + +class JobsetV1alpha2Coordinator(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. """ - Coordinator defines which pod can be marked as the coordinator for the JobSet workload. - """ # noqa: E501 - job_index: Optional[StrictInt] = Field(default=None, description="JobIndex is the index of Job which contains the coordinator pod (i.e., for a ReplicatedJob with N replicas, there are Job indexes 0 to N-1).", alias="jobIndex") - pod_index: Optional[StrictInt] = Field(default=None, description="PodIndex is the Job completion index of the coordinator pod.", alias="podIndex") - replicated_job: StrictStr = Field(description="ReplicatedJob is the name of the ReplicatedJob which contains the coordinator pod.", alias="replicatedJob") - __properties: ClassVar[List[str]] = ["jobIndex", "podIndex", "replicatedJob"] - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of JobsetV1alpha2Coordinator from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. + + """ + 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 = { + 'job_index': 'int', + 'pod_index': 'int', + 'replicated_job': 'str' + } + + attribute_map = { + 'job_index': 'jobIndex', + 'pod_index': 'podIndex', + 'replicated_job': 'replicatedJob' + } + + def __init__(self, job_index=None, pod_index=None, replicated_job='', local_vars_configuration=None): # noqa: E501 + """JobsetV1alpha2Coordinator - 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._job_index = None + self._pod_index = None + self._replicated_job = None + self.discriminator = None + + if job_index is not None: + self.job_index = job_index + if pod_index is not None: + self.pod_index = pod_index + self.replicated_job = replicated_job + + @property + def job_index(self): + """Gets the job_index of this JobsetV1alpha2Coordinator. # noqa: E501 + + JobIndex is the index of Job which contains the coordinator pod (i.e., for a ReplicatedJob with N replicas, there are Job indexes 0 to N-1). # noqa: E501 + + :return: The job_index of this JobsetV1alpha2Coordinator. # noqa: E501 + :rtype: int + """ + return self._job_index + + @job_index.setter + def job_index(self, job_index): + """Sets the job_index of this JobsetV1alpha2Coordinator. + + JobIndex is the index of Job which contains the coordinator pod (i.e., for a ReplicatedJob with N replicas, there are Job indexes 0 to N-1). # noqa: E501 + + :param job_index: The job_index of this JobsetV1alpha2Coordinator. # noqa: E501 + :type: int """ - excluded_fields: Set[str] = set([ - ]) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + self._job_index = job_index + + @property + def pod_index(self): + """Gets the pod_index of this JobsetV1alpha2Coordinator. # noqa: E501 - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of JobsetV1alpha2Coordinator from a dict""" - if obj is None: - return None + PodIndex is the Job completion index of the coordinator pod. # noqa: E501 + + :return: The pod_index of this JobsetV1alpha2Coordinator. # noqa: E501 + :rtype: int + """ + return self._pod_index - if not isinstance(obj, dict): - return cls.model_validate(obj) + @pod_index.setter + def pod_index(self, pod_index): + """Sets the pod_index of this JobsetV1alpha2Coordinator. + + PodIndex is the Job completion index of the coordinator pod. # noqa: E501 + + :param pod_index: The pod_index of this JobsetV1alpha2Coordinator. # noqa: E501 + :type: int + """ - _obj = cls.model_validate({ - "jobIndex": obj.get("jobIndex"), - "podIndex": obj.get("podIndex"), - "replicatedJob": obj.get("replicatedJob") if obj.get("replicatedJob") is not None else '' - }) - return _obj + self._pod_index = pod_index + @property + def replicated_job(self): + """Gets the replicated_job of this JobsetV1alpha2Coordinator. # noqa: E501 + ReplicatedJob is the name of the ReplicatedJob which contains the coordinator pod. # noqa: E501 + + :return: The replicated_job of this JobsetV1alpha2Coordinator. # noqa: E501 + :rtype: str + """ + return self._replicated_job + + @replicated_job.setter + def replicated_job(self, replicated_job): + """Sets the replicated_job of this JobsetV1alpha2Coordinator. + + ReplicatedJob is the name of the ReplicatedJob which contains the coordinator pod. # noqa: E501 + + :param replicated_job: The replicated_job of this JobsetV1alpha2Coordinator. # noqa: E501 + :type: str + """ + if self.local_vars_configuration.client_side_validation and replicated_job is None: # noqa: E501 + raise ValueError("Invalid value for `replicated_job`, must not be `None`") # noqa: E501 + + self._replicated_job = replicated_job + + 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, JobsetV1alpha2Coordinator): + 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, JobsetV1alpha2Coordinator): + return True + + return self.to_dict() != other.to_dict() diff --git a/sdk/python/jobset/models/jobset_v1alpha2_failure_policy.py b/sdk/python/jobset/models/jobset_v1alpha2_failure_policy.py index 9f5a0b977..0e7680642 100644 --- a/sdk/python/jobset/models/jobset_v1alpha2_failure_policy.py +++ b/sdk/python/jobset/models/jobset_v1alpha2_failure_policy.py @@ -3,95 +3,148 @@ """ JobSet SDK - Python SDK for the JobSet API + Python SDK for the JobSet API # noqa: E501 The version of the OpenAPI document: v0.1.4 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 + Generated by: https://openapi-generator.tech +""" -from __future__ import annotations import pprint import re # noqa: F401 -import json -from pydantic import BaseModel, ConfigDict, Field, StrictInt -from typing import Any, ClassVar, Dict, List, Optional -from jobset.models.jobset_v1alpha2_failure_policy_rule import JobsetV1alpha2FailurePolicyRule -from typing import Optional, Set -from typing_extensions import Self +import six + +from jobset.configuration import Configuration + + +class JobsetV1alpha2FailurePolicy(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ -class JobsetV1alpha2FailurePolicy(BaseModel): """ - JobsetV1alpha2FailurePolicy - """ # noqa: E501 - max_restarts: Optional[StrictInt] = Field(default=None, description="MaxRestarts defines the limit on the number of JobSet restarts. A restart is achieved by recreating all active child jobs.", alias="maxRestarts") - rules: Optional[List[JobsetV1alpha2FailurePolicyRule]] = Field(default=None, description="List of failure policy rules for this JobSet. For a given Job failure, the rules will be evaluated in order, and only the first matching rule will be executed. If no matching rule is found, the RestartJobSet action is applied.") - __properties: ClassVar[List[str]] = ["maxRestarts", "rules"] - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of JobsetV1alpha2FailurePolicy from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. + 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_restarts': 'int', + 'rules': 'list[JobsetV1alpha2FailurePolicyRule]' + } + + attribute_map = { + 'max_restarts': 'maxRestarts', + 'rules': 'rules' + } + + def __init__(self, max_restarts=None, rules=None, local_vars_configuration=None): # noqa: E501 + """JobsetV1alpha2FailurePolicy - 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_restarts = None + self._rules = None + self.discriminator = None + + if max_restarts is not None: + self.max_restarts = max_restarts + if rules is not None: + self.rules = rules + + @property + def max_restarts(self): + """Gets the max_restarts of this JobsetV1alpha2FailurePolicy. # noqa: E501 + + MaxRestarts defines the limit on the number of JobSet restarts. A restart is achieved by recreating all active child jobs. # noqa: E501 + + :return: The max_restarts of this JobsetV1alpha2FailurePolicy. # noqa: E501 + :rtype: int + """ + return self._max_restarts + + @max_restarts.setter + def max_restarts(self, max_restarts): + """Sets the max_restarts of this JobsetV1alpha2FailurePolicy. + + MaxRestarts defines the limit on the number of JobSet restarts. A restart is achieved by recreating all active child jobs. # noqa: E501 + + :param max_restarts: The max_restarts of this JobsetV1alpha2FailurePolicy. # noqa: E501 + :type: int """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each item in rules (list) - _items = [] - if self.rules: - for _item_rules in self.rules: - if _item_rules: - _items.append(_item_rules.to_dict()) - _dict['rules'] = _items - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of JobsetV1alpha2FailurePolicy from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "maxRestarts": obj.get("maxRestarts"), - "rules": [JobsetV1alpha2FailurePolicyRule.from_dict(_item) for _item in obj["rules"]] if obj.get("rules") is not None else None - }) - return _obj + self._max_restarts = max_restarts + + @property + def rules(self): + """Gets the rules of this JobsetV1alpha2FailurePolicy. # noqa: E501 + + List of failure policy rules for this JobSet. For a given Job failure, the rules will be evaluated in order, and only the first matching rule will be executed. If no matching rule is found, the RestartJobSet action is applied. # noqa: E501 + + :return: The rules of this JobsetV1alpha2FailurePolicy. # noqa: E501 + :rtype: list[JobsetV1alpha2FailurePolicyRule] + """ + return self._rules + + @rules.setter + def rules(self, rules): + """Sets the rules of this JobsetV1alpha2FailurePolicy. + + List of failure policy rules for this JobSet. For a given Job failure, the rules will be evaluated in order, and only the first matching rule will be executed. If no matching rule is found, the RestartJobSet action is applied. # noqa: E501 + + :param rules: The rules of this JobsetV1alpha2FailurePolicy. # noqa: E501 + :type: list[JobsetV1alpha2FailurePolicyRule] + """ + self._rules = rules + + 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, JobsetV1alpha2FailurePolicy): + 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, JobsetV1alpha2FailurePolicy): + return True + + return self.to_dict() != other.to_dict() diff --git a/sdk/python/jobset/models/jobset_v1alpha2_failure_policy_rule.py b/sdk/python/jobset/models/jobset_v1alpha2_failure_policy_rule.py index 36d0b7847..459eab518 100644 --- a/sdk/python/jobset/models/jobset_v1alpha2_failure_policy_rule.py +++ b/sdk/python/jobset/models/jobset_v1alpha2_failure_policy_rule.py @@ -3,91 +3,206 @@ """ JobSet SDK - Python SDK for the JobSet API + Python SDK for the JobSet API # noqa: E501 The version of the OpenAPI document: v0.1.4 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 + Generated by: https://openapi-generator.tech +""" -from __future__ import annotations import pprint import re # noqa: F401 -import json -from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self +import six + +from jobset.configuration import Configuration + -class JobsetV1alpha2FailurePolicyRule(BaseModel): +class JobsetV1alpha2FailurePolicyRule(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. """ - FailurePolicyRule defines a FailurePolicyAction to be executed if a child job fails due to a reason listed in OnJobFailureReasons. - """ # noqa: E501 - action: StrictStr = Field(description="The action to take if the rule is matched.") - name: StrictStr = Field(description="The name of the failure policy rule. The name is defaulted to 'failurePolicyRuleN' where N is the index of the failure policy rule. The name must match the regular expression \"^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$\".") - on_job_failure_reasons: Optional[List[StrictStr]] = Field(default=None, description="The requirement on the job failure reasons. The requirement is satisfied if at least one reason matches the list. The rules are evaluated in order, and the first matching rule is executed. An empty list applies the rule to any job failure reason.", alias="onJobFailureReasons") - target_replicated_jobs: Optional[List[StrictStr]] = Field(default=None, description="TargetReplicatedJobs are the names of the replicated jobs the operator applies to. An empty list will apply to all replicatedJobs.", alias="targetReplicatedJobs") - __properties: ClassVar[List[str]] = ["action", "name", "onJobFailureReasons", "targetReplicatedJobs"] - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of JobsetV1alpha2FailurePolicyRule from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. + openapi_types = { + 'action': 'str', + 'name': 'str', + 'on_job_failure_reasons': 'list[str]', + 'target_replicated_jobs': 'list[str]' + } + + attribute_map = { + 'action': 'action', + 'name': 'name', + 'on_job_failure_reasons': 'onJobFailureReasons', + 'target_replicated_jobs': 'targetReplicatedJobs' + } + + def __init__(self, action='', name='', on_job_failure_reasons=None, target_replicated_jobs=None, local_vars_configuration=None): # noqa: E501 + """JobsetV1alpha2FailurePolicyRule - 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._action = None + self._name = None + self._on_job_failure_reasons = None + self._target_replicated_jobs = None + self.discriminator = None + + self.action = action + self.name = name + if on_job_failure_reasons is not None: + self.on_job_failure_reasons = on_job_failure_reasons + if target_replicated_jobs is not None: + self.target_replicated_jobs = target_replicated_jobs + + @property + def action(self): + """Gets the action of this JobsetV1alpha2FailurePolicyRule. # noqa: E501 + + The action to take if the rule is matched. # noqa: E501 + + :return: The action of this JobsetV1alpha2FailurePolicyRule. # noqa: E501 + :rtype: str + """ + return self._action + + @action.setter + def action(self, action): + """Sets the action of this JobsetV1alpha2FailurePolicyRule. + + The action to take if the rule is matched. # noqa: E501 + + :param action: The action of this JobsetV1alpha2FailurePolicyRule. # noqa: E501 + :type: str + """ + if self.local_vars_configuration.client_side_validation and action is None: # noqa: E501 + raise ValueError("Invalid value for `action`, must not be `None`") # noqa: E501 + + self._action = action + + @property + def name(self): + """Gets the name of this JobsetV1alpha2FailurePolicyRule. # noqa: E501 + + The name of the failure policy rule. The name is defaulted to 'failurePolicyRuleN' where N is the index of the failure policy rule. The name must match the regular expression \"^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$\". # noqa: E501 + + :return: The name of this JobsetV1alpha2FailurePolicyRule. # noqa: E501 + :rtype: str + """ + return self._name + + @name.setter + def name(self, name): + """Sets the name of this JobsetV1alpha2FailurePolicyRule. + + The name of the failure policy rule. The name is defaulted to 'failurePolicyRuleN' where N is the index of the failure policy rule. The name must match the regular expression \"^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$\". # noqa: E501 + + :param name: The name of this JobsetV1alpha2FailurePolicyRule. # 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 on_job_failure_reasons(self): + """Gets the on_job_failure_reasons of this JobsetV1alpha2FailurePolicyRule. # noqa: E501 + + The requirement on the job failure reasons. The requirement is satisfied if at least one reason matches the list. The rules are evaluated in order, and the first matching rule is executed. An empty list applies the rule to any job failure reason. # noqa: E501 + + :return: The on_job_failure_reasons of this JobsetV1alpha2FailurePolicyRule. # noqa: E501 + :rtype: list[str] + """ + return self._on_job_failure_reasons + + @on_job_failure_reasons.setter + def on_job_failure_reasons(self, on_job_failure_reasons): + """Sets the on_job_failure_reasons of this JobsetV1alpha2FailurePolicyRule. + + The requirement on the job failure reasons. The requirement is satisfied if at least one reason matches the list. The rules are evaluated in order, and the first matching rule is executed. An empty list applies the rule to any job failure reason. # noqa: E501 + + :param on_job_failure_reasons: The on_job_failure_reasons of this JobsetV1alpha2FailurePolicyRule. # noqa: E501 + :type: list[str] + """ + + self._on_job_failure_reasons = on_job_failure_reasons + + @property + def target_replicated_jobs(self): + """Gets the target_replicated_jobs of this JobsetV1alpha2FailurePolicyRule. # noqa: E501 + + TargetReplicatedJobs are the names of the replicated jobs the operator applies to. An empty list will apply to all replicatedJobs. # noqa: E501 + + :return: The target_replicated_jobs of this JobsetV1alpha2FailurePolicyRule. # noqa: E501 + :rtype: list[str] """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of JobsetV1alpha2FailurePolicyRule from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "action": obj.get("action") if obj.get("action") is not None else '', - "name": obj.get("name") if obj.get("name") is not None else '', - "onJobFailureReasons": obj.get("onJobFailureReasons"), - "targetReplicatedJobs": obj.get("targetReplicatedJobs") - }) - return _obj + return self._target_replicated_jobs + + @target_replicated_jobs.setter + def target_replicated_jobs(self, target_replicated_jobs): + """Sets the target_replicated_jobs of this JobsetV1alpha2FailurePolicyRule. + TargetReplicatedJobs are the names of the replicated jobs the operator applies to. An empty list will apply to all replicatedJobs. # noqa: E501 + + :param target_replicated_jobs: The target_replicated_jobs of this JobsetV1alpha2FailurePolicyRule. # noqa: E501 + :type: list[str] + """ + self._target_replicated_jobs = target_replicated_jobs + + 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, JobsetV1alpha2FailurePolicyRule): + 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, JobsetV1alpha2FailurePolicyRule): + return True + + return self.to_dict() != other.to_dict() diff --git a/sdk/python/jobset/models/jobset_v1alpha2_job_set.py b/sdk/python/jobset/models/jobset_v1alpha2_job_set.py index 879561432..7d382b991 100644 --- a/sdk/python/jobset/models/jobset_v1alpha2_job_set.py +++ b/sdk/python/jobset/models/jobset_v1alpha2_job_set.py @@ -3,104 +3,226 @@ """ JobSet SDK - Python SDK for the JobSet API + Python SDK for the JobSet API # noqa: E501 The version of the OpenAPI document: v0.1.4 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 + Generated by: https://openapi-generator.tech +""" -from __future__ import annotations import pprint import re # noqa: F401 -import json -from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from jobset.models.jobset_v1alpha2_job_set_spec import JobsetV1alpha2JobSetSpec -from jobset.models.jobset_v1alpha2_job_set_status import JobsetV1alpha2JobSetStatus -from typing import Optional, Set -from typing_extensions import Self +import six + +from jobset.configuration import Configuration -class JobsetV1alpha2JobSet(BaseModel): + +class JobsetV1alpha2JobSet(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. """ - JobSet is the Schema for the jobsets API - """ # noqa: E501 - api_version: Optional[StrictStr] = Field(default=None, 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", alias="apiVersion") - kind: Optional[StrictStr] = Field(default=None, 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") - metadata: Optional[V1ObjectMeta] = None - spec: Optional[JobsetV1alpha2JobSetSpec] = None - status: Optional[JobsetV1alpha2JobSetStatus] = None - __properties: ClassVar[List[str]] = ["apiVersion", "kind", "metadata", "spec", "status"] - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of JobsetV1alpha2JobSet from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. + + """ + 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': 'JobsetV1alpha2JobSetSpec', + 'status': 'JobsetV1alpha2JobSetStatus' + } + + 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 + """JobsetV1alpha2JobSet - 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 JobsetV1alpha2JobSet. # 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 JobsetV1alpha2JobSet. # noqa: E501 + :rtype: str """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of metadata - if self.metadata: - _dict['metadata'] = self.metadata.to_dict() - # override the default output from pydantic by calling `to_dict()` of spec - if self.spec: - _dict['spec'] = self.spec.to_dict() - # override the default output from pydantic by calling `to_dict()` of status - if self.status: - _dict['status'] = self.status.to_dict() - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of JobsetV1alpha2JobSet from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "apiVersion": obj.get("apiVersion"), - "kind": obj.get("kind"), - "metadata": V1ObjectMeta.from_dict(obj["metadata"]) if obj.get("metadata") is not None else None, - "spec": JobsetV1alpha2JobSetSpec.from_dict(obj["spec"]) if obj.get("spec") is not None else None, - "status": JobsetV1alpha2JobSetStatus.from_dict(obj["status"]) if obj.get("status") is not None else None - }) - return _obj + return self._api_version + + @api_version.setter + def api_version(self, api_version): + """Sets the api_version of this JobsetV1alpha2JobSet. + + 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 JobsetV1alpha2JobSet. # noqa: E501 + :type: str + """ + + self._api_version = api_version + + @property + def kind(self): + """Gets the kind of this JobsetV1alpha2JobSet. # 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 JobsetV1alpha2JobSet. # noqa: E501 + :rtype: str + """ + return self._kind + + @kind.setter + def kind(self, kind): + """Sets the kind of this JobsetV1alpha2JobSet. + + 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 JobsetV1alpha2JobSet. # noqa: E501 + :type: str + """ + + self._kind = kind + + @property + def metadata(self): + """Gets the metadata of this JobsetV1alpha2JobSet. # noqa: E501 + :return: The metadata of this JobsetV1alpha2JobSet. # noqa: E501 + :rtype: V1ObjectMeta + """ + return self._metadata + + @metadata.setter + def metadata(self, metadata): + """Sets the metadata of this JobsetV1alpha2JobSet. + + + :param metadata: The metadata of this JobsetV1alpha2JobSet. # noqa: E501 + :type: V1ObjectMeta + """ + + self._metadata = metadata + + @property + def spec(self): + """Gets the spec of this JobsetV1alpha2JobSet. # noqa: E501 + + + :return: The spec of this JobsetV1alpha2JobSet. # noqa: E501 + :rtype: JobsetV1alpha2JobSetSpec + """ + return self._spec + + @spec.setter + def spec(self, spec): + """Sets the spec of this JobsetV1alpha2JobSet. + + + :param spec: The spec of this JobsetV1alpha2JobSet. # noqa: E501 + :type: JobsetV1alpha2JobSetSpec + """ + + self._spec = spec + + @property + def status(self): + """Gets the status of this JobsetV1alpha2JobSet. # noqa: E501 + + + :return: The status of this JobsetV1alpha2JobSet. # noqa: E501 + :rtype: JobsetV1alpha2JobSetStatus + """ + return self._status + + @status.setter + def status(self, status): + """Sets the status of this JobsetV1alpha2JobSet. + + + :param status: The status of this JobsetV1alpha2JobSet. # noqa: E501 + :type: JobsetV1alpha2JobSetStatus + """ + + 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, JobsetV1alpha2JobSet): + 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, JobsetV1alpha2JobSet): + return True + + return self.to_dict() != other.to_dict() diff --git a/sdk/python/jobset/models/jobset_v1alpha2_job_set_list.py b/sdk/python/jobset/models/jobset_v1alpha2_job_set_list.py index db7f9ee8f..acf0746a1 100644 --- a/sdk/python/jobset/models/jobset_v1alpha2_job_set_list.py +++ b/sdk/python/jobset/models/jobset_v1alpha2_job_set_list.py @@ -3,102 +3,201 @@ """ JobSet SDK - Python SDK for the JobSet API + Python SDK for the JobSet API # noqa: E501 The version of the OpenAPI document: v0.1.4 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 + Generated by: https://openapi-generator.tech +""" -from __future__ import annotations import pprint import re # noqa: F401 -import json -from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from jobset.models.jobset_v1alpha2_job_set import JobsetV1alpha2JobSet -from typing import Optional, Set -from typing_extensions import Self +import six + +from jobset.configuration import Configuration + -class JobsetV1alpha2JobSetList(BaseModel): +class JobsetV1alpha2JobSetList(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. """ - JobSetList contains a list of JobSet - """ # noqa: E501 - api_version: Optional[StrictStr] = Field(default=None, 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", alias="apiVersion") - items: List[JobsetV1alpha2JobSet] - kind: Optional[StrictStr] = Field(default=None, 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") - metadata: Optional[V1ListMeta] = None - __properties: ClassVar[List[str]] = ["apiVersion", "items", "kind", "metadata"] - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of JobsetV1alpha2JobSetList from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. + openapi_types = { + 'api_version': 'str', + 'items': 'list[JobsetV1alpha2JobSet]', + '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 + """JobsetV1alpha2JobSetList - 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 JobsetV1alpha2JobSetList. # 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 JobsetV1alpha2JobSetList. # noqa: E501 + :rtype: str + """ + return self._api_version + + @api_version.setter + def api_version(self, api_version): + """Sets the api_version of this JobsetV1alpha2JobSetList. + + 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 JobsetV1alpha2JobSetList. # noqa: E501 + :type: str + """ + + self._api_version = api_version + + @property + def items(self): + """Gets the items of this JobsetV1alpha2JobSetList. # noqa: E501 + + + :return: The items of this JobsetV1alpha2JobSetList. # noqa: E501 + :rtype: list[JobsetV1alpha2JobSet] + """ + return self._items + + @items.setter + def items(self, items): + """Sets the items of this JobsetV1alpha2JobSetList. + + + :param items: The items of this JobsetV1alpha2JobSetList. # noqa: E501 + :type: list[JobsetV1alpha2JobSet] + """ + 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 JobsetV1alpha2JobSetList. # 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 JobsetV1alpha2JobSetList. # noqa: E501 + :rtype: str + """ + return self._kind + + @kind.setter + def kind(self, kind): + """Sets the kind of this JobsetV1alpha2JobSetList. + + 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 JobsetV1alpha2JobSetList. # noqa: E501 + :type: str + """ + + self._kind = kind + + @property + def metadata(self): + """Gets the metadata of this JobsetV1alpha2JobSetList. # noqa: E501 + + + :return: The metadata of this JobsetV1alpha2JobSetList. # noqa: E501 + :rtype: V1ListMeta """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each item in items (list) - _items = [] - if self.items: - for _item_items in self.items: - if _item_items: - _items.append(_item_items.to_dict()) - _dict['items'] = _items - # override the default output from pydantic by calling `to_dict()` of metadata - if self.metadata: - _dict['metadata'] = self.metadata.to_dict() - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of JobsetV1alpha2JobSetList from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "apiVersion": obj.get("apiVersion"), - "items": [JobsetV1alpha2JobSet.from_dict(_item) for _item in obj["items"]] if obj.get("items") is not None else None, - "kind": obj.get("kind"), - "metadata": V1ListMeta.from_dict(obj["metadata"]) if obj.get("metadata") is not None else None - }) - return _obj + return self._metadata + + @metadata.setter + def metadata(self, metadata): + """Sets the metadata of this JobsetV1alpha2JobSetList. + :param metadata: The metadata of this JobsetV1alpha2JobSetList. # 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, JobsetV1alpha2JobSetList): + 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, JobsetV1alpha2JobSetList): + return True + + return self.to_dict() != other.to_dict() diff --git a/sdk/python/jobset/models/jobset_v1alpha2_job_set_spec.py b/sdk/python/jobset/models/jobset_v1alpha2_job_set_spec.py index 2817fc956..c51885a9c 100644 --- a/sdk/python/jobset/models/jobset_v1alpha2_job_set_spec.py +++ b/sdk/python/jobset/models/jobset_v1alpha2_job_set_spec.py @@ -3,129 +3,334 @@ """ JobSet SDK - Python SDK for the JobSet API + Python SDK for the JobSet API # noqa: E501 The version of the OpenAPI document: v0.1.4 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 + Generated by: https://openapi-generator.tech +""" -from __future__ import annotations import pprint import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from jobset.models.jobset_v1alpha2_coordinator import JobsetV1alpha2Coordinator -from jobset.models.jobset_v1alpha2_failure_policy import JobsetV1alpha2FailurePolicy -from jobset.models.jobset_v1alpha2_network import JobsetV1alpha2Network -from jobset.models.jobset_v1alpha2_replicated_job import JobsetV1alpha2ReplicatedJob -from jobset.models.jobset_v1alpha2_startup_policy import JobsetV1alpha2StartupPolicy -from jobset.models.jobset_v1alpha2_success_policy import JobsetV1alpha2SuccessPolicy -from typing import Optional, Set -from typing_extensions import Self - -class JobsetV1alpha2JobSetSpec(BaseModel): + +import six + +from jobset.configuration import Configuration + + +class JobsetV1alpha2JobSetSpec(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. """ - JobSetSpec defines the desired state of JobSet - """ # noqa: E501 - coordinator: Optional[JobsetV1alpha2Coordinator] = None - failure_policy: Optional[JobsetV1alpha2FailurePolicy] = Field(default=None, alias="failurePolicy") - managed_by: Optional[StrictStr] = Field(default=None, description="ManagedBy is used to indicate the controller or entity that manages a JobSet. The built-in JobSet controller reconciles JobSets which don't have this field at all or the field value is the reserved string `jobset.sigs.k8s.io/jobset-controller`, but skips reconciling JobSets with a custom value for this field. The value must be a valid domain-prefixed path (e.g. acme.io/foo) - all characters before the first \"/\" must be a valid subdomain as defined by RFC 1123. All characters trailing the first \"/\" must be valid HTTP Path characters as defined by RFC 3986. The value cannot exceed 63 characters. The field is immutable.", alias="managedBy") - network: Optional[JobsetV1alpha2Network] = None - replicated_jobs: Optional[List[JobsetV1alpha2ReplicatedJob]] = Field(default=None, description="ReplicatedJobs is the group of jobs that will form the set.", alias="replicatedJobs") - startup_policy: Optional[JobsetV1alpha2StartupPolicy] = Field(default=None, alias="startupPolicy") - success_policy: Optional[JobsetV1alpha2SuccessPolicy] = Field(default=None, alias="successPolicy") - suspend: Optional[StrictBool] = Field(default=None, description="Suspend suspends all running child Jobs when set to true.") - ttl_seconds_after_finished: Optional[StrictInt] = Field(default=None, description="TTLSecondsAfterFinished limits the lifetime of a JobSet that has finished execution (either Complete or Failed). If this field is set, TTLSecondsAfterFinished after the JobSet finishes, it is eligible to be automatically deleted. When the JobSet is being deleted, its lifecycle guarantees (e.g. finalizers) will be honored. If this field is unset, the JobSet won't be automatically deleted. If this field is set to zero, the JobSet becomes eligible to be deleted immediately after it finishes.", alias="ttlSecondsAfterFinished") - __properties: ClassVar[List[str]] = ["coordinator", "failurePolicy", "managedBy", "network", "replicatedJobs", "startupPolicy", "successPolicy", "suspend", "ttlSecondsAfterFinished"] - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of JobsetV1alpha2JobSetSpec from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of coordinator - if self.coordinator: - _dict['coordinator'] = self.coordinator.to_dict() - # override the default output from pydantic by calling `to_dict()` of failure_policy - if self.failure_policy: - _dict['failurePolicy'] = self.failure_policy.to_dict() - # override the default output from pydantic by calling `to_dict()` of network - if self.network: - _dict['network'] = self.network.to_dict() - # override the default output from pydantic by calling `to_dict()` of each item in replicated_jobs (list) - _items = [] - if self.replicated_jobs: - for _item_replicated_jobs in self.replicated_jobs: - if _item_replicated_jobs: - _items.append(_item_replicated_jobs.to_dict()) - _dict['replicatedJobs'] = _items - # override the default output from pydantic by calling `to_dict()` of startup_policy - if self.startup_policy: - _dict['startupPolicy'] = self.startup_policy.to_dict() - # override the default output from pydantic by calling `to_dict()` of success_policy - if self.success_policy: - _dict['successPolicy'] = self.success_policy.to_dict() - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of JobsetV1alpha2JobSetSpec from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "coordinator": JobsetV1alpha2Coordinator.from_dict(obj["coordinator"]) if obj.get("coordinator") is not None else None, - "failurePolicy": JobsetV1alpha2FailurePolicy.from_dict(obj["failurePolicy"]) if obj.get("failurePolicy") is not None else None, - "managedBy": obj.get("managedBy"), - "network": JobsetV1alpha2Network.from_dict(obj["network"]) if obj.get("network") is not None else None, - "replicatedJobs": [JobsetV1alpha2ReplicatedJob.from_dict(_item) for _item in obj["replicatedJobs"]] if obj.get("replicatedJobs") is not None else None, - "startupPolicy": JobsetV1alpha2StartupPolicy.from_dict(obj["startupPolicy"]) if obj.get("startupPolicy") is not None else None, - "successPolicy": JobsetV1alpha2SuccessPolicy.from_dict(obj["successPolicy"]) if obj.get("successPolicy") is not None else None, - "suspend": obj.get("suspend"), - "ttlSecondsAfterFinished": obj.get("ttlSecondsAfterFinished") - }) - return _obj + openapi_types = { + 'coordinator': 'JobsetV1alpha2Coordinator', + 'failure_policy': 'JobsetV1alpha2FailurePolicy', + 'managed_by': 'str', + 'network': 'JobsetV1alpha2Network', + 'replicated_jobs': 'list[JobsetV1alpha2ReplicatedJob]', + 'startup_policy': 'JobsetV1alpha2StartupPolicy', + 'success_policy': 'JobsetV1alpha2SuccessPolicy', + 'suspend': 'bool', + 'ttl_seconds_after_finished': 'int' + } + + attribute_map = { + 'coordinator': 'coordinator', + 'failure_policy': 'failurePolicy', + 'managed_by': 'managedBy', + 'network': 'network', + 'replicated_jobs': 'replicatedJobs', + 'startup_policy': 'startupPolicy', + 'success_policy': 'successPolicy', + 'suspend': 'suspend', + 'ttl_seconds_after_finished': 'ttlSecondsAfterFinished' + } + + def __init__(self, coordinator=None, failure_policy=None, managed_by=None, network=None, replicated_jobs=None, startup_policy=None, success_policy=None, suspend=None, ttl_seconds_after_finished=None, local_vars_configuration=None): # noqa: E501 + """JobsetV1alpha2JobSetSpec - 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._coordinator = None + self._failure_policy = None + self._managed_by = None + self._network = None + self._replicated_jobs = None + self._startup_policy = None + self._success_policy = None + self._suspend = None + self._ttl_seconds_after_finished = None + self.discriminator = None + + if coordinator is not None: + self.coordinator = coordinator + if failure_policy is not None: + self.failure_policy = failure_policy + if managed_by is not None: + self.managed_by = managed_by + if network is not None: + self.network = network + if replicated_jobs is not None: + self.replicated_jobs = replicated_jobs + if startup_policy is not None: + self.startup_policy = startup_policy + if success_policy is not None: + self.success_policy = success_policy + if suspend is not None: + self.suspend = suspend + if ttl_seconds_after_finished is not None: + self.ttl_seconds_after_finished = ttl_seconds_after_finished + + @property + def coordinator(self): + """Gets the coordinator of this JobsetV1alpha2JobSetSpec. # noqa: E501 + + + :return: The coordinator of this JobsetV1alpha2JobSetSpec. # noqa: E501 + :rtype: JobsetV1alpha2Coordinator + """ + return self._coordinator + + @coordinator.setter + def coordinator(self, coordinator): + """Sets the coordinator of this JobsetV1alpha2JobSetSpec. + + + :param coordinator: The coordinator of this JobsetV1alpha2JobSetSpec. # noqa: E501 + :type: JobsetV1alpha2Coordinator + """ + + self._coordinator = coordinator + + @property + def failure_policy(self): + """Gets the failure_policy of this JobsetV1alpha2JobSetSpec. # noqa: E501 + + + :return: The failure_policy of this JobsetV1alpha2JobSetSpec. # noqa: E501 + :rtype: JobsetV1alpha2FailurePolicy + """ + return self._failure_policy + + @failure_policy.setter + def failure_policy(self, failure_policy): + """Sets the failure_policy of this JobsetV1alpha2JobSetSpec. + + + :param failure_policy: The failure_policy of this JobsetV1alpha2JobSetSpec. # noqa: E501 + :type: JobsetV1alpha2FailurePolicy + """ + + self._failure_policy = failure_policy + + @property + def managed_by(self): + """Gets the managed_by of this JobsetV1alpha2JobSetSpec. # noqa: E501 + + ManagedBy is used to indicate the controller or entity that manages a JobSet. The built-in JobSet controller reconciles JobSets which don't have this field at all or the field value is the reserved string `jobset.sigs.k8s.io/jobset-controller`, but skips reconciling JobSets with a custom value for this field. The value must be a valid domain-prefixed path (e.g. acme.io/foo) - all characters before the first \"/\" must be a valid subdomain as defined by RFC 1123. All characters trailing the first \"/\" must be valid HTTP Path characters as defined by RFC 3986. The value cannot exceed 63 characters. The field is immutable. # noqa: E501 + + :return: The managed_by of this JobsetV1alpha2JobSetSpec. # noqa: E501 + :rtype: str + """ + return self._managed_by + + @managed_by.setter + def managed_by(self, managed_by): + """Sets the managed_by of this JobsetV1alpha2JobSetSpec. + + ManagedBy is used to indicate the controller or entity that manages a JobSet. The built-in JobSet controller reconciles JobSets which don't have this field at all or the field value is the reserved string `jobset.sigs.k8s.io/jobset-controller`, but skips reconciling JobSets with a custom value for this field. The value must be a valid domain-prefixed path (e.g. acme.io/foo) - all characters before the first \"/\" must be a valid subdomain as defined by RFC 1123. All characters trailing the first \"/\" must be valid HTTP Path characters as defined by RFC 3986. The value cannot exceed 63 characters. The field is immutable. # noqa: E501 + + :param managed_by: The managed_by of this JobsetV1alpha2JobSetSpec. # noqa: E501 + :type: str + """ + + self._managed_by = managed_by + + @property + def network(self): + """Gets the network of this JobsetV1alpha2JobSetSpec. # noqa: E501 + + + :return: The network of this JobsetV1alpha2JobSetSpec. # noqa: E501 + :rtype: JobsetV1alpha2Network + """ + return self._network + + @network.setter + def network(self, network): + """Sets the network of this JobsetV1alpha2JobSetSpec. + + + :param network: The network of this JobsetV1alpha2JobSetSpec. # noqa: E501 + :type: JobsetV1alpha2Network + """ + + self._network = network + + @property + def replicated_jobs(self): + """Gets the replicated_jobs of this JobsetV1alpha2JobSetSpec. # noqa: E501 + + ReplicatedJobs is the group of jobs that will form the set. # noqa: E501 + + :return: The replicated_jobs of this JobsetV1alpha2JobSetSpec. # noqa: E501 + :rtype: list[JobsetV1alpha2ReplicatedJob] + """ + return self._replicated_jobs + + @replicated_jobs.setter + def replicated_jobs(self, replicated_jobs): + """Sets the replicated_jobs of this JobsetV1alpha2JobSetSpec. + + ReplicatedJobs is the group of jobs that will form the set. # noqa: E501 + + :param replicated_jobs: The replicated_jobs of this JobsetV1alpha2JobSetSpec. # noqa: E501 + :type: list[JobsetV1alpha2ReplicatedJob] + """ + + self._replicated_jobs = replicated_jobs + + @property + def startup_policy(self): + """Gets the startup_policy of this JobsetV1alpha2JobSetSpec. # noqa: E501 + + + :return: The startup_policy of this JobsetV1alpha2JobSetSpec. # noqa: E501 + :rtype: JobsetV1alpha2StartupPolicy + """ + return self._startup_policy + + @startup_policy.setter + def startup_policy(self, startup_policy): + """Sets the startup_policy of this JobsetV1alpha2JobSetSpec. + + + :param startup_policy: The startup_policy of this JobsetV1alpha2JobSetSpec. # noqa: E501 + :type: JobsetV1alpha2StartupPolicy + """ + + self._startup_policy = startup_policy + + @property + def success_policy(self): + """Gets the success_policy of this JobsetV1alpha2JobSetSpec. # noqa: E501 + + + :return: The success_policy of this JobsetV1alpha2JobSetSpec. # noqa: E501 + :rtype: JobsetV1alpha2SuccessPolicy + """ + return self._success_policy + + @success_policy.setter + def success_policy(self, success_policy): + """Sets the success_policy of this JobsetV1alpha2JobSetSpec. + + + :param success_policy: The success_policy of this JobsetV1alpha2JobSetSpec. # noqa: E501 + :type: JobsetV1alpha2SuccessPolicy + """ + + self._success_policy = success_policy + + @property + def suspend(self): + """Gets the suspend of this JobsetV1alpha2JobSetSpec. # noqa: E501 + + Suspend suspends all running child Jobs when set to true. # noqa: E501 + + :return: The suspend of this JobsetV1alpha2JobSetSpec. # noqa: E501 + :rtype: bool + """ + return self._suspend + + @suspend.setter + def suspend(self, suspend): + """Sets the suspend of this JobsetV1alpha2JobSetSpec. + + Suspend suspends all running child Jobs when set to true. # noqa: E501 + + :param suspend: The suspend of this JobsetV1alpha2JobSetSpec. # noqa: E501 + :type: bool + """ + + self._suspend = suspend + + @property + def ttl_seconds_after_finished(self): + """Gets the ttl_seconds_after_finished of this JobsetV1alpha2JobSetSpec. # noqa: E501 + + TTLSecondsAfterFinished limits the lifetime of a JobSet that has finished execution (either Complete or Failed). If this field is set, TTLSecondsAfterFinished after the JobSet finishes, it is eligible to be automatically deleted. When the JobSet is being deleted, its lifecycle guarantees (e.g. finalizers) will be honored. If this field is unset, the JobSet won't be automatically deleted. If this field is set to zero, the JobSet becomes eligible to be deleted immediately after it finishes. # noqa: E501 + + :return: The ttl_seconds_after_finished of this JobsetV1alpha2JobSetSpec. # noqa: E501 + :rtype: int + """ + return self._ttl_seconds_after_finished + + @ttl_seconds_after_finished.setter + def ttl_seconds_after_finished(self, ttl_seconds_after_finished): + """Sets the ttl_seconds_after_finished of this JobsetV1alpha2JobSetSpec. + + TTLSecondsAfterFinished limits the lifetime of a JobSet that has finished execution (either Complete or Failed). If this field is set, TTLSecondsAfterFinished after the JobSet finishes, it is eligible to be automatically deleted. When the JobSet is being deleted, its lifecycle guarantees (e.g. finalizers) will be honored. If this field is unset, the JobSet won't be automatically deleted. If this field is set to zero, the JobSet becomes eligible to be deleted immediately after it finishes. # noqa: E501 + + :param ttl_seconds_after_finished: The ttl_seconds_after_finished of this JobsetV1alpha2JobSetSpec. # noqa: E501 + :type: int + """ + + self._ttl_seconds_after_finished = ttl_seconds_after_finished + + 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, JobsetV1alpha2JobSetSpec): + 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, JobsetV1alpha2JobSetSpec): + return True + return self.to_dict() != other.to_dict() diff --git a/sdk/python/jobset/models/jobset_v1alpha2_job_set_status.py b/sdk/python/jobset/models/jobset_v1alpha2_job_set_status.py index ac6bdd91d..d95cfa327 100644 --- a/sdk/python/jobset/models/jobset_v1alpha2_job_set_status.py +++ b/sdk/python/jobset/models/jobset_v1alpha2_job_set_status.py @@ -3,108 +3,230 @@ """ JobSet SDK - Python SDK for the JobSet API + Python SDK for the JobSet API # noqa: E501 The version of the OpenAPI document: v0.1.4 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 + Generated by: https://openapi-generator.tech +""" -from __future__ import annotations import pprint import re # noqa: F401 -import json -from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from jobset.models.jobset_v1alpha2_replicated_job_status import JobsetV1alpha2ReplicatedJobStatus -from typing import Optional, Set -from typing_extensions import Self +import six + +from jobset.configuration import Configuration -class JobsetV1alpha2JobSetStatus(BaseModel): + +class JobsetV1alpha2JobSetStatus(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. """ - JobSetStatus defines the observed state of JobSet - """ # noqa: E501 - conditions: Optional[List[V1Condition]] = None - replicated_jobs_status: Optional[List[JobsetV1alpha2ReplicatedJobStatus]] = Field(default=None, description="ReplicatedJobsStatus track the number of JobsReady for each replicatedJob.", alias="replicatedJobsStatus") - restarts: Optional[StrictInt] = Field(default=None, description="Restarts tracks the number of times the JobSet has restarted (i.e. recreated in case of RecreateAll policy).") - restarts_count_towards_max: Optional[StrictInt] = Field(default=None, description="RestartsCountTowardsMax tracks the number of times the JobSet has restarted that counts towards the maximum allowed number of restarts.", alias="restartsCountTowardsMax") - terminal_state: Optional[StrictStr] = Field(default=None, description="TerminalState the state of the JobSet when it finishes execution. It can be either Complete or Failed. Otherwise, it is empty by default.", alias="terminalState") - __properties: ClassVar[List[str]] = ["conditions", "replicatedJobsStatus", "restarts", "restartsCountTowardsMax", "terminalState"] - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of JobsetV1alpha2JobSetStatus from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. + + """ + 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]', + 'replicated_jobs_status': 'list[JobsetV1alpha2ReplicatedJobStatus]', + 'restarts': 'int', + 'restarts_count_towards_max': 'int', + 'terminal_state': 'str' + } + + attribute_map = { + 'conditions': 'conditions', + 'replicated_jobs_status': 'replicatedJobsStatus', + 'restarts': 'restarts', + 'restarts_count_towards_max': 'restartsCountTowardsMax', + 'terminal_state': 'terminalState' + } + + def __init__(self, conditions=None, replicated_jobs_status=None, restarts=None, restarts_count_towards_max=None, terminal_state=None, local_vars_configuration=None): # noqa: E501 + """JobsetV1alpha2JobSetStatus - 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._replicated_jobs_status = None + self._restarts = None + self._restarts_count_towards_max = None + self._terminal_state = None + self.discriminator = None + + if conditions is not None: + self.conditions = conditions + if replicated_jobs_status is not None: + self.replicated_jobs_status = replicated_jobs_status + if restarts is not None: + self.restarts = restarts + if restarts_count_towards_max is not None: + self.restarts_count_towards_max = restarts_count_towards_max + if terminal_state is not None: + self.terminal_state = terminal_state + + @property + def conditions(self): + """Gets the conditions of this JobsetV1alpha2JobSetStatus. # noqa: E501 + + + :return: The conditions of this JobsetV1alpha2JobSetStatus. # noqa: E501 + :rtype: list[V1Condition] """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each item in conditions (list) - _items = [] - if self.conditions: - for _item_conditions in self.conditions: - if _item_conditions: - _items.append(_item_conditions.to_dict()) - _dict['conditions'] = _items - # override the default output from pydantic by calling `to_dict()` of each item in replicated_jobs_status (list) - _items = [] - if self.replicated_jobs_status: - for _item_replicated_jobs_status in self.replicated_jobs_status: - if _item_replicated_jobs_status: - _items.append(_item_replicated_jobs_status.to_dict()) - _dict['replicatedJobsStatus'] = _items - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of JobsetV1alpha2JobSetStatus from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "conditions": [V1Condition.from_dict(_item) for _item in obj["conditions"]] if obj.get("conditions") is not None else None, - "replicatedJobsStatus": [JobsetV1alpha2ReplicatedJobStatus.from_dict(_item) for _item in obj["replicatedJobsStatus"]] if obj.get("replicatedJobsStatus") is not None else None, - "restarts": obj.get("restarts"), - "restartsCountTowardsMax": obj.get("restartsCountTowardsMax"), - "terminalState": obj.get("terminalState") - }) - return _obj + return self._conditions + + @conditions.setter + def conditions(self, conditions): + """Sets the conditions of this JobsetV1alpha2JobSetStatus. + + + :param conditions: The conditions of this JobsetV1alpha2JobSetStatus. # noqa: E501 + :type: list[V1Condition] + """ + + self._conditions = conditions + + @property + def replicated_jobs_status(self): + """Gets the replicated_jobs_status of this JobsetV1alpha2JobSetStatus. # noqa: E501 + + ReplicatedJobsStatus track the number of JobsReady for each replicatedJob. # noqa: E501 + + :return: The replicated_jobs_status of this JobsetV1alpha2JobSetStatus. # noqa: E501 + :rtype: list[JobsetV1alpha2ReplicatedJobStatus] + """ + return self._replicated_jobs_status + + @replicated_jobs_status.setter + def replicated_jobs_status(self, replicated_jobs_status): + """Sets the replicated_jobs_status of this JobsetV1alpha2JobSetStatus. + + ReplicatedJobsStatus track the number of JobsReady for each replicatedJob. # noqa: E501 + + :param replicated_jobs_status: The replicated_jobs_status of this JobsetV1alpha2JobSetStatus. # noqa: E501 + :type: list[JobsetV1alpha2ReplicatedJobStatus] + """ + + self._replicated_jobs_status = replicated_jobs_status + + @property + def restarts(self): + """Gets the restarts of this JobsetV1alpha2JobSetStatus. # noqa: E501 + Restarts tracks the number of times the JobSet has restarted (i.e. recreated in case of RecreateAll policy). # noqa: E501 + + :return: The restarts of this JobsetV1alpha2JobSetStatus. # noqa: E501 + :rtype: int + """ + return self._restarts + + @restarts.setter + def restarts(self, restarts): + """Sets the restarts of this JobsetV1alpha2JobSetStatus. + + Restarts tracks the number of times the JobSet has restarted (i.e. recreated in case of RecreateAll policy). # noqa: E501 + + :param restarts: The restarts of this JobsetV1alpha2JobSetStatus. # noqa: E501 + :type: int + """ + + self._restarts = restarts + + @property + def restarts_count_towards_max(self): + """Gets the restarts_count_towards_max of this JobsetV1alpha2JobSetStatus. # noqa: E501 + + RestartsCountTowardsMax tracks the number of times the JobSet has restarted that counts towards the maximum allowed number of restarts. # noqa: E501 + + :return: The restarts_count_towards_max of this JobsetV1alpha2JobSetStatus. # noqa: E501 + :rtype: int + """ + return self._restarts_count_towards_max + + @restarts_count_towards_max.setter + def restarts_count_towards_max(self, restarts_count_towards_max): + """Sets the restarts_count_towards_max of this JobsetV1alpha2JobSetStatus. + + RestartsCountTowardsMax tracks the number of times the JobSet has restarted that counts towards the maximum allowed number of restarts. # noqa: E501 + + :param restarts_count_towards_max: The restarts_count_towards_max of this JobsetV1alpha2JobSetStatus. # noqa: E501 + :type: int + """ + + self._restarts_count_towards_max = restarts_count_towards_max + + @property + def terminal_state(self): + """Gets the terminal_state of this JobsetV1alpha2JobSetStatus. # noqa: E501 + + TerminalState the state of the JobSet when it finishes execution. It can be either Complete or Failed. Otherwise, it is empty by default. # noqa: E501 + + :return: The terminal_state of this JobsetV1alpha2JobSetStatus. # noqa: E501 + :rtype: str + """ + return self._terminal_state + + @terminal_state.setter + def terminal_state(self, terminal_state): + """Sets the terminal_state of this JobsetV1alpha2JobSetStatus. + + TerminalState the state of the JobSet when it finishes execution. It can be either Complete or Failed. Otherwise, it is empty by default. # noqa: E501 + + :param terminal_state: The terminal_state of this JobsetV1alpha2JobSetStatus. # noqa: E501 + :type: str + """ + self._terminal_state = terminal_state + + 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, JobsetV1alpha2JobSetStatus): + 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, JobsetV1alpha2JobSetStatus): + return True + + return self.to_dict() != other.to_dict() diff --git a/sdk/python/jobset/models/jobset_v1alpha2_network.py b/sdk/python/jobset/models/jobset_v1alpha2_network.py index 8ff7d1c01..fe280a1cf 100644 --- a/sdk/python/jobset/models/jobset_v1alpha2_network.py +++ b/sdk/python/jobset/models/jobset_v1alpha2_network.py @@ -3,89 +3,176 @@ """ JobSet SDK - Python SDK for the JobSet API + Python SDK for the JobSet API # noqa: E501 The version of the OpenAPI document: v0.1.4 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 + Generated by: https://openapi-generator.tech +""" -from __future__ import annotations import pprint import re # noqa: F401 -import json -from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self +import six + +from jobset.configuration import Configuration + + +class JobsetV1alpha2Network(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ -class JobsetV1alpha2Network(BaseModel): """ - JobsetV1alpha2Network - """ # noqa: E501 - enable_dns_hostnames: Optional[StrictBool] = Field(default=None, description="EnableDNSHostnames allows pods to be reached via their hostnames. Pods will be reachable using the fully qualified pod hostname: ---.", alias="enableDNSHostnames") - publish_not_ready_addresses: Optional[StrictBool] = Field(default=None, description="Indicates if DNS records of pods should be published before the pods are ready. Defaults to True.", alias="publishNotReadyAddresses") - subdomain: Optional[StrictStr] = Field(default=None, description="Subdomain is an explicit choice for a network subdomain name When set, any replicated job in the set is added to this network. Defaults to if not set.") - __properties: ClassVar[List[str]] = ["enableDNSHostnames", "publishNotReadyAddresses", "subdomain"] - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of JobsetV1alpha2Network from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. + 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 = { + 'enable_dns_hostnames': 'bool', + 'publish_not_ready_addresses': 'bool', + 'subdomain': 'str' + } + + attribute_map = { + 'enable_dns_hostnames': 'enableDNSHostnames', + 'publish_not_ready_addresses': 'publishNotReadyAddresses', + 'subdomain': 'subdomain' + } + + def __init__(self, enable_dns_hostnames=None, publish_not_ready_addresses=None, subdomain=None, local_vars_configuration=None): # noqa: E501 + """JobsetV1alpha2Network - 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._enable_dns_hostnames = None + self._publish_not_ready_addresses = None + self._subdomain = None + self.discriminator = None + + if enable_dns_hostnames is not None: + self.enable_dns_hostnames = enable_dns_hostnames + if publish_not_ready_addresses is not None: + self.publish_not_ready_addresses = publish_not_ready_addresses + if subdomain is not None: + self.subdomain = subdomain + + @property + def enable_dns_hostnames(self): + """Gets the enable_dns_hostnames of this JobsetV1alpha2Network. # noqa: E501 + + EnableDNSHostnames allows pods to be reached via their hostnames. Pods will be reachable using the fully qualified pod hostname: ---. # noqa: E501 + + :return: The enable_dns_hostnames of this JobsetV1alpha2Network. # noqa: E501 + :rtype: bool """ - excluded_fields: Set[str] = set([ - ]) + return self._enable_dns_hostnames - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + @enable_dns_hostnames.setter + def enable_dns_hostnames(self, enable_dns_hostnames): + """Sets the enable_dns_hostnames of this JobsetV1alpha2Network. - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of JobsetV1alpha2Network from a dict""" - if obj is None: - return None + EnableDNSHostnames allows pods to be reached via their hostnames. Pods will be reachable using the fully qualified pod hostname: ---. # noqa: E501 - if not isinstance(obj, dict): - return cls.model_validate(obj) + :param enable_dns_hostnames: The enable_dns_hostnames of this JobsetV1alpha2Network. # noqa: E501 + :type: bool + """ - _obj = cls.model_validate({ - "enableDNSHostnames": obj.get("enableDNSHostnames"), - "publishNotReadyAddresses": obj.get("publishNotReadyAddresses"), - "subdomain": obj.get("subdomain") - }) - return _obj + self._enable_dns_hostnames = enable_dns_hostnames + @property + def publish_not_ready_addresses(self): + """Gets the publish_not_ready_addresses of this JobsetV1alpha2Network. # noqa: E501 + + Indicates if DNS records of pods should be published before the pods are ready. Defaults to True. # noqa: E501 + + :return: The publish_not_ready_addresses of this JobsetV1alpha2Network. # noqa: E501 + :rtype: bool + """ + return self._publish_not_ready_addresses + + @publish_not_ready_addresses.setter + def publish_not_ready_addresses(self, publish_not_ready_addresses): + """Sets the publish_not_ready_addresses of this JobsetV1alpha2Network. + + Indicates if DNS records of pods should be published before the pods are ready. Defaults to True. # noqa: E501 + + :param publish_not_ready_addresses: The publish_not_ready_addresses of this JobsetV1alpha2Network. # noqa: E501 + :type: bool + """ + + self._publish_not_ready_addresses = publish_not_ready_addresses + + @property + def subdomain(self): + """Gets the subdomain of this JobsetV1alpha2Network. # noqa: E501 + + Subdomain is an explicit choice for a network subdomain name When set, any replicated job in the set is added to this network. Defaults to if not set. # noqa: E501 + + :return: The subdomain of this JobsetV1alpha2Network. # noqa: E501 + :rtype: str + """ + return self._subdomain + + @subdomain.setter + def subdomain(self, subdomain): + """Sets the subdomain of this JobsetV1alpha2Network. + + Subdomain is an explicit choice for a network subdomain name When set, any replicated job in the set is added to this network. Defaults to if not set. # noqa: E501 + + :param subdomain: The subdomain of this JobsetV1alpha2Network. # noqa: E501 + :type: str + """ + self._subdomain = subdomain + + 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, JobsetV1alpha2Network): + 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, JobsetV1alpha2Network): + return True + + return self.to_dict() != other.to_dict() diff --git a/sdk/python/jobset/models/jobset_v1alpha2_replicated_job.py b/sdk/python/jobset/models/jobset_v1alpha2_replicated_job.py index b7840838b..2ca4f093e 100644 --- a/sdk/python/jobset/models/jobset_v1alpha2_replicated_job.py +++ b/sdk/python/jobset/models/jobset_v1alpha2_replicated_job.py @@ -3,92 +3,176 @@ """ JobSet SDK - Python SDK for the JobSet API + Python SDK for the JobSet API # noqa: E501 The version of the OpenAPI document: v0.1.4 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 + Generated by: https://openapi-generator.tech +""" -from __future__ import annotations import pprint import re # noqa: F401 -import json -from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self +import six + +from jobset.configuration import Configuration -class JobsetV1alpha2ReplicatedJob(BaseModel): + +class JobsetV1alpha2ReplicatedJob(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. """ - JobsetV1alpha2ReplicatedJob - """ # noqa: E501 - name: StrictStr = Field(description="Name is the name of the entry and will be used as a suffix for the Job name.") - replicas: Optional[StrictInt] = Field(default=None, description="Replicas is the number of jobs that will be created from this ReplicatedJob's template. Jobs names will be in the format: --") - template: V1JobTemplateSpec - __properties: ClassVar[List[str]] = ["name", "replicas", "template"] - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of JobsetV1alpha2ReplicatedJob from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. + + """ + 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', + 'replicas': 'int', + 'template': 'V1JobTemplateSpec' + } + + attribute_map = { + 'name': 'name', + 'replicas': 'replicas', + 'template': 'template' + } + + def __init__(self, name='', replicas=None, template=None, local_vars_configuration=None): # noqa: E501 + """JobsetV1alpha2ReplicatedJob - 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._replicas = None + self._template = None + self.discriminator = None + + self.name = name + if replicas is not None: + self.replicas = replicas + self.template = template + + @property + def name(self): + """Gets the name of this JobsetV1alpha2ReplicatedJob. # noqa: E501 + + Name is the name of the entry and will be used as a suffix for the Job name. # noqa: E501 + + :return: The name of this JobsetV1alpha2ReplicatedJob. # noqa: E501 + :rtype: str + """ + return self._name + + @name.setter + def name(self, name): + """Sets the name of this JobsetV1alpha2ReplicatedJob. + + Name is the name of the entry and will be used as a suffix for the Job name. # noqa: E501 + + :param name: The name of this JobsetV1alpha2ReplicatedJob. # 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 replicas(self): + """Gets the replicas of this JobsetV1alpha2ReplicatedJob. # noqa: E501 + + Replicas is the number of jobs that will be created from this ReplicatedJob's template. Jobs names will be in the format: -- # noqa: E501 + + :return: The replicas of this JobsetV1alpha2ReplicatedJob. # noqa: E501 + :rtype: int + """ + return self._replicas + + @replicas.setter + def replicas(self, replicas): + """Sets the replicas of this JobsetV1alpha2ReplicatedJob. + + Replicas is the number of jobs that will be created from this ReplicatedJob's template. Jobs names will be in the format: -- # noqa: E501 + + :param replicas: The replicas of this JobsetV1alpha2ReplicatedJob. # noqa: E501 + :type: int """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of template - if self.template: - _dict['template'] = self.template.to_dict() - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of JobsetV1alpha2ReplicatedJob from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name") if obj.get("name") is not None else '', - "replicas": obj.get("replicas"), - "template": V1JobTemplateSpec.from_dict(obj["template"]) if obj.get("template") is not None else None - }) - return _obj + self._replicas = replicas + @property + def template(self): + """Gets the template of this JobsetV1alpha2ReplicatedJob. # noqa: E501 + + + :return: The template of this JobsetV1alpha2ReplicatedJob. # noqa: E501 + :rtype: V1JobTemplateSpec + """ + return self._template + + @template.setter + def template(self, template): + """Sets the template of this JobsetV1alpha2ReplicatedJob. + + + :param template: The template of this JobsetV1alpha2ReplicatedJob. # noqa: E501 + :type: V1JobTemplateSpec + """ + 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, JobsetV1alpha2ReplicatedJob): + 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, JobsetV1alpha2ReplicatedJob): + return True + + return self.to_dict() != other.to_dict() diff --git a/sdk/python/jobset/models/jobset_v1alpha2_replicated_job_status.py b/sdk/python/jobset/models/jobset_v1alpha2_replicated_job_status.py index 9d65f236c..e278c81e9 100644 --- a/sdk/python/jobset/models/jobset_v1alpha2_replicated_job_status.py +++ b/sdk/python/jobset/models/jobset_v1alpha2_replicated_job_status.py @@ -3,95 +3,266 @@ """ JobSet SDK - Python SDK for the JobSet API + Python SDK for the JobSet API # noqa: E501 The version of the OpenAPI document: v0.1.4 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 + Generated by: https://openapi-generator.tech +""" -from __future__ import annotations import pprint import re # noqa: F401 -import json -from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List -from typing import Optional, Set -from typing_extensions import Self +import six + +from jobset.configuration import Configuration + -class JobsetV1alpha2ReplicatedJobStatus(BaseModel): +class JobsetV1alpha2ReplicatedJobStatus(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. """ - ReplicatedJobStatus defines the observed ReplicatedJobs Readiness. - """ # noqa: E501 - active: StrictInt = Field(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.") - failed: StrictInt = Field(description="Failed is the number of failed child Jobs.") - name: StrictStr = Field(description="Name of the ReplicatedJob.") - ready: StrictInt = Field(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 Job (i.e., the minimum of job.spec.parallelism and job.spec.completions).") - succeeded: StrictInt = Field(description="Succeeded is the number of successfully completed child Jobs.") - suspended: StrictInt = Field(description="Suspended is the number of child Jobs which are in a suspended state.") - __properties: ClassVar[List[str]] = ["active", "failed", "name", "ready", "succeeded", "suspended"] - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of JobsetV1alpha2ReplicatedJobStatus from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. + 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 + """JobsetV1alpha2ReplicatedJobStatus - 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 JobsetV1alpha2ReplicatedJobStatus. # 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 JobsetV1alpha2ReplicatedJobStatus. # noqa: E501 + :rtype: int + """ + return self._active + + @active.setter + def active(self, active): + """Sets the active of this JobsetV1alpha2ReplicatedJobStatus. + + 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 JobsetV1alpha2ReplicatedJobStatus. # 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 JobsetV1alpha2ReplicatedJobStatus. # noqa: E501 + + Failed is the number of failed child Jobs. # noqa: E501 + + :return: The failed of this JobsetV1alpha2ReplicatedJobStatus. # noqa: E501 + :rtype: int + """ + return self._failed + + @failed.setter + def failed(self, failed): + """Sets the failed of this JobsetV1alpha2ReplicatedJobStatus. + + Failed is the number of failed child Jobs. # noqa: E501 + + :param failed: The failed of this JobsetV1alpha2ReplicatedJobStatus. # 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 JobsetV1alpha2ReplicatedJobStatus. # noqa: E501 + + Name of the ReplicatedJob. # noqa: E501 + + :return: The name of this JobsetV1alpha2ReplicatedJobStatus. # noqa: E501 + :rtype: str + """ + return self._name + + @name.setter + def name(self, name): + """Sets the name of this JobsetV1alpha2ReplicatedJobStatus. + + Name of the ReplicatedJob. # noqa: E501 + + :param name: The name of this JobsetV1alpha2ReplicatedJobStatus. # 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 JobsetV1alpha2ReplicatedJobStatus. # 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 Job (i.e., the minimum of job.spec.parallelism and job.spec.completions). # noqa: E501 + + :return: The ready of this JobsetV1alpha2ReplicatedJobStatus. # noqa: E501 + :rtype: int """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of JobsetV1alpha2ReplicatedJobStatus from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "active": obj.get("active") if obj.get("active") is not None else 0, - "failed": obj.get("failed") if obj.get("failed") is not None else 0, - "name": obj.get("name") if obj.get("name") is not None else '', - "ready": obj.get("ready") if obj.get("ready") is not None else 0, - "succeeded": obj.get("succeeded") if obj.get("succeeded") is not None else 0, - "suspended": obj.get("suspended") if obj.get("suspended") is not None else 0 - }) - return _obj + return self._ready + + @ready.setter + def ready(self, ready): + """Sets the ready of this JobsetV1alpha2ReplicatedJobStatus. + + 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 Job (i.e., the minimum of job.spec.parallelism and job.spec.completions). # noqa: E501 + + :param ready: The ready of this JobsetV1alpha2ReplicatedJobStatus. # 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 JobsetV1alpha2ReplicatedJobStatus. # noqa: E501 + + Succeeded is the number of successfully completed child Jobs. # noqa: E501 + + :return: The succeeded of this JobsetV1alpha2ReplicatedJobStatus. # noqa: E501 + :rtype: int + """ + return self._succeeded + + @succeeded.setter + def succeeded(self, succeeded): + """Sets the succeeded of this JobsetV1alpha2ReplicatedJobStatus. + + Succeeded is the number of successfully completed child Jobs. # noqa: E501 + + :param succeeded: The succeeded of this JobsetV1alpha2ReplicatedJobStatus. # 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 JobsetV1alpha2ReplicatedJobStatus. # noqa: E501 + + Suspended is the number of child Jobs which are in a suspended state. # noqa: E501 + + :return: The suspended of this JobsetV1alpha2ReplicatedJobStatus. # noqa: E501 + :rtype: int + """ + return self._suspended + + @suspended.setter + def suspended(self, suspended): + """Sets the suspended of this JobsetV1alpha2ReplicatedJobStatus. + + Suspended is the number of child Jobs which are in a suspended state. # noqa: E501 + + :param suspended: The suspended of this JobsetV1alpha2ReplicatedJobStatus. # 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, JobsetV1alpha2ReplicatedJobStatus): + 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, JobsetV1alpha2ReplicatedJobStatus): + return True + return self.to_dict() != other.to_dict() diff --git a/sdk/python/jobset/models/jobset_v1alpha2_startup_policy.py b/sdk/python/jobset/models/jobset_v1alpha2_startup_policy.py index 0f2ab03e7..f47e6daf4 100644 --- a/sdk/python/jobset/models/jobset_v1alpha2_startup_policy.py +++ b/sdk/python/jobset/models/jobset_v1alpha2_startup_policy.py @@ -3,85 +3,121 @@ """ JobSet SDK - Python SDK for the JobSet API + Python SDK for the JobSet API # noqa: E501 The version of the OpenAPI document: v0.1.4 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 + Generated by: https://openapi-generator.tech +""" -from __future__ import annotations import pprint import re # noqa: F401 -import json -from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List -from typing import Optional, Set -from typing_extensions import Self +import six -class JobsetV1alpha2StartupPolicy(BaseModel): - """ - JobsetV1alpha2StartupPolicy - """ # noqa: E501 - startup_policy_order: StrictStr = Field(description="StartupPolicyOrder determines the startup order of the ReplicatedJobs. AnyOrder means to start replicated jobs in any order. InOrder means to start them as they are listed in the JobSet. A ReplicatedJob is started only when all the jobs of the previous one are ready.", alias="startupPolicyOrder") - __properties: ClassVar[List[str]] = ["startupPolicyOrder"] +from jobset.configuration import Configuration - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) +class JobsetV1alpha2StartupPolicy(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + Do not edit the class manually. + """ - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + """ + 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 = { + 'startup_policy_order': 'str' + } - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of JobsetV1alpha2StartupPolicy from a JSON string""" - return cls.from_dict(json.loads(json_str)) + attribute_map = { + 'startup_policy_order': 'startupPolicyOrder' + } - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + def __init__(self, startup_policy_order='', local_vars_configuration=None): # noqa: E501 + """JobsetV1alpha2StartupPolicy - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + self._startup_policy_order = None + self.discriminator = None - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + self.startup_policy_order = startup_policy_order - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + @property + def startup_policy_order(self): + """Gets the startup_policy_order of this JobsetV1alpha2StartupPolicy. # noqa: E501 - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of JobsetV1alpha2StartupPolicy from a dict""" - if obj is None: - return None + StartupPolicyOrder determines the startup order of the ReplicatedJobs. AnyOrder means to start replicated jobs in any order. InOrder means to start them as they are listed in the JobSet. A ReplicatedJob is started only when all the jobs of the previous one are ready. # noqa: E501 - if not isinstance(obj, dict): - return cls.model_validate(obj) + :return: The startup_policy_order of this JobsetV1alpha2StartupPolicy. # noqa: E501 + :rtype: str + """ + return self._startup_policy_order - _obj = cls.model_validate({ - "startupPolicyOrder": obj.get("startupPolicyOrder") if obj.get("startupPolicyOrder") is not None else '' - }) - return _obj + @startup_policy_order.setter + def startup_policy_order(self, startup_policy_order): + """Sets the startup_policy_order of this JobsetV1alpha2StartupPolicy. + StartupPolicyOrder determines the startup order of the ReplicatedJobs. AnyOrder means to start replicated jobs in any order. InOrder means to start them as they are listed in the JobSet. A ReplicatedJob is started only when all the jobs of the previous one are ready. # noqa: E501 + :param startup_policy_order: The startup_policy_order of this JobsetV1alpha2StartupPolicy. # noqa: E501 + :type: str + """ + if self.local_vars_configuration.client_side_validation and startup_policy_order is None: # noqa: E501 + raise ValueError("Invalid value for `startup_policy_order`, must not be `None`") # noqa: E501 + + self._startup_policy_order = startup_policy_order + + 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, JobsetV1alpha2StartupPolicy): + 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, JobsetV1alpha2StartupPolicy): + return True + + return self.to_dict() != other.to_dict() diff --git a/sdk/python/jobset/models/jobset_v1alpha2_success_policy.py b/sdk/python/jobset/models/jobset_v1alpha2_success_policy.py index fd74815ae..350238fd2 100644 --- a/sdk/python/jobset/models/jobset_v1alpha2_success_policy.py +++ b/sdk/python/jobset/models/jobset_v1alpha2_success_policy.py @@ -3,87 +3,149 @@ """ JobSet SDK - Python SDK for the JobSet API + Python SDK for the JobSet API # noqa: E501 The version of the OpenAPI document: v0.1.4 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 + Generated by: https://openapi-generator.tech +""" -from __future__ import annotations import pprint import re # noqa: F401 -import json -from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self +import six + +from jobset.configuration import Configuration + + +class JobsetV1alpha2SuccessPolicy(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ -class JobsetV1alpha2SuccessPolicy(BaseModel): """ - JobsetV1alpha2SuccessPolicy - """ # noqa: E501 - operator: StrictStr = Field(description="Operator determines either All or Any of the selected jobs should succeed to consider the JobSet successful") - target_replicated_jobs: Optional[List[StrictStr]] = Field(default=None, description="TargetReplicatedJobs are the names of the replicated jobs the operator will apply to. A null or empty list will apply to all replicatedJobs.", alias="targetReplicatedJobs") - __properties: ClassVar[List[str]] = ["operator", "targetReplicatedJobs"] - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of JobsetV1alpha2SuccessPolicy from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. + 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 = { + 'operator': 'str', + 'target_replicated_jobs': 'list[str]' + } + + attribute_map = { + 'operator': 'operator', + 'target_replicated_jobs': 'targetReplicatedJobs' + } + + def __init__(self, operator='', target_replicated_jobs=None, local_vars_configuration=None): # noqa: E501 + """JobsetV1alpha2SuccessPolicy - 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._operator = None + self._target_replicated_jobs = None + self.discriminator = None + + self.operator = operator + if target_replicated_jobs is not None: + self.target_replicated_jobs = target_replicated_jobs + + @property + def operator(self): + """Gets the operator of this JobsetV1alpha2SuccessPolicy. # noqa: E501 + + Operator determines either All or Any of the selected jobs should succeed to consider the JobSet successful # noqa: E501 + + :return: The operator of this JobsetV1alpha2SuccessPolicy. # noqa: E501 + :rtype: str """ - excluded_fields: Set[str] = set([ - ]) + return self._operator + + @operator.setter + def operator(self, operator): + """Sets the operator of this JobsetV1alpha2SuccessPolicy. - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + Operator determines either All or Any of the selected jobs should succeed to consider the JobSet successful # noqa: E501 - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of JobsetV1alpha2SuccessPolicy from a dict""" - if obj is None: - return None + :param operator: The operator of this JobsetV1alpha2SuccessPolicy. # noqa: E501 + :type: str + """ + if self.local_vars_configuration.client_side_validation and operator is None: # noqa: E501 + raise ValueError("Invalid value for `operator`, must not be `None`") # noqa: E501 - if not isinstance(obj, dict): - return cls.model_validate(obj) + self._operator = operator - _obj = cls.model_validate({ - "operator": obj.get("operator") if obj.get("operator") is not None else '', - "targetReplicatedJobs": obj.get("targetReplicatedJobs") - }) - return _obj + @property + def target_replicated_jobs(self): + """Gets the target_replicated_jobs of this JobsetV1alpha2SuccessPolicy. # noqa: E501 + TargetReplicatedJobs are the names of the replicated jobs the operator will apply to. A null or empty list will apply to all replicatedJobs. # noqa: E501 + + :return: The target_replicated_jobs of this JobsetV1alpha2SuccessPolicy. # noqa: E501 + :rtype: list[str] + """ + return self._target_replicated_jobs + + @target_replicated_jobs.setter + def target_replicated_jobs(self, target_replicated_jobs): + """Sets the target_replicated_jobs of this JobsetV1alpha2SuccessPolicy. + + TargetReplicatedJobs are the names of the replicated jobs the operator will apply to. A null or empty list will apply to all replicatedJobs. # noqa: E501 + + :param target_replicated_jobs: The target_replicated_jobs of this JobsetV1alpha2SuccessPolicy. # noqa: E501 + :type: list[str] + """ + self._target_replicated_jobs = target_replicated_jobs + + 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, JobsetV1alpha2SuccessPolicy): + 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, JobsetV1alpha2SuccessPolicy): + return True + + return self.to_dict() != other.to_dict() diff --git a/sdk/python/jobset/py.typed b/sdk/python/jobset/py.typed deleted file mode 100644 index e69de29bb..000000000 diff --git a/sdk/python/jobset/rest.py b/sdk/python/jobset/rest.py index 162618bd6..02ed07cae 100644 --- a/sdk/python/jobset/rest.py +++ b/sdk/python/jobset/rest.py @@ -3,66 +3,57 @@ """ JobSet SDK - Python SDK for the JobSet API + Python SDK for the JobSet API # noqa: E501 The version of the OpenAPI document: v0.1.4 - Generated by OpenAPI Generator (https://openapi-generator.tech) + Generated by: https://openapi-generator.tech +""" - Do not edit the class manually. -""" # noqa: E501 +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 jobset.exceptions import ApiException, ApiValueError -SUPPORTED_SOCKS_PROXIES = {"socks5", "socks5h", "socks4", "socks4a"} -RESTResponseType = urllib3.HTTPResponse - -def is_socks_proxy_url(url): - if url is None: - return False - split_section = url.split("://") - if len(split_section) < 2: - return False - else: - return split_section[0].lower() in SUPPORTED_SOCKS_PROXIES +logger = logging.getLogger(__name__) class RESTResponse(io.IOBase): - def __init__(self, resp) -> None: - self.response = resp + def __init__(self, resp): + self.urllib3_response = resp self.status = resp.status self.reason = resp.reason - self.data = None - - def read(self): - if self.data is None: - self.data = self.response.data - return self.data + self.data = resp.data def getheaders(self): """Returns a dictionary of the response headers.""" - return self.response.headers + return self.urllib3_response.getheaders() def getheader(self, name, default=None): """Returns a given response header.""" - return self.response.headers.get(name, default) + return self.urllib3_response.getheader(name, default) -class RESTClientObject: +class RESTClientObject(object): - def __init__(self, configuration) -> None: + 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 @@ -71,79 +62,74 @@ def __init__(self, configuration) -> None: else: cert_reqs = ssl.CERT_NONE - pool_args = { - "cert_reqs": cert_reqs, - "ca_certs": configuration.ssl_ca_cert, - "cert_file": configuration.cert_file, - "key_file": configuration.key_file, - } + # 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: - pool_args['assert_hostname'] = ( - configuration.assert_hostname - ) + addition_pool_args['assert_hostname'] = configuration.assert_hostname # noqa: E501 if configuration.retries is not None: - pool_args['retries'] = configuration.retries + addition_pool_args['retries'] = configuration.retries - if configuration.tls_server_name: - pool_args['server_hostname'] = configuration.tls_server_name - - - if configuration.socket_options is not None: - pool_args['socket_options'] = configuration.socket_options - - if configuration.connection_pool_maxsize is not None: - pool_args['maxsize'] = configuration.connection_pool_maxsize + if maxsize is None: + if configuration.connection_pool_maxsize is not None: + maxsize = configuration.connection_pool_maxsize + else: + maxsize = 4 # https pool manager - self.pool_manager: urllib3.PoolManager - if configuration.proxy: - if is_socks_proxy_url(configuration.proxy): - from urllib3.contrib.socks import SOCKSProxyManager - pool_args["proxy_url"] = configuration.proxy - pool_args["headers"] = configuration.proxy_headers - self.pool_manager = SOCKSProxyManager(**pool_args) - else: - pool_args["proxy_url"] = configuration.proxy - pool_args["proxy_headers"] = configuration.proxy_headers - self.pool_manager = urllib3.ProxyManager(**pool_args) + 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(**pool_args) - - def request( - self, - method, - url, - headers=None, - body=None, - post_params=None, - _request_timeout=None - ): + 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' - ] + assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT', + 'PATCH', 'OPTIONS'] if post_params and body: raise ApiValueError( @@ -155,83 +141,60 @@ def request( timeout = None if _request_timeout: - if isinstance(_request_timeout, (int, float)): + 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 - ): + elif (isinstance(_request_timeout, tuple) and + len(_request_timeout) == 2): timeout = urllib3.Timeout( - connect=_request_timeout[0], - read=_request_timeout[1] - ) + 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']: - - # no content type provided or payload is json - content_type = headers.get('Content-Type') - if ( - not content_type - or re.search('json', content_type, re.IGNORECASE) - ): + 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, + method, url, body=request_body, + preload_content=_preload_content, timeout=timeout, - headers=headers, - preload_content=False - ) - elif content_type == 'application/x-www-form-urlencoded': + headers=headers) + elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501 r = self.pool_manager.request( - method, - url, + method, url, fields=post_params, encode_multipart=False, + preload_content=_preload_content, timeout=timeout, - headers=headers, - preload_content=False - ) - elif content_type == 'multipart/form-data': + 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'] - # Ensures that dict objects are serialized - post_params = [(a, json.dumps(b)) if isinstance(b, dict) else (a,b) for a, b in post_params] r = self.pool_manager.request( - method, - url, + method, url, fields=post_params, encode_multipart=True, + preload_content=_preload_content, timeout=timeout, - headers=headers, - preload_content=False - ) + 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. + # 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=body, - timeout=timeout, - headers=headers, - preload_content=False - ) - elif headers['Content-Type'] == 'text/plain' and isinstance(body, bool): - request_body = "true" if body else "false" - r = self.pool_manager.request( - method, - url, + method, url, body=request_body, - preload_content=False, + preload_content=_preload_content, timeout=timeout, headers=headers) else: @@ -242,16 +205,87 @@ def request( raise ApiException(status=0, reason=msg) # For `GET`, `HEAD` else: - r = self.pool_manager.request( - method, - url, - fields={}, - timeout=timeout, - headers=headers, - preload_content=False - ) + 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 = "\n".join([type(e).__name__, str(e)]) + msg = "{0}\n{1}".format(type(e).__name__, str(e)) raise ApiException(status=0, reason=msg) - return RESTResponse(r) + 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/python/pyproject.toml b/sdk/python/pyproject.toml index 9c5188d42..921aa1047 100644 --- a/sdk/python/pyproject.toml +++ b/sdk/python/pyproject.toml @@ -1,71 +1,27 @@ -[tool.poetry] -name = "jobset" -version = "0.1.4" -description = "JobSet SDK" -authors = ["OpenAPI Generator Community "] -license = "NoLicense" -readme = "README.md" -repository = "https://github.com/GIT_USER_ID/GIT_REPO_ID" -keywords = ["OpenAPI", "OpenAPI-Generator", "JobSet SDK"] -include = ["jobset/py.typed"] - -[tool.poetry.dependencies] -python = "^3.8" - -urllib3 = ">= 1.25.3" -python-dateutil = ">=2.8.2" -pydantic = ">=2" -typing-extensions = ">=4.7.1" - -[tool.poetry.dev-dependencies] -pytest = ">=7.2.1" -tox = ">=3.9.0" -flake8 = ">=4.0.0" -types-python-dateutil = ">=2.8.19.14" -mypy = ">=1.5" - - [build-system] -requires = ["setuptools"] +requires = ["setuptools", "setuptools-scm"] build-backend = "setuptools.build_meta" -[tool.pylint.'MESSAGES CONTROL'] -extension-pkg-whitelist = "pydantic" - -[tool.mypy] -files = [ - "jobset", - #"test", # auto-generated tests - "tests", # hand-written tests +[project] +name = "jobset" +version = "0.2.0" +authors = [ + {name = "Kubernetes"}, ] -# TODO: enable "strict" once all these individual checks are passing -# strict = true - -# List from: https://mypy.readthedocs.io/en/stable/existing_code.html#introduce-stricter-options -warn_unused_configs = true -warn_redundant_casts = true -warn_unused_ignores = true - -## Getting these passing should be easy -strict_equality = true -strict_concatenate = true - -## Strongly recommend enabling this one as soon as you can -check_untyped_defs = true - -## These shouldn't be too much additional work, but may be tricky to -## get passing if you use a lot of untyped libraries -disallow_subclassing_any = true -disallow_untyped_decorators = true -disallow_any_generics = true +description = "JobSet represents distributed jobs for ML/AI/HPC applications" +requires-python = ">=3.7" +readme = "README.md" +license = {text = "Apache"} +dependencies = [ + "certifi >= 14.05.14", + "six >= 1.10", + "python_dateutil >= 2.5.3", + "setuptools >= 21.0.0", + "urllib3 >= 1.15.1", + "kubernetes", +] +[project.optional-dependencies] +test = ["pytest>=6.2.5", "pytest-cov>=2.8.1", "pytest-randomly==1.2.3"] -### These next few are various gradations of forcing use of type annotations -#disallow_untyped_calls = true -#disallow_incomplete_defs = true -#disallow_untyped_defs = true -# -### This one isn't too hard to get passing, but return on investment is lower -#no_implicit_reexport = true -# -### This one can be tricky to get passing if you use a lot of untyped libraries -#warn_return_any = true +[tool.setuptools] +packages = ["jobset", "jobset.api", "jobset.models"] \ No newline at end of file diff --git a/sdk/python/requirements.txt b/sdk/python/requirements.txt index 7d45544de..eb358efd5 100644 --- a/sdk/python/requirements.txt +++ b/sdk/python/requirements.txt @@ -1,5 +1,6 @@ +certifi >= 14.05.14 +future; python_version<="2.7" +six >= 1.10 python_dateutil >= 2.5.3 setuptools >= 21.0.0 -urllib3 >= 1.25.3, < 3.0.0 -pydantic >= 2 -typing-extensions >= 4.7.1 +urllib3 >= 1.15.1 diff --git a/sdk/python/test-requirements.txt b/sdk/python/test-requirements.txt index 1f7f2ae43..091fa58b0 100644 --- a/sdk/python/test-requirements.txt +++ b/sdk/python/test-requirements.txt @@ -1,6 +1,4 @@ kubernetes pytest>=6.2.5 pytest-cov>=2.8.1 -pytest-randomly>=3.12.0 -mypy>=1.4.1 -types-python-dateutil>=2.8.19 +pytest-randomly==1.2.3 # needed for python 2.7+3.4 diff --git a/sdk/python/test/test_jobset_v1alpha2_coordinator.py b/sdk/python/test/test_jobset_v1alpha2_coordinator.py index 4ebc195ea..7aae08bd4 100644 --- a/sdk/python/test/test_jobset_v1alpha2_coordinator.py +++ b/sdk/python/test/test_jobset_v1alpha2_coordinator.py @@ -3,18 +3,23 @@ """ JobSet SDK - Python SDK for the JobSet API + Python SDK for the JobSet API # noqa: E501 The version of the OpenAPI document: v0.1.4 - Generated by OpenAPI Generator (https://openapi-generator.tech) + Generated by: https://openapi-generator.tech +""" - Do not edit the class manually. -""" # noqa: E501 +from __future__ import absolute_import +# Kubernetes imports +from kubernetes.client.models.v1_job_template_spec import V1JobTemplateSpec import unittest +import datetime -from jobset.models.jobset_v1alpha2_coordinator import JobsetV1alpha2Coordinator +import jobset +from jobset.models.jobset_v1alpha2_coordinator import JobsetV1alpha2Coordinator # noqa: E501 +from jobset.rest import ApiException class TestJobsetV1alpha2Coordinator(unittest.TestCase): """JobsetV1alpha2Coordinator unit test stubs""" @@ -25,30 +30,28 @@ def setUp(self): def tearDown(self): pass - def make_instance(self, include_optional) -> JobsetV1alpha2Coordinator: + def make_instance(self, include_optional): """Test JobsetV1alpha2Coordinator - include_optional is a boolean, when False only required + include_option is a boolean, when False only required params are included, when True both required and optional params are included """ - # uncomment below to create an instance of `JobsetV1alpha2Coordinator` - """ - model = JobsetV1alpha2Coordinator() - if include_optional: + # model = jobset.models.jobset_v1alpha2_coordinator.JobsetV1alpha2Coordinator() # noqa: E501 + if include_optional : return JobsetV1alpha2Coordinator( - job_index = 56, - pod_index = 56, - replicated_job = '' + job_index = 56, + pod_index = 56, + replicated_job = '0' ) - else: + else : return JobsetV1alpha2Coordinator( - replicated_job = '', + replicated_job = '0', ) - """ def testJobsetV1alpha2Coordinator(self): """Test JobsetV1alpha2Coordinator""" - # inst_req_only = self.make_instance(include_optional=False) - # inst_req_and_optional = self.make_instance(include_optional=True) + inst_req_only = self.make_instance(include_optional=False) + inst_req_and_optional = self.make_instance(include_optional=True) + if __name__ == '__main__': unittest.main() diff --git a/sdk/python/test/test_jobset_v1alpha2_failure_policy.py b/sdk/python/test/test_jobset_v1alpha2_failure_policy.py index 3af6212dc..72e216715 100644 --- a/sdk/python/test/test_jobset_v1alpha2_failure_policy.py +++ b/sdk/python/test/test_jobset_v1alpha2_failure_policy.py @@ -3,18 +3,23 @@ """ JobSet SDK - Python SDK for the JobSet API + Python SDK for the JobSet API # noqa: E501 The version of the OpenAPI document: v0.1.4 - Generated by OpenAPI Generator (https://openapi-generator.tech) + Generated by: https://openapi-generator.tech +""" - Do not edit the class manually. -""" # noqa: E501 +from __future__ import absolute_import +# Kubernetes imports +from kubernetes.client.models.v1_job_template_spec import V1JobTemplateSpec import unittest +import datetime -from jobset.models.jobset_v1alpha2_failure_policy import JobsetV1alpha2FailurePolicy +import jobset +from jobset.models.jobset_v1alpha2_failure_policy import JobsetV1alpha2FailurePolicy # noqa: E501 +from jobset.rest import ApiException class TestJobsetV1alpha2FailurePolicy(unittest.TestCase): """JobsetV1alpha2FailurePolicy unit test stubs""" @@ -25,38 +30,36 @@ def setUp(self): def tearDown(self): pass - def make_instance(self, include_optional) -> JobsetV1alpha2FailurePolicy: + def make_instance(self, include_optional): """Test JobsetV1alpha2FailurePolicy - include_optional is a boolean, when False only required + include_option is a boolean, when False only required params are included, when True both required and optional params are included """ - # uncomment below to create an instance of `JobsetV1alpha2FailurePolicy` - """ - model = JobsetV1alpha2FailurePolicy() - if include_optional: + # model = jobset.models.jobset_v1alpha2_failure_policy.JobsetV1alpha2FailurePolicy() # noqa: E501 + if include_optional : return JobsetV1alpha2FailurePolicy( - max_restarts = 56, + max_restarts = 56, rules = [ jobset.models.jobset_v1alpha2_failure_policy_rule.JobsetV1alpha2FailurePolicyRule( - action = '', - name = '', + action = '0', + name = '0', on_job_failure_reasons = [ - '' + '0' ], target_replicated_jobs = [ - '' + '0' ], ) ] ) - else: + else : return JobsetV1alpha2FailurePolicy( ) - """ def testJobsetV1alpha2FailurePolicy(self): """Test JobsetV1alpha2FailurePolicy""" - # inst_req_only = self.make_instance(include_optional=False) - # inst_req_and_optional = self.make_instance(include_optional=True) + inst_req_only = self.make_instance(include_optional=False) + inst_req_and_optional = self.make_instance(include_optional=True) + if __name__ == '__main__': unittest.main() diff --git a/sdk/python/test/test_jobset_v1alpha2_failure_policy_rule.py b/sdk/python/test/test_jobset_v1alpha2_failure_policy_rule.py index 42e3ac991..fe706e322 100644 --- a/sdk/python/test/test_jobset_v1alpha2_failure_policy_rule.py +++ b/sdk/python/test/test_jobset_v1alpha2_failure_policy_rule.py @@ -3,18 +3,23 @@ """ JobSet SDK - Python SDK for the JobSet API + Python SDK for the JobSet API # noqa: E501 The version of the OpenAPI document: v0.1.4 - Generated by OpenAPI Generator (https://openapi-generator.tech) + Generated by: https://openapi-generator.tech +""" - Do not edit the class manually. -""" # noqa: E501 +from __future__ import absolute_import +# Kubernetes imports +from kubernetes.client.models.v1_job_template_spec import V1JobTemplateSpec import unittest +import datetime -from jobset.models.jobset_v1alpha2_failure_policy_rule import JobsetV1alpha2FailurePolicyRule +import jobset +from jobset.models.jobset_v1alpha2_failure_policy_rule import JobsetV1alpha2FailurePolicyRule # noqa: E501 +from jobset.rest import ApiException class TestJobsetV1alpha2FailurePolicyRule(unittest.TestCase): """JobsetV1alpha2FailurePolicyRule unit test stubs""" @@ -25,36 +30,34 @@ def setUp(self): def tearDown(self): pass - def make_instance(self, include_optional) -> JobsetV1alpha2FailurePolicyRule: + def make_instance(self, include_optional): """Test JobsetV1alpha2FailurePolicyRule - include_optional is a boolean, when False only required + include_option is a boolean, when False only required params are included, when True both required and optional params are included """ - # uncomment below to create an instance of `JobsetV1alpha2FailurePolicyRule` - """ - model = JobsetV1alpha2FailurePolicyRule() - if include_optional: + # model = jobset.models.jobset_v1alpha2_failure_policy_rule.JobsetV1alpha2FailurePolicyRule() # noqa: E501 + if include_optional : return JobsetV1alpha2FailurePolicyRule( - action = '', - name = '', + action = '0', + name = '0', on_job_failure_reasons = [ - '' - ], + '0' + ], target_replicated_jobs = [ - '' + '0' ] ) - else: + else : return JobsetV1alpha2FailurePolicyRule( - action = '', - name = '', + action = '0', + name = '0', ) - """ def testJobsetV1alpha2FailurePolicyRule(self): """Test JobsetV1alpha2FailurePolicyRule""" - # inst_req_only = self.make_instance(include_optional=False) - # inst_req_and_optional = self.make_instance(include_optional=True) + inst_req_only = self.make_instance(include_optional=False) + inst_req_and_optional = self.make_instance(include_optional=True) + if __name__ == '__main__': unittest.main() diff --git a/sdk/python/test/test_jobset_v1alpha2_job_set.py b/sdk/python/test/test_jobset_v1alpha2_job_set.py index 577528d7c..cd37d0dfd 100644 --- a/sdk/python/test/test_jobset_v1alpha2_job_set.py +++ b/sdk/python/test/test_jobset_v1alpha2_job_set.py @@ -3,18 +3,23 @@ """ JobSet SDK - Python SDK for the JobSet API + Python SDK for the JobSet API # noqa: E501 The version of the OpenAPI document: v0.1.4 - Generated by OpenAPI Generator (https://openapi-generator.tech) + Generated by: https://openapi-generator.tech +""" - Do not edit the class manually. -""" # noqa: E501 +from __future__ import absolute_import +# Kubernetes imports +from kubernetes.client.models.v1_job_template_spec import V1JobTemplateSpec import unittest +import datetime -from jobset.models.jobset_v1alpha2_job_set import JobsetV1alpha2JobSet +import jobset +from jobset.models.jobset_v1alpha2_job_set import JobsetV1alpha2JobSet # noqa: E501 +from jobset.rest import ApiException class TestJobsetV1alpha2JobSet(unittest.TestCase): """JobsetV1alpha2JobSet unit test stubs""" @@ -25,54 +30,52 @@ def setUp(self): def tearDown(self): pass - def make_instance(self, include_optional) -> JobsetV1alpha2JobSet: + def make_instance(self, include_optional): """Test JobsetV1alpha2JobSet - include_optional is a boolean, when False only required + include_option is a boolean, when False only required params are included, when True both required and optional params are included """ - # uncomment below to create an instance of `JobsetV1alpha2JobSet` - """ - model = JobsetV1alpha2JobSet() - if include_optional: + # model = jobset.models.jobset_v1alpha2_job_set.JobsetV1alpha2JobSet() # noqa: E501 + if include_optional : return JobsetV1alpha2JobSet( - api_version = '', - kind = '', - metadata = None, + api_version = '0', + kind = '0', + metadata = None, spec = jobset.models.jobset_v1alpha2_job_set_spec.JobsetV1alpha2JobSetSpec( coordinator = jobset.models.jobset_v1alpha2_coordinator.JobsetV1alpha2Coordinator( job_index = 56, pod_index = 56, - replicated_job = '', ), + replicated_job = '0', ), failure_policy = jobset.models.jobset_v1alpha2_failure_policy.JobsetV1alpha2FailurePolicy( max_restarts = 56, rules = [ jobset.models.jobset_v1alpha2_failure_policy_rule.JobsetV1alpha2FailurePolicyRule( - action = '', - name = '', + action = '0', + name = '0', on_job_failure_reasons = [ - '' + '0' ], target_replicated_jobs = [ - '' + '0' ], ) ], ), - managed_by = '', + managed_by = '0', network = jobset.models.jobset_v1alpha2_network.JobsetV1alpha2Network( enable_dns_hostnames = True, publish_not_ready_addresses = True, - subdomain = '', ), + subdomain = '0', ), replicated_jobs = [ jobset.models.jobset_v1alpha2_replicated_job.JobsetV1alpha2ReplicatedJob( - name = '', + name = '0', replicas = 56, template = V1JobTemplateSpec(), ) ], startup_policy = jobset.models.jobset_v1alpha2_startup_policy.JobsetV1alpha2StartupPolicy( - startup_policy_order = '', ), + startup_policy_order = '0', ), success_policy = jobset.models.jobset_v1alpha2_success_policy.JobsetV1alpha2SuccessPolicy( - operator = '', ), + operator = '0', ), suspend = True, - ttl_seconds_after_finished = 56, ), + ttl_seconds_after_finished = 56, ), status = jobset.models.jobset_v1alpha2_job_set_status.JobsetV1alpha2JobSetStatus( conditions = [ None @@ -81,24 +84,24 @@ def make_instance(self, include_optional) -> JobsetV1alpha2JobSet: jobset.models.jobset_v1alpha2_replicated_job_status.JobsetV1alpha2ReplicatedJobStatus( active = 56, failed = 56, - name = '', + name = '0', ready = 56, succeeded = 56, suspended = 56, ) ], restarts = 56, restarts_count_towards_max = 56, - terminal_state = '', ) + terminal_state = '0', ) ) - else: + else : return JobsetV1alpha2JobSet( ) - """ def testJobsetV1alpha2JobSet(self): """Test JobsetV1alpha2JobSet""" - # inst_req_only = self.make_instance(include_optional=False) - # inst_req_and_optional = self.make_instance(include_optional=True) + inst_req_only = self.make_instance(include_optional=False) + inst_req_and_optional = self.make_instance(include_optional=True) + if __name__ == '__main__': unittest.main() diff --git a/sdk/python/test/test_jobset_v1alpha2_job_set_list.py b/sdk/python/test/test_jobset_v1alpha2_job_set_list.py index 915b9124a..30c1eb8de 100644 --- a/sdk/python/test/test_jobset_v1alpha2_job_set_list.py +++ b/sdk/python/test/test_jobset_v1alpha2_job_set_list.py @@ -3,18 +3,23 @@ """ JobSet SDK - Python SDK for the JobSet API + Python SDK for the JobSet API # noqa: E501 The version of the OpenAPI document: v0.1.4 - Generated by OpenAPI Generator (https://openapi-generator.tech) + Generated by: https://openapi-generator.tech +""" - Do not edit the class manually. -""" # noqa: E501 +from __future__ import absolute_import +# Kubernetes imports +from kubernetes.client.models.v1_job_template_spec import V1JobTemplateSpec import unittest +import datetime -from jobset.models.jobset_v1alpha2_job_set_list import JobsetV1alpha2JobSetList +import jobset +from jobset.models.jobset_v1alpha2_job_set_list import JobsetV1alpha2JobSetList # noqa: E501 +from jobset.rest import ApiException class TestJobsetV1alpha2JobSetList(unittest.TestCase): """JobsetV1alpha2JobSetList unit test stubs""" @@ -25,55 +30,53 @@ def setUp(self): def tearDown(self): pass - def make_instance(self, include_optional) -> JobsetV1alpha2JobSetList: + def make_instance(self, include_optional): """Test JobsetV1alpha2JobSetList - include_optional is a boolean, when False only required + include_option is a boolean, when False only required params are included, when True both required and optional params are included """ - # uncomment below to create an instance of `JobsetV1alpha2JobSetList` - """ - model = JobsetV1alpha2JobSetList() - if include_optional: + # model = jobset.models.jobset_v1alpha2_job_set_list.JobsetV1alpha2JobSetList() # noqa: E501 + if include_optional : return JobsetV1alpha2JobSetList( - api_version = '', + api_version = '0', items = [ jobset.models.jobset_v1alpha2_job_set.JobsetV1alpha2JobSet( - api_version = '', - kind = '', + api_version = '0', + kind = '0', metadata = None, spec = jobset.models.jobset_v1alpha2_job_set_spec.JobsetV1alpha2JobSetSpec( coordinator = jobset.models.jobset_v1alpha2_coordinator.JobsetV1alpha2Coordinator( job_index = 56, pod_index = 56, - replicated_job = '', ), + replicated_job = '0', ), failure_policy = jobset.models.jobset_v1alpha2_failure_policy.JobsetV1alpha2FailurePolicy( max_restarts = 56, rules = [ jobset.models.jobset_v1alpha2_failure_policy_rule.JobsetV1alpha2FailurePolicyRule( - action = '', - name = '', + action = '0', + name = '0', on_job_failure_reasons = [ - '' + '0' ], target_replicated_jobs = [ - '' + '0' ], ) ], ), - managed_by = '', + managed_by = '0', network = jobset.models.jobset_v1alpha2_network.JobsetV1alpha2Network( enable_dns_hostnames = True, publish_not_ready_addresses = True, - subdomain = '', ), + subdomain = '0', ), replicated_jobs = [ jobset.models.jobset_v1alpha2_replicated_job.JobsetV1alpha2ReplicatedJob( - name = '', + name = '0', replicas = 56, template = V1JobTemplateSpec(), ) ], startup_policy = jobset.models.jobset_v1alpha2_startup_policy.JobsetV1alpha2StartupPolicy( - startup_policy_order = '', ), + startup_policy_order = '0', ), success_policy = jobset.models.jobset_v1alpha2_success_policy.JobsetV1alpha2SuccessPolicy( - operator = '', ), + operator = '0', ), suspend = True, ttl_seconds_after_finished = 56, ), status = jobset.models.jobset_v1alpha2_job_set_status.JobsetV1alpha2JobSetStatus( @@ -84,58 +87,58 @@ def make_instance(self, include_optional) -> JobsetV1alpha2JobSetList: jobset.models.jobset_v1alpha2_replicated_job_status.JobsetV1alpha2ReplicatedJobStatus( active = 56, failed = 56, - name = '', + name = '0', ready = 56, succeeded = 56, suspended = 56, ) ], restarts = 56, restarts_count_towards_max = 56, - terminal_state = '', ), ) - ], - kind = '', + terminal_state = '0', ), ) + ], + kind = '0', metadata = None ) - else: + else : return JobsetV1alpha2JobSetList( items = [ jobset.models.jobset_v1alpha2_job_set.JobsetV1alpha2JobSet( - api_version = '', - kind = '', + api_version = '0', + kind = '0', metadata = None, spec = jobset.models.jobset_v1alpha2_job_set_spec.JobsetV1alpha2JobSetSpec( coordinator = jobset.models.jobset_v1alpha2_coordinator.JobsetV1alpha2Coordinator( job_index = 56, pod_index = 56, - replicated_job = '', ), + replicated_job = '0', ), failure_policy = jobset.models.jobset_v1alpha2_failure_policy.JobsetV1alpha2FailurePolicy( max_restarts = 56, rules = [ jobset.models.jobset_v1alpha2_failure_policy_rule.JobsetV1alpha2FailurePolicyRule( - action = '', - name = '', + action = '0', + name = '0', on_job_failure_reasons = [ - '' + '0' ], target_replicated_jobs = [ - '' + '0' ], ) ], ), - managed_by = '', + managed_by = '0', network = jobset.models.jobset_v1alpha2_network.JobsetV1alpha2Network( enable_dns_hostnames = True, publish_not_ready_addresses = True, - subdomain = '', ), + subdomain = '0', ), replicated_jobs = [ jobset.models.jobset_v1alpha2_replicated_job.JobsetV1alpha2ReplicatedJob( - name = '', + name = '0', replicas = 56, template = V1JobTemplateSpec(), ) ], startup_policy = jobset.models.jobset_v1alpha2_startup_policy.JobsetV1alpha2StartupPolicy( - startup_policy_order = '', ), + startup_policy_order = '0', ), success_policy = jobset.models.jobset_v1alpha2_success_policy.JobsetV1alpha2SuccessPolicy( - operator = '', ), + operator = '0', ), suspend = True, ttl_seconds_after_finished = 56, ), status = jobset.models.jobset_v1alpha2_job_set_status.JobsetV1alpha2JobSetStatus( @@ -146,22 +149,22 @@ def make_instance(self, include_optional) -> JobsetV1alpha2JobSetList: jobset.models.jobset_v1alpha2_replicated_job_status.JobsetV1alpha2ReplicatedJobStatus( active = 56, failed = 56, - name = '', + name = '0', ready = 56, succeeded = 56, suspended = 56, ) ], restarts = 56, restarts_count_towards_max = 56, - terminal_state = '', ), ) + terminal_state = '0', ), ) ], ) - """ def testJobsetV1alpha2JobSetList(self): """Test JobsetV1alpha2JobSetList""" - # inst_req_only = self.make_instance(include_optional=False) - # inst_req_and_optional = self.make_instance(include_optional=True) + inst_req_only = self.make_instance(include_optional=False) + inst_req_and_optional = self.make_instance(include_optional=True) + if __name__ == '__main__': unittest.main() diff --git a/sdk/python/test/test_jobset_v1alpha2_job_set_spec.py b/sdk/python/test/test_jobset_v1alpha2_job_set_spec.py index f3f8a40a8..35bf8cabf 100644 --- a/sdk/python/test/test_jobset_v1alpha2_job_set_spec.py +++ b/sdk/python/test/test_jobset_v1alpha2_job_set_spec.py @@ -3,18 +3,23 @@ """ JobSet SDK - Python SDK for the JobSet API + Python SDK for the JobSet API # noqa: E501 The version of the OpenAPI document: v0.1.4 - Generated by OpenAPI Generator (https://openapi-generator.tech) + Generated by: https://openapi-generator.tech +""" - Do not edit the class manually. -""" # noqa: E501 +from __future__ import absolute_import +# Kubernetes imports +from kubernetes.client.models.v1_job_template_spec import V1JobTemplateSpec import unittest +import datetime -from jobset.models.jobset_v1alpha2_job_set_spec import JobsetV1alpha2JobSetSpec +import jobset +from jobset.models.jobset_v1alpha2_job_set_spec import JobsetV1alpha2JobSetSpec # noqa: E501 +from jobset.rest import ApiException class TestJobsetV1alpha2JobSetSpec(unittest.TestCase): """JobsetV1alpha2JobSetSpec unit test stubs""" @@ -25,63 +30,61 @@ def setUp(self): def tearDown(self): pass - def make_instance(self, include_optional) -> JobsetV1alpha2JobSetSpec: + def make_instance(self, include_optional): """Test JobsetV1alpha2JobSetSpec - include_optional is a boolean, when False only required + include_option is a boolean, when False only required params are included, when True both required and optional params are included """ - # uncomment below to create an instance of `JobsetV1alpha2JobSetSpec` - """ - model = JobsetV1alpha2JobSetSpec() - if include_optional: + # model = jobset.models.jobset_v1alpha2_job_set_spec.JobsetV1alpha2JobSetSpec() # noqa: E501 + if include_optional : return JobsetV1alpha2JobSetSpec( coordinator = jobset.models.jobset_v1alpha2_coordinator.JobsetV1alpha2Coordinator( job_index = 56, pod_index = 56, - replicated_job = '', ), + replicated_job = '0', ), failure_policy = jobset.models.jobset_v1alpha2_failure_policy.JobsetV1alpha2FailurePolicy( max_restarts = 56, rules = [ jobset.models.jobset_v1alpha2_failure_policy_rule.JobsetV1alpha2FailurePolicyRule( - action = '', - name = '', + action = '0', + name = '0', on_job_failure_reasons = [ - '' + '0' ], target_replicated_jobs = [ - '' + '0' ], ) - ], ), - managed_by = '', + ], ), + managed_by = '0', network = jobset.models.jobset_v1alpha2_network.JobsetV1alpha2Network( enable_dns_hostnames = True, publish_not_ready_addresses = True, - subdomain = '', ), + subdomain = '0', ), replicated_jobs = [ jobset.models.jobset_v1alpha2_replicated_job.JobsetV1alpha2ReplicatedJob( - name = '', + name = '0', replicas = 56, template = V1JobTemplateSpec(), ) - ], + ], startup_policy = jobset.models.jobset_v1alpha2_startup_policy.JobsetV1alpha2StartupPolicy( - startup_policy_order = '', ), + startup_policy_order = '0', ), success_policy = jobset.models.jobset_v1alpha2_success_policy.JobsetV1alpha2SuccessPolicy( - operator = '', + operator = '0', target_replicated_jobs = [ - '' - ], ), - suspend = True, + '0' + ], ), + suspend = True, ttl_seconds_after_finished = 56 ) - else: + else : return JobsetV1alpha2JobSetSpec( ) - """ def testJobsetV1alpha2JobSetSpec(self): """Test JobsetV1alpha2JobSetSpec""" - # inst_req_only = self.make_instance(include_optional=False) - # inst_req_and_optional = self.make_instance(include_optional=True) + inst_req_only = self.make_instance(include_optional=False) + inst_req_and_optional = self.make_instance(include_optional=True) + if __name__ == '__main__': unittest.main() diff --git a/sdk/python/test/test_jobset_v1alpha2_job_set_status.py b/sdk/python/test/test_jobset_v1alpha2_job_set_status.py index c80e1eda7..345a5b083 100644 --- a/sdk/python/test/test_jobset_v1alpha2_job_set_status.py +++ b/sdk/python/test/test_jobset_v1alpha2_job_set_status.py @@ -3,18 +3,23 @@ """ JobSet SDK - Python SDK for the JobSet API + Python SDK for the JobSet API # noqa: E501 The version of the OpenAPI document: v0.1.4 - Generated by OpenAPI Generator (https://openapi-generator.tech) + Generated by: https://openapi-generator.tech +""" - Do not edit the class manually. -""" # noqa: E501 +from __future__ import absolute_import +# Kubernetes imports +from kubernetes.client.models.v1_job_template_spec import V1JobTemplateSpec import unittest +import datetime -from jobset.models.jobset_v1alpha2_job_set_status import JobsetV1alpha2JobSetStatus +import jobset +from jobset.models.jobset_v1alpha2_job_set_status import JobsetV1alpha2JobSetStatus # noqa: E501 +from jobset.rest import ApiException class TestJobsetV1alpha2JobSetStatus(unittest.TestCase): """JobsetV1alpha2JobSetStatus unit test stubs""" @@ -25,41 +30,39 @@ def setUp(self): def tearDown(self): pass - def make_instance(self, include_optional) -> JobsetV1alpha2JobSetStatus: + def make_instance(self, include_optional): """Test JobsetV1alpha2JobSetStatus - include_optional is a boolean, when False only required + include_option is a boolean, when False only required params are included, when True both required and optional params are included """ - # uncomment below to create an instance of `JobsetV1alpha2JobSetStatus` - """ - model = JobsetV1alpha2JobSetStatus() - if include_optional: + # model = jobset.models.jobset_v1alpha2_job_set_status.JobsetV1alpha2JobSetStatus() # noqa: E501 + if include_optional : return JobsetV1alpha2JobSetStatus( conditions = [ None - ], + ], replicated_jobs_status = [ jobset.models.jobset_v1alpha2_replicated_job_status.JobsetV1alpha2ReplicatedJobStatus( active = 56, failed = 56, - name = '', + name = '0', ready = 56, succeeded = 56, suspended = 56, ) - ], - restarts = 56, - restarts_count_towards_max = 56, - terminal_state = '' + ], + restarts = 56, + restarts_count_towards_max = 56, + terminal_state = '0' ) - else: + else : return JobsetV1alpha2JobSetStatus( ) - """ def testJobsetV1alpha2JobSetStatus(self): """Test JobsetV1alpha2JobSetStatus""" - # inst_req_only = self.make_instance(include_optional=False) - # inst_req_and_optional = self.make_instance(include_optional=True) + inst_req_only = self.make_instance(include_optional=False) + inst_req_and_optional = self.make_instance(include_optional=True) + if __name__ == '__main__': unittest.main() diff --git a/sdk/python/test/test_jobset_v1alpha2_network.py b/sdk/python/test/test_jobset_v1alpha2_network.py index ee85231f0..5b6a61e95 100644 --- a/sdk/python/test/test_jobset_v1alpha2_network.py +++ b/sdk/python/test/test_jobset_v1alpha2_network.py @@ -3,18 +3,23 @@ """ JobSet SDK - Python SDK for the JobSet API + Python SDK for the JobSet API # noqa: E501 The version of the OpenAPI document: v0.1.4 - Generated by OpenAPI Generator (https://openapi-generator.tech) + Generated by: https://openapi-generator.tech +""" - Do not edit the class manually. -""" # noqa: E501 +from __future__ import absolute_import +# Kubernetes imports +from kubernetes.client.models.v1_job_template_spec import V1JobTemplateSpec import unittest +import datetime -from jobset.models.jobset_v1alpha2_network import JobsetV1alpha2Network +import jobset +from jobset.models.jobset_v1alpha2_network import JobsetV1alpha2Network # noqa: E501 +from jobset.rest import ApiException class TestJobsetV1alpha2Network(unittest.TestCase): """JobsetV1alpha2Network unit test stubs""" @@ -25,29 +30,27 @@ def setUp(self): def tearDown(self): pass - def make_instance(self, include_optional) -> JobsetV1alpha2Network: + def make_instance(self, include_optional): """Test JobsetV1alpha2Network - include_optional is a boolean, when False only required + include_option is a boolean, when False only required params are included, when True both required and optional params are included """ - # uncomment below to create an instance of `JobsetV1alpha2Network` - """ - model = JobsetV1alpha2Network() - if include_optional: + # model = jobset.models.jobset_v1alpha2_network.JobsetV1alpha2Network() # noqa: E501 + if include_optional : return JobsetV1alpha2Network( - enable_dns_hostnames = True, - publish_not_ready_addresses = True, - subdomain = '' + enable_dns_hostnames = True, + publish_not_ready_addresses = True, + subdomain = '0' ) - else: + else : return JobsetV1alpha2Network( ) - """ def testJobsetV1alpha2Network(self): """Test JobsetV1alpha2Network""" - # inst_req_only = self.make_instance(include_optional=False) - # inst_req_and_optional = self.make_instance(include_optional=True) + inst_req_only = self.make_instance(include_optional=False) + inst_req_and_optional = self.make_instance(include_optional=True) + if __name__ == '__main__': unittest.main() diff --git a/sdk/python/test/test_jobset_v1alpha2_replicated_job.py b/sdk/python/test/test_jobset_v1alpha2_replicated_job.py index 158eb2231..ac51873f9 100644 --- a/sdk/python/test/test_jobset_v1alpha2_replicated_job.py +++ b/sdk/python/test/test_jobset_v1alpha2_replicated_job.py @@ -3,18 +3,23 @@ """ JobSet SDK - Python SDK for the JobSet API + Python SDK for the JobSet API # noqa: E501 The version of the OpenAPI document: v0.1.4 - Generated by OpenAPI Generator (https://openapi-generator.tech) + Generated by: https://openapi-generator.tech +""" - Do not edit the class manually. -""" # noqa: E501 +from __future__ import absolute_import +# Kubernetes imports +from kubernetes.client.models.v1_job_template_spec import V1JobTemplateSpec import unittest +import datetime -from jobset.models.jobset_v1alpha2_replicated_job import JobsetV1alpha2ReplicatedJob +import jobset +from jobset.models.jobset_v1alpha2_replicated_job import JobsetV1alpha2ReplicatedJob # noqa: E501 +from jobset.rest import ApiException class TestJobsetV1alpha2ReplicatedJob(unittest.TestCase): """JobsetV1alpha2ReplicatedJob unit test stubs""" @@ -25,31 +30,29 @@ def setUp(self): def tearDown(self): pass - def make_instance(self, include_optional) -> JobsetV1alpha2ReplicatedJob: + def make_instance(self, include_optional): """Test JobsetV1alpha2ReplicatedJob - include_optional is a boolean, when False only required + include_option is a boolean, when False only required params are included, when True both required and optional params are included """ - # uncomment below to create an instance of `JobsetV1alpha2ReplicatedJob` - """ - model = JobsetV1alpha2ReplicatedJob() - if include_optional: + # model = jobset.models.jobset_v1alpha2_replicated_job.JobsetV1alpha2ReplicatedJob() # noqa: E501 + if include_optional : return JobsetV1alpha2ReplicatedJob( - name = '', - replicas = 56, + name = '0', + replicas = 56, template = V1JobTemplateSpec() ) - else: + else : return JobsetV1alpha2ReplicatedJob( - name = '', + name = '0', template = V1JobTemplateSpec(), ) - """ def testJobsetV1alpha2ReplicatedJob(self): """Test JobsetV1alpha2ReplicatedJob""" - # inst_req_only = self.make_instance(include_optional=False) - # inst_req_and_optional = self.make_instance(include_optional=True) + inst_req_only = self.make_instance(include_optional=False) + inst_req_and_optional = self.make_instance(include_optional=True) + if __name__ == '__main__': unittest.main() diff --git a/sdk/python/test/test_jobset_v1alpha2_replicated_job_status.py b/sdk/python/test/test_jobset_v1alpha2_replicated_job_status.py index 638a108c0..bcf087246 100644 --- a/sdk/python/test/test_jobset_v1alpha2_replicated_job_status.py +++ b/sdk/python/test/test_jobset_v1alpha2_replicated_job_status.py @@ -3,18 +3,23 @@ """ JobSet SDK - Python SDK for the JobSet API + Python SDK for the JobSet API # noqa: E501 The version of the OpenAPI document: v0.1.4 - Generated by OpenAPI Generator (https://openapi-generator.tech) + Generated by: https://openapi-generator.tech +""" - Do not edit the class manually. -""" # noqa: E501 +from __future__ import absolute_import +# Kubernetes imports +from kubernetes.client.models.v1_job_template_spec import V1JobTemplateSpec import unittest +import datetime -from jobset.models.jobset_v1alpha2_replicated_job_status import JobsetV1alpha2ReplicatedJobStatus +import jobset +from jobset.models.jobset_v1alpha2_replicated_job_status import JobsetV1alpha2ReplicatedJobStatus # noqa: E501 +from jobset.rest import ApiException class TestJobsetV1alpha2ReplicatedJobStatus(unittest.TestCase): """JobsetV1alpha2ReplicatedJobStatus unit test stubs""" @@ -25,38 +30,36 @@ def setUp(self): def tearDown(self): pass - def make_instance(self, include_optional) -> JobsetV1alpha2ReplicatedJobStatus: + def make_instance(self, include_optional): """Test JobsetV1alpha2ReplicatedJobStatus - include_optional is a boolean, when False only required + include_option is a boolean, when False only required params are included, when True both required and optional params are included """ - # uncomment below to create an instance of `JobsetV1alpha2ReplicatedJobStatus` - """ - model = JobsetV1alpha2ReplicatedJobStatus() - if include_optional: + # model = jobset.models.jobset_v1alpha2_replicated_job_status.JobsetV1alpha2ReplicatedJobStatus() # noqa: E501 + if include_optional : return JobsetV1alpha2ReplicatedJobStatus( - active = 56, - failed = 56, - name = '', - ready = 56, - succeeded = 56, + active = 56, + failed = 56, + name = '0', + ready = 56, + succeeded = 56, suspended = 56 ) - else: + else : return JobsetV1alpha2ReplicatedJobStatus( active = 56, failed = 56, - name = '', + name = '0', ready = 56, succeeded = 56, suspended = 56, ) - """ def testJobsetV1alpha2ReplicatedJobStatus(self): """Test JobsetV1alpha2ReplicatedJobStatus""" - # inst_req_only = self.make_instance(include_optional=False) - # inst_req_and_optional = self.make_instance(include_optional=True) + inst_req_only = self.make_instance(include_optional=False) + inst_req_and_optional = self.make_instance(include_optional=True) + if __name__ == '__main__': unittest.main() diff --git a/sdk/python/test/test_jobset_v1alpha2_startup_policy.py b/sdk/python/test/test_jobset_v1alpha2_startup_policy.py index fc8e116ed..b0eef20e2 100644 --- a/sdk/python/test/test_jobset_v1alpha2_startup_policy.py +++ b/sdk/python/test/test_jobset_v1alpha2_startup_policy.py @@ -3,18 +3,23 @@ """ JobSet SDK - Python SDK for the JobSet API + Python SDK for the JobSet API # noqa: E501 The version of the OpenAPI document: v0.1.4 - Generated by OpenAPI Generator (https://openapi-generator.tech) + Generated by: https://openapi-generator.tech +""" - Do not edit the class manually. -""" # noqa: E501 +from __future__ import absolute_import +# Kubernetes imports +from kubernetes.client.models.v1_job_template_spec import V1JobTemplateSpec import unittest +import datetime -from jobset.models.jobset_v1alpha2_startup_policy import JobsetV1alpha2StartupPolicy +import jobset +from jobset.models.jobset_v1alpha2_startup_policy import JobsetV1alpha2StartupPolicy # noqa: E501 +from jobset.rest import ApiException class TestJobsetV1alpha2StartupPolicy(unittest.TestCase): """JobsetV1alpha2StartupPolicy unit test stubs""" @@ -25,28 +30,26 @@ def setUp(self): def tearDown(self): pass - def make_instance(self, include_optional) -> JobsetV1alpha2StartupPolicy: + def make_instance(self, include_optional): """Test JobsetV1alpha2StartupPolicy - include_optional is a boolean, when False only required + include_option is a boolean, when False only required params are included, when True both required and optional params are included """ - # uncomment below to create an instance of `JobsetV1alpha2StartupPolicy` - """ - model = JobsetV1alpha2StartupPolicy() - if include_optional: + # model = jobset.models.jobset_v1alpha2_startup_policy.JobsetV1alpha2StartupPolicy() # noqa: E501 + if include_optional : return JobsetV1alpha2StartupPolicy( - startup_policy_order = '' + startup_policy_order = '0' ) - else: + else : return JobsetV1alpha2StartupPolicy( - startup_policy_order = '', + startup_policy_order = '0', ) - """ def testJobsetV1alpha2StartupPolicy(self): """Test JobsetV1alpha2StartupPolicy""" - # inst_req_only = self.make_instance(include_optional=False) - # inst_req_and_optional = self.make_instance(include_optional=True) + inst_req_only = self.make_instance(include_optional=False) + inst_req_and_optional = self.make_instance(include_optional=True) + if __name__ == '__main__': unittest.main() diff --git a/sdk/python/test/test_jobset_v1alpha2_success_policy.py b/sdk/python/test/test_jobset_v1alpha2_success_policy.py index c165a7b3d..17eb67faf 100644 --- a/sdk/python/test/test_jobset_v1alpha2_success_policy.py +++ b/sdk/python/test/test_jobset_v1alpha2_success_policy.py @@ -3,18 +3,23 @@ """ JobSet SDK - Python SDK for the JobSet API + Python SDK for the JobSet API # noqa: E501 The version of the OpenAPI document: v0.1.4 - Generated by OpenAPI Generator (https://openapi-generator.tech) + Generated by: https://openapi-generator.tech +""" - Do not edit the class manually. -""" # noqa: E501 +from __future__ import absolute_import +# Kubernetes imports +from kubernetes.client.models.v1_job_template_spec import V1JobTemplateSpec import unittest +import datetime -from jobset.models.jobset_v1alpha2_success_policy import JobsetV1alpha2SuccessPolicy +import jobset +from jobset.models.jobset_v1alpha2_success_policy import JobsetV1alpha2SuccessPolicy # noqa: E501 +from jobset.rest import ApiException class TestJobsetV1alpha2SuccessPolicy(unittest.TestCase): """JobsetV1alpha2SuccessPolicy unit test stubs""" @@ -25,31 +30,29 @@ def setUp(self): def tearDown(self): pass - def make_instance(self, include_optional) -> JobsetV1alpha2SuccessPolicy: + def make_instance(self, include_optional): """Test JobsetV1alpha2SuccessPolicy - include_optional is a boolean, when False only required + include_option is a boolean, when False only required params are included, when True both required and optional params are included """ - # uncomment below to create an instance of `JobsetV1alpha2SuccessPolicy` - """ - model = JobsetV1alpha2SuccessPolicy() - if include_optional: + # model = jobset.models.jobset_v1alpha2_success_policy.JobsetV1alpha2SuccessPolicy() # noqa: E501 + if include_optional : return JobsetV1alpha2SuccessPolicy( - operator = '', + operator = '0', target_replicated_jobs = [ - '' + '0' ] ) - else: + else : return JobsetV1alpha2SuccessPolicy( - operator = '', + operator = '0', ) - """ def testJobsetV1alpha2SuccessPolicy(self): """Test JobsetV1alpha2SuccessPolicy""" - # inst_req_only = self.make_instance(include_optional=False) - # inst_req_and_optional = self.make_instance(include_optional=True) + inst_req_only = self.make_instance(include_optional=False) + inst_req_and_optional = self.make_instance(include_optional=True) + if __name__ == '__main__': unittest.main() diff --git a/sdk/python/tox.ini b/sdk/python/tox.ini index 8a2c6b5ce..c9aa1f15d 100644 --- a/sdk/python/tox.ini +++ b/sdk/python/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py3 +envlist = py27, py3 [testenv] deps=-r{toxinidir}/requirements.txt From 2843c4d7c239dde34922262eccc6095fda97c619 Mon Sep 17 00:00:00 2001 From: epicseven-cup Date: Wed, 9 Oct 2024 21:36:09 -0400 Subject: [PATCH 09/14] keep the update for gen-sdk.sh --- hack/python-sdk/gen-sdk.sh | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/hack/python-sdk/gen-sdk.sh b/hack/python-sdk/gen-sdk.sh index 4baaf0bcd..f1da5c48a 100755 --- a/hack/python-sdk/gen-sdk.sh +++ b/hack/python-sdk/gen-sdk.sh @@ -67,18 +67,13 @@ elif ! [ "$DOCKER_EXIST" ] && [ "$PODMAN_EXIST" ]; then CONTAINER_ENGINE="podman" fi -# Install the sdk using docker -${CONTAINER_ENGINE} run --rm \ +# Install the sdk using docker, using the user that is running the container engine so that files can still be removed +${CONTAINER_ENGINE} run --user $(id -u):$(id -g) --rm \ -v "${repo_root}":/local docker.io/openapitools/openapi-generator-cli generate \ -i /local/"${SWAGGER_CODEGEN_FILE}" \ -g python \ -o /local/"${SDK_OUTPUT_PATH}" \ - -c local/"${SWAGGER_CODEGEN_FILE}" - -if [ -d "docker-17.03.0-ce.tgz" ]; then - echo "Removing docker install folder" - rm -r docker-17.03.0-ce.tgz -fi + -c local/"${SWAGGER_CODEGEN_CONF}" echo "Running post-generation script ..." "${repo_root}"/hack/python-sdk/post_gen.py @@ -86,4 +81,10 @@ echo "Running post-generation script ..." echo "JobSet Python SDK is generated successfully to folder ${SDK_OUTPUT_PATH}/." # Remove setup.py -rm ${SDK_OUTPUT_PATH}/setup.py +rm "${SDK_OUTPUT_PATH}"/setup.py + +# Clean up +if [ -d "docker-17.03.0-ce.tgz" ]; then + echo "Removing docker install folder" + rm -r docker-17.03.0-ce.tgz +fi From 611b1447d07e2d05d133605d301f9d8d544527c0 Mon Sep 17 00:00:00 2001 From: epicseven-cup Date: Sun, 13 Oct 2024 15:52:08 -0400 Subject: [PATCH 10/14] removed docker install to make similar to the python sdk install --- hack/python-sdk/gen-sdk.sh | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/hack/python-sdk/gen-sdk.sh b/hack/python-sdk/gen-sdk.sh index f1da5c48a..1ab88daca 100755 --- a/hack/python-sdk/gen-sdk.sh +++ b/hack/python-sdk/gen-sdk.sh @@ -43,30 +43,9 @@ rm -rf "${SDK_OUTPUT_PATH}"/docs/V1*.md "${SDK_OUTPUT_PATH}"/jobset/models "${SD echo "Generating Python SDK for JobSet..." - # Defaults the container engine to docker CONTAINER_ENGINE=${CONTAINER_ENGINE:-docker} -DOCKER_EXIST=$(command -v docker) -PODMAN_EXIST=$(command -v podman) - -echo DOCKER_EXIST -echo PODMAN_EXIST -# Checking if docker / podman is installed -if ! [ "$DOCKER_EXIST" ] && ! [ "$PODMAN_EXIST" ]; then - # Install docker - echo "Both Podman and Docker is not installed" - echo "Installing Docker now (Version 17.03.0)" - # Defaulting to 17.03.0 - wget https://download.docker.com/linux/static/stable/x86_64/docker-17.03.0-ce.tgz - tar xzvf docker-17.03.0-ce.tgz - echo "Starting dockerd" - ./docker/dockerd & -elif ! [ "$DOCKER_EXIST" ] && [ "$PODMAN_EXIST" ]; then - echo "Found Podman, switching to Podman" - CONTAINER_ENGINE="podman" -fi - # Install the sdk using docker, using the user that is running the container engine so that files can still be removed ${CONTAINER_ENGINE} run --user $(id -u):$(id -g) --rm \ -v "${repo_root}":/local docker.io/openapitools/openapi-generator-cli generate \ From 1ad7b04b1e45ff5e9cff3fc9d6aceca4a1d4b36d Mon Sep 17 00:00:00 2001 From: tomato Date: Sun, 15 Dec 2024 18:32:53 -0500 Subject: [PATCH 11/14] added podman support --- hack/python-sdk/gen-sdk.sh | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/hack/python-sdk/gen-sdk.sh b/hack/python-sdk/gen-sdk.sh index 1ab88daca..8236e6ed4 100755 --- a/hack/python-sdk/gen-sdk.sh +++ b/hack/python-sdk/gen-sdk.sh @@ -45,9 +45,20 @@ echo "Generating Python SDK for JobSet..." # Defaults the container engine to docker CONTAINER_ENGINE=${CONTAINER_ENGINE:-docker} +USERLEVEL="--user $(id -u):$(id -g)" + +# Checking the path of podman, silencing the errors +which podman &> /dev/null + +# Checking the exit status of which command, 0 means that command exit successfully +if [[ $? -eq 0 ]]; then + echo "Podman is found, changing over to podman" + CONTAINER_ENGINE=podman + USERLEVEL="" +fi # Install the sdk using docker, using the user that is running the container engine so that files can still be removed -${CONTAINER_ENGINE} run --user $(id -u):$(id -g) --rm \ +${CONTAINER_ENGINE} run $USERLEVEL --rm \ -v "${repo_root}":/local docker.io/openapitools/openapi-generator-cli generate \ -i /local/"${SWAGGER_CODEGEN_FILE}" \ -g python \ @@ -60,10 +71,4 @@ echo "Running post-generation script ..." echo "JobSet Python SDK is generated successfully to folder ${SDK_OUTPUT_PATH}/." # Remove setup.py -rm "${SDK_OUTPUT_PATH}"/setup.py - -# Clean up -if [ -d "docker-17.03.0-ce.tgz" ]; then - echo "Removing docker install folder" - rm -r docker-17.03.0-ce.tgz -fi +rm "${SDK_OUTPUT_PATH}"/setup.py \ No newline at end of file From 44a9dff3e505b1d0182a7739b0e837c1cc7928bc Mon Sep 17 00:00:00 2001 From: tomato Date: Mon, 16 Dec 2024 21:56:47 -0500 Subject: [PATCH 12/14] removed podman for testing --- hack/python-sdk/gen-sdk.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/hack/python-sdk/gen-sdk.sh b/hack/python-sdk/gen-sdk.sh index 8236e6ed4..413932c20 100755 --- a/hack/python-sdk/gen-sdk.sh +++ b/hack/python-sdk/gen-sdk.sh @@ -48,14 +48,14 @@ CONTAINER_ENGINE=${CONTAINER_ENGINE:-docker} USERLEVEL="--user $(id -u):$(id -g)" # Checking the path of podman, silencing the errors -which podman &> /dev/null +#which podman &> /dev/null -# Checking the exit status of which command, 0 means that command exit successfully -if [[ $? -eq 0 ]]; then - echo "Podman is found, changing over to podman" - CONTAINER_ENGINE=podman - USERLEVEL="" -fi +## Checking the exit status of which command, 0 means that command exit successfully +#if [[ $? -eq 0 ]]; then +# echo "Podman is found, changing over to podman" +# CONTAINER_ENGINE=podman +# USERLEVEL="" +#fi # Install the sdk using docker, using the user that is running the container engine so that files can still be removed ${CONTAINER_ENGINE} run $USERLEVEL --rm \ From 712dcfb68360c9bbdeda91db60159b6fb3131c40 Mon Sep 17 00:00:00 2001 From: tomato Date: Tue, 17 Dec 2024 23:12:41 -0500 Subject: [PATCH 13/14] clean up podman left overs --- hack/python-sdk/gen-sdk.sh | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/hack/python-sdk/gen-sdk.sh b/hack/python-sdk/gen-sdk.sh index 413932c20..725e356e9 100755 --- a/hack/python-sdk/gen-sdk.sh +++ b/hack/python-sdk/gen-sdk.sh @@ -45,20 +45,9 @@ echo "Generating Python SDK for JobSet..." # Defaults the container engine to docker CONTAINER_ENGINE=${CONTAINER_ENGINE:-docker} -USERLEVEL="--user $(id -u):$(id -g)" - -# Checking the path of podman, silencing the errors -#which podman &> /dev/null - -## Checking the exit status of which command, 0 means that command exit successfully -#if [[ $? -eq 0 ]]; then -# echo "Podman is found, changing over to podman" -# CONTAINER_ENGINE=podman -# USERLEVEL="" -#fi # Install the sdk using docker, using the user that is running the container engine so that files can still be removed -${CONTAINER_ENGINE} run $USERLEVEL --rm \ +${CONTAINER_ENGINE} run --user $(id -u):$(id -g) --rm \ -v "${repo_root}":/local docker.io/openapitools/openapi-generator-cli generate \ -i /local/"${SWAGGER_CODEGEN_FILE}" \ -g python \ From e31006d7cba3d7cecd56448c6dff1fb13fb95937 Mon Sep 17 00:00:00 2001 From: epicseven-cup Date: Thu, 16 Jan 2025 23:19:05 -0500 Subject: [PATCH 14/14] update the pathing for k8 test image --- hack/python-sdk/gen-sdk.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hack/python-sdk/gen-sdk.sh b/hack/python-sdk/gen-sdk.sh index 725e356e9..210e2b9e8 100755 --- a/hack/python-sdk/gen-sdk.sh +++ b/hack/python-sdk/gen-sdk.sh @@ -49,10 +49,10 @@ CONTAINER_ENGINE=${CONTAINER_ENGINE:-docker} # Install the sdk using docker, using the user that is running the container engine so that files can still be removed ${CONTAINER_ENGINE} run --user $(id -u):$(id -g) --rm \ -v "${repo_root}":/local docker.io/openapitools/openapi-generator-cli generate \ - -i /local/"${SWAGGER_CODEGEN_FILE}" \ + -i /local/hack/python-sdk/swagger.json \ -g python \ - -o /local/"${SDK_OUTPUT_PATH}" \ - -c local/"${SWAGGER_CODEGEN_CONF}" + -o /local/sdk/python \ + -c local/hack/python-sdk/swagger_config.json echo "Running post-generation script ..." "${repo_root}"/hack/python-sdk/post_gen.py