Skip to content

Commit

Permalink
feat: Bring Python client to core (argoproj#7025)
Browse files Browse the repository at this point in the history
Signed-off-by: Yuan Tang <[email protected]>
  • Loading branch information
terrytangyuan committed Oct 27, 2021
1 parent 5cec4a2 commit 2bbba15
Show file tree
Hide file tree
Showing 859 changed files with 258,043 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/sdks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
matrix:
name:
- java
- python
steps:
- uses: actions/checkout@v2
- run: make --directory sdks/${{matrix.name}} publish -B
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ scan-%:
.PHONY: codegen
codegen: types swagger docs manifests
make --directory sdks/java generate
make --directory sdks/python generate

.PHONY: types
types: pkg/apis/workflow/v1alpha1/generated.proto pkg/apis/workflow/v1alpha1/openapi_generated.go pkg/apis/workflow/v1alpha1/zz_generated.deepcopy.go
Expand Down
8 changes: 8 additions & 0 deletions sdks/python/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/client/.openapi-generator/
/client/.gitignore
/client/.openapi-generator-ignore
/client/*.*
/client/README.md
/client/test
/client/test-requirements.txt
/client/.gitignore
38 changes: 38 additions & 0 deletions sdks/python/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
GIT_TAG := $(shell git describe --exact-match --tags --abbrev=0 2> /dev/null || echo untagged)
ifeq ($(GIT_TAG),untagged)
VERSION := 0.0.0-latest
else
# remove the "v" prefix, not allowed
VERSION := $(GIT_TAG:v=)
endif

# work dir
WD := $(shell echo "`pwd`/client")

DOCKER = docker run --rm -v $(WD):/wd --workdir /wd
CHOWN = chown -R $(shell id -u):$(shell id -g)

publish: generate
echo "TODO: Publish the package to PyPI"

generate:
rm -Rf $(WD)
mkdir -p $(WD)
cat ../../api/openapi-spec/swagger.json | \
sed 's/io.k8s.api.core.v1.//' | \
sed 's/io.k8s.apimachinery.pkg.apis.meta.v1.//' \
> $(WD)/swagger.json
$(DOCKER) openapitools/openapi-generator-cli:v5.2.1 \
generate \
-i /wd/swagger.json \
-g python \
-o /wd \
-p hideGenerationTimestamp=true \
--skip-validate-spec \
--artifact-id argo-client-python \
--global-property modelTests=false \
--global-property packageName=workflows.client \
--global-property packageVersion=${CLIENT_VERSION}
--generate-alias-as-model
# https://vsupalov.com/docker-shared-permissions/#set-the-docker-user-when-running-your-container
$(CHOWN) $(WD) || sudo $(CHOWN) $(WD)
44 changes: 44 additions & 0 deletions sdks/python/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Argo Python SDK

This is the Python SDK for Argo Workflows.

## Requirements

Python >= 3.6

## Installation & Usage

To install the latest development version of the SDK, run the following:

```
pip install git+https://github.com/argoproj/argo-workflows@master#subdirectory=sdks/python/client
```

Then import the package:
```python
import openapi_client
```

## Getting Started

Please follow the [installation procedure](#installation--usage) and then run the following:

```python
import time
import openapi_client
import yaml
import requests

from pprint import pprint
from openapi_client.api import workflow_service_api
from openapi_client.model.io_argoproj_workflow_v1alpha1_workflow_create_request import IoArgoprojWorkflowV1alpha1WorkflowCreateRequest

configuration = openapi_client.Configuration(host="http:https://localhost:2746")

resp = requests.get('https://raw.githubusercontent.com/argoproj/argo-workflows/master/examples/dag-diamond-steps.yaml')
manifest = yaml.safe_load(resp.text)
api_client = openapi_client.ApiClient(configuration)
api_instance = workflow_service_api.WorkflowServiceApi(api_client)
api_response = api_instance.workflow_service_create_workflow('argo', IoArgoprojWorkflowV1alpha1WorkflowCreateRequest(workflow=manifest, _check_type=False))
pprint(api_response)
```
16 changes: 16 additions & 0 deletions sdks/python/client/docs/AWSElasticBlockStoreVolumeSource.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# AWSElasticBlockStoreVolumeSource

Represents a Persistent Disk resource in AWS. An AWS EBS disk must exist before mounting to a container. The disk must also be in the same AWS zone as the kubelet. An AWS EBS disk can only be mounted as read/write once. AWS EBS volumes support ownership management and SELinux relabeling.

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**volume_id** | **str** | Unique ID of the persistent disk resource in AWS (Amazon EBS volume). More info: https://kubernetes.io/docs/concepts/storage/volumes#awselasticblockstore |
**fs_type** | **str** | Filesystem type of the volume that you want to mount. Tip: Ensure that the filesystem type is supported by the host operating system. Examples: \&quot;ext4\&quot;, \&quot;xfs\&quot;, \&quot;ntfs\&quot;. Implicitly inferred to be \&quot;ext4\&quot; if unspecified. More info: https://kubernetes.io/docs/concepts/storage/volumes#awselasticblockstore | [optional]
**partition** | **int** | The partition in the volume that you want to mount. If omitted, the default is to mount by volume name. Examples: For volume /dev/sda1, you specify the partition as \&quot;1\&quot;. Similarly, the volume partition for /dev/sda is \&quot;0\&quot; (or you can leave the property empty). | [optional]
**read_only** | **bool** | Specify \&quot;true\&quot; to force and set the ReadOnly property in VolumeMounts to \&quot;true\&quot;. If omitted, the default is \&quot;false\&quot;. More info: https://kubernetes.io/docs/concepts/storage/volumes#awselasticblockstore | [optional]
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


15 changes: 15 additions & 0 deletions sdks/python/client/docs/Affinity.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Affinity

Affinity is a group of affinity scheduling rules.

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**node_affinity** | [**NodeAffinity**](NodeAffinity.md) | | [optional]
**pod_affinity** | [**PodAffinity**](PodAffinity.md) | | [optional]
**pod_anti_affinity** | [**PodAntiAffinity**](PodAntiAffinity.md) | | [optional]
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


Loading

0 comments on commit 2bbba15

Please sign in to comment.