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

Argo Python SDK #9

Closed
zhujiangyou opened this issue Nov 21, 2019 · 6 comments
Closed

Argo Python SDK #9

zhujiangyou opened this issue Nov 21, 2019 · 6 comments
Labels
good first issue Good for newcomers

Comments

@zhujiangyou
Copy link

Where can I find a python SDK to replace Argo's various command-line interfaces?

@CermakM
Copy link
Owner

CermakM commented Dec 9, 2019

Hey @zhujiangyou, thanks for the question!

I'll try to clarify the purpose of this client and see if I answer your question.

This library currently doesn't have the Argo CLI ported to Python, if that's what you mean. I am sorry to disappoint you if that's what you have expected.

This client acts similarly to the kubernetes-python-client. It is basically an extension to the Kubernetes client providing Argo models and API paths to create, list, delete and in general manipulate workflows and workflow templates as you would do with any other Kubernetes resource.

@CermakM CermakM added the good first issue Good for newcomers label Dec 9, 2019
@yxue-kabam
Copy link

@CermakM just wanted to let you know what you have done is very valuable to me. I didn't make much progress on this after I tried to generate python sdk from argo swag definition (with Kubernetes client generator). I were able to generate the models but I couldn't fix the dependency problems where some Argo models just assume kubernetes models were there. So would love to know how you have resolved that.

Other than that it's been great, I have been able to build dags on top of your sdk and on my way to work a workflow framework on top of your client. Thank you!

@CermakM
Copy link
Owner

CermakM commented Dec 10, 2019

Hey @yxue-kabam. Thanks a lot for the feedback! :) I am glad it helps!

Yep, it's been somewhat complicated to include the kubernetes models. I solved it by tweaking the code generation and including the Python Kubernetes models.

@CermakM
Copy link
Owner

CermakM commented Dec 18, 2019

The SDK is currently under development: https://github.com/CermakM/argo-python-sdk

@CermakM CermakM changed the title Programming implementation of Argo Argo Python SDK Jan 3, 2020
@CermakM
Copy link
Owner

CermakM commented Jan 3, 2020

Here is a hello-world example of the Argo Python SDK.
Feel free to visit https://github.com/CermakM/argo-python-sdk for more examples.


Argo YAMLArgo Python

# @file: hello-world.yaml
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  name: hello-world
  generateName: hello-world-
spec:
  entrypoint: whalesay
  templates:
  - name: whalesay
    container:
      name: whalesay
      image: docker/whalesay:latest
      command: [cowsay]
      args: ["hello world"]

from argo.workflows.sdk import Workflow
from argo.workflows.sdk import template

from argo.workflows.sdk.templates import V1Container


class HelloWorld(Workflow):

    entrypoint = "whalesay"

    @template
    def whalesay(self) -> V1Container:
        container = V1Container(
            image="docker/whalesay:latest",
            name="whalesay",
            command=["cowsay"],
            args=["hello world"]
        )

        return container

@CermakM CermakM pinned this issue Jan 26, 2020
@CermakM
Copy link
Owner

CermakM commented Jan 30, 2020

If you want an API for Argo CLI directly, please check https://github.com/argoproj-labs/argo-workflows-python-sdk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants