Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add python client #4

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

/java/.openapi-generator/
/java/api/
/client/.gitignore
/java/.openapi-generator-ignore
/java/build.*
/java/gradle*
Expand All @@ -11,3 +10,9 @@
/java/target/
/java/git_push.sh
/java/.travis.yml

/python/.openapi-generator/
/python/.openapi-generator-ignore
/python/test
/python/git_push.sh
/python/dist/
66 changes: 66 additions & 0 deletions python/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/
venv/
.venv/
.python-version
.pytest_cache

# Translations
*.mo
*.pot

# Django stuff:
*.log

# Sphinx documentation
docs/_build/

# PyBuilder
target/

#Ipython Notebook
.ipynb_checkpoints
24 changes: 24 additions & 0 deletions python/.gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# ref: https://docs.gitlab.com/ee/ci/README.html

stages:
- test

.tests:
stage: test
script:
- pip install -r requirements.txt
- pip install -r test-requirements.txt
- pytest --cov=numaflow

test-3.6:
extends: .tests
image: python:3.6-alpine
test-3.7:
extends: .tests
image: python:3.7-alpine
test-3.8:
extends: .tests
image: python:3.8-alpine
test-3.9:
extends: .tests
image: python:3.9-alpine
13 changes: 13 additions & 0 deletions python/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# ref: https://docs.travis-ci.com/user/languages/python
language: python
python:
- "3.6"
- "3.7"
- "3.8"
- "3.9"
# command to install dependencies
install:
- "pip install -r requirements.txt"
- "pip install -r test-requirements.txt"
# command to run tests
script: pytest --cov=numaflow
42 changes: 42 additions & 0 deletions python/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
VERSION ?= main

SDK_VERSION := $(shell if [[ "$(VERSION)" =~ ^v[0-9]+\.[0-9]+\.[0-9]+.* ]]; then echo ${VERSION} | cut -c2-; elif [[ "$(VERSION)" =~ ^main$$ ]]; then echo 0.0.0-pre; else echo $(VERSION); fi)

GENERATOR_VERSION := v5.4.0

DOCKER = docker run --rm -v `pwd -P`:/base --workdir /base

publish: generate
echo TODO

generate:
rm -Rf ./docs ./test ./numaflow/models/ ./numaflow/model/
mkdir -p ./dist
cat ../swagger.json | ../hack/swaggerfilter.py io.numaproj.numaflow | \
sed 's/io.k8s.api.core.//' | \
sed 's/io.k8s.apimachinery.pkg.apis.meta.//' | \
sed 's/io.k8s.apimachinery.pkg.api.//' | \
sed 's/io.numaproj.numaflow.v1alpha1.//' \
> ./dist/swagger.json
$(DOCKER) openapitools/openapi-generator-cli:$(GENERATOR_VERSION) \
generate \
-i /base/dist/swagger.json \
-g python \
-o /base \
--additional-properties packageVersion=${SDK_VERSION} \
--additional-properties packageName="numaflow" \
--additional-properties projectName="numaflow" \
--additional-properties hideGenerationTimestamp=true \
--remove-operation-id-prefix \
--model-name-prefix '' \
--model-name-suffix '' \
--artifact-id numaflow-python-client \
--global-property modelTests=false \
--global-property packageName=numaflow \
--import-mappings V1ResourceRequirements="from kubernetes.client import V1ResourceRequirements" \
--import-mappings V1SecretKeySelector="from kubernetes.client import V1SecretKeySelector" \
--generate-alias-as-model
echo "kubernetes >= 22.6.0" >> requirements.txt

install:
pip3 install ./
158 changes: 158 additions & 0 deletions python/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
# numaflow
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:

- API version: v0.7.0
- Package version: 0.7.0
- Build package: org.openapitools.codegen.languages.PythonClientCodegen

## Requirements.

Python >=3.6

## Installation & Usage
### pip install

If the python package is hosted on a repository, you can install directly using:

```sh
pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git
```
(you may need to run `pip` with root permission: `sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git`)

Then import the package:
```python
import numaflow
```

### Setuptools

Install via [Setuptools](http://pypi.python.org/pypi/setuptools).

```sh
python setup.py install --user
```
(or `sudo python setup.py install` to install the package for all users)

Then import the package:
```python
import numaflow
```

## Getting Started

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

```python

import time
import numaflow
from pprint import pprint
```

## Documentation for API Endpoints

All URIs are relative to *http://localhost*

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------


## Documentation For Models

- [AbstractPodTemplate](docs/AbstractPodTemplate.md)
- [AbstractVertex](docs/AbstractVertex.md)
- [Authorization](docs/Authorization.md)
- [BasicAuth](docs/BasicAuth.md)
- [Buffer](docs/Buffer.md)
- [BufferServiceConfig](docs/BufferServiceConfig.md)
- [Container](docs/Container.md)
- [ContainerBuilder](docs/ContainerBuilder.md)
- [ContainerTemplate](docs/ContainerTemplate.md)
- [DaemonTemplate](docs/DaemonTemplate.md)
- [Edge](docs/Edge.md)
- [EdgeLimits](docs/EdgeLimits.md)
- [FixedWindow](docs/FixedWindow.md)
- [ForwardConditions](docs/ForwardConditions.md)
- [Function](docs/Function.md)
- [GeneratorSource](docs/GeneratorSource.md)
- [GetContainerReq](docs/GetContainerReq.md)
- [GetDaemonDeploymentReq](docs/GetDaemonDeploymentReq.md)
- [GetJetStreamServiceSpecReq](docs/GetJetStreamServiceSpecReq.md)
- [GetJetStreamStatefulSetSpecReq](docs/GetJetStreamStatefulSetSpecReq.md)
- [GetRedisServiceSpecReq](docs/GetRedisServiceSpecReq.md)
- [GetRedisStatefulSetSpecReq](docs/GetRedisStatefulSetSpecReq.md)
- [GetVertexPodSpecReq](docs/GetVertexPodSpecReq.md)
- [GroupBy](docs/GroupBy.md)
- [HTTPSource](docs/HTTPSource.md)
- [InterStepBufferService](docs/InterStepBufferService.md)
- [InterStepBufferServiceList](docs/InterStepBufferServiceList.md)
- [InterStepBufferServiceSpec](docs/InterStepBufferServiceSpec.md)
- [InterStepBufferServiceStatus](docs/InterStepBufferServiceStatus.md)
- [JetStreamBufferService](docs/JetStreamBufferService.md)
- [JetStreamConfig](docs/JetStreamConfig.md)
- [JobTemplate](docs/JobTemplate.md)
- [KafkaSink](docs/KafkaSink.md)
- [KafkaSource](docs/KafkaSource.md)
- [Lifecycle](docs/Lifecycle.md)
- [Metadata](docs/Metadata.md)
- [NativeRedis](docs/NativeRedis.md)
- [NatsAuth](docs/NatsAuth.md)
- [NatsSource](docs/NatsSource.md)
- [PBQStorage](docs/PBQStorage.md)
- [PersistenceStrategy](docs/PersistenceStrategy.md)
- [Pipeline](docs/Pipeline.md)
- [PipelineLimits](docs/PipelineLimits.md)
- [PipelineList](docs/PipelineList.md)
- [PipelineSpec](docs/PipelineSpec.md)
- [PipelineStatus](docs/PipelineStatus.md)
- [RedisBufferService](docs/RedisBufferService.md)
- [RedisConfig](docs/RedisConfig.md)
- [RedisSettings](docs/RedisSettings.md)
- [Scale](docs/Scale.md)
- [Sink](docs/Sink.md)
- [SlidingWindow](docs/SlidingWindow.md)
- [Source](docs/Source.md)
- [Status](docs/Status.md)
- [TLS](docs/TLS.md)
- [Templates](docs/Templates.md)
- [UDF](docs/UDF.md)
- [UDSink](docs/UDSink.md)
- [Vertex](docs/Vertex.md)
- [VertexInstance](docs/VertexInstance.md)
- [VertexLimits](docs/VertexLimits.md)
- [VertexList](docs/VertexList.md)
- [VertexSpec](docs/VertexSpec.md)
- [VertexStatus](docs/VertexStatus.md)
- [Watermark](docs/Watermark.md)
- [Window](docs/Window.md)


## Documentation For Authorization

All endpoints do not require authorization.

## Author



## Notes for Large OpenAPI documents
If the OpenAPI document is large, imports in numaflow.apis and numaflow.models may fail with a
RecursionError indicating the maximum recursion limit has been exceeded. In that case, there are a couple of solutions:

Solution 1:
Use specific imports for apis and models like:
- `from numaflow.api.default_api import DefaultApi`
- `from numaflow.model.pet import Pet`

Solution 2:
Before importing the package, adjust the maximum recursion limit as shown below:
```
import sys
sys.setrecursionlimit(1500)
import numaflow
from numaflow.apis import *
from numaflow.models import *
```

21 changes: 21 additions & 0 deletions python/docs/AbstractPodTemplate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# AbstractPodTemplate

AbstractPodTemplate provides a template for pod customization in vertices, daemon deployments and so on.

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**affinity** | [**V1Affinity**](V1Affinity.md) | | [optional]
**image_pull_secrets** | [**[V1LocalObjectReference]**](V1LocalObjectReference.md) | ImagePullSecrets is an optional list of references to secrets in the same namespace to use for pulling any of the images used by this PodSpec. If specified, these secrets will be passed to individual puller implementations for them to use. For example, in the case of docker, only DockerConfig type secrets are honored. More info: https://kubernetes.io/docs/concepts/containers/images#specifying-imagepullsecrets-on-a-pod | [optional]
**metadata** | [**Metadata**](Metadata.md) | | [optional]
**node_selector** | **{str: (str,)}** | NodeSelector is a selector which must be true for the pod to fit on a node. Selector which must match a node's labels for the pod to be scheduled on that node. More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ | [optional]
**priority** | **int** | The priority value. Various system components use this field to find the priority of the Redis pod. When Priority Admission Controller is enabled, it prevents users from setting this field. The admission controller populates this field from PriorityClassName. The higher the value, the higher the priority. More info: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/ | [optional]
**priority_class_name** | **str** | If specified, indicates the Redis pod's priority. \"system-node-critical\" and \"system-cluster-critical\" are two special keywords which indicate the highest priorities with the former being the highest priority. Any other name must be defined by creating a PriorityClass object with that name. If not specified, the pod priority will be default or zero if there is no default. More info: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/ | [optional]
**security_context** | [**V1PodSecurityContext**](V1PodSecurityContext.md) | | [optional]
**service_account_name** | **str** | ServiceAccountName applied to the pod | [optional]
**tolerations** | [**[V1Toleration]**](V1Toleration.md) | If specified, the pod's tolerations. | [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)


31 changes: 31 additions & 0 deletions python/docs/AbstractVertex.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# AbstractVertex


## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**name** | **str** | |
**affinity** | [**V1Affinity**](V1Affinity.md) | | [optional]
**container_template** | [**ContainerTemplate**](ContainerTemplate.md) | | [optional]
**image_pull_secrets** | [**[V1LocalObjectReference]**](V1LocalObjectReference.md) | ImagePullSecrets is an optional list of references to secrets in the same namespace to use for pulling any of the images used by this PodSpec. If specified, these secrets will be passed to individual puller implementations for them to use. For example, in the case of docker, only DockerConfig type secrets are honored. More info: https://kubernetes.io/docs/concepts/containers/images#specifying-imagepullsecrets-on-a-pod | [optional]
**init_container_template** | [**ContainerTemplate**](ContainerTemplate.md) | | [optional]
**init_containers** | [**[V1Container]**](V1Container.md) | List of init containers belonging to the pod. More info: https://kubernetes.io/docs/concepts/workloads/pods/init-containers/ | [optional]
**limits** | [**VertexLimits**](VertexLimits.md) | | [optional]
**metadata** | [**Metadata**](Metadata.md) | | [optional]
**node_selector** | **{str: (str,)}** | NodeSelector is a selector which must be true for the pod to fit on a node. Selector which must match a node's labels for the pod to be scheduled on that node. More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ | [optional]
**priority** | **int** | The priority value. Various system components use this field to find the priority of the Redis pod. When Priority Admission Controller is enabled, it prevents users from setting this field. The admission controller populates this field from PriorityClassName. The higher the value, the higher the priority. More info: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/ | [optional]
**priority_class_name** | **str** | If specified, indicates the Redis pod's priority. \"system-node-critical\" and \"system-cluster-critical\" are two special keywords which indicate the highest priorities with the former being the highest priority. Any other name must be defined by creating a PriorityClass object with that name. If not specified, the pod priority will be default or zero if there is no default. More info: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/ | [optional]
**scale** | [**Scale**](Scale.md) | | [optional]
**security_context** | [**V1PodSecurityContext**](V1PodSecurityContext.md) | | [optional]
**service_account_name** | **str** | ServiceAccountName applied to the pod | [optional]
**sidecars** | [**[V1Container]**](V1Container.md) | List of sidecar containers belonging to the pod. | [optional]
**sink** | [**Sink**](Sink.md) | | [optional]
**source** | [**Source**](Source.md) | | [optional]
**tolerations** | [**[V1Toleration]**](V1Toleration.md) | If specified, the pod's tolerations. | [optional]
**udf** | [**UDF**](UDF.md) | | [optional]
**volumes** | [**[V1Volume]**](V1Volume.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)


12 changes: 12 additions & 0 deletions python/docs/Authorization.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Authorization


## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**token** | [**V1SecretKeySelector**](V1SecretKeySelector.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