Skip to main content

Manage and create Clarifai workflows with yaml files

Project description

yaml2workflow

PyPi version Python 3.7 Github Actions

Clarifai workflows are powerful tools. Building them via the API is a sure way to automate this process, especially if you have many nodes and branches.

Taking inspiration from Kubernetes Helm Charts and AWS Cloud Formation templates, yaml2workflow is designed to make automating the creation and managing the definition of workflows easier and more transparent.

🙌 Define Workflows as YAML files

Much clearer and more human-readable definitions without distractors. Also, by storing the workflow definitions as a file, you can now use version control for your future automations! Winning.

# A single node workflow
workflow:
  id: test-wf-1
  nodes:
    - id: detector
      model:
          model_id: face-detection
          model_version_id: 45fb9a671625463fa646c3523a3087d5

🙌 Export Workflows as YAML files

[New!] Export your workflows into YAML files as well. Simply pass in the workflow object from a GetWorkflow response. See export_example.py for how to do that.

from yaml2workflow.exporter.workflow import Exporter

with Exporter(response.workflow) as e:
  e.parse()
  e.export("export_example.yml")

🚀 Installation

Simply enter

pip install yaml2workflow

💪 Usage

  1. Create a YAML file to define your workflow. Gather the model IDs and model version IDs from Clarifai. See parse_example.yml for a full, filled in template.
  2. Import the library and use it directly in your code as follows:
from yaml2workflow.parser.workflow import parse

workflows = parse('parse_example.yml', stub=stub, metadata=metadata)

post_workflows_response = stub.PostWorkflows(
    service_pb2.PostWorkflowsRequest(
        workflows=workflows
    ),
    metadata=metadata
)

See parse_example.py for the full example.

🎉 Done! You've now unlocked more human-readble and more maintable workflows.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yaml2workflow-0.2.4.tar.gz (9.3 kB view hashes)

Uploaded Source

Built Distribution

yaml2workflow-0.2.4-py3-none-any.whl (10.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page