Metadata-Version: 2.4
Name: python_workflow_submitter
Version: 1.0.1
Summary: A way of submitting workflows to graphql in python
Home-page: https://github.com/DiamondLightSource/python-workflow-submitter
Author: Matthew Carre
Author-email: Matthew Carre <matthew.carre@diamond.ac.uk>
License-Expression: Apache-2.0
Project-URL: GitHub, https://github.com/DiamondLightSource/python-workflow-submitter
Project-URL: Homepage, https://github.com/DiamondLightSource/python-workflow-submitter
Project-URL: issues, https://github.com/DiamondLightSource/python-workflow-submitter/issues
Classifier: Development Status :: 3 - Alpha
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.10, <4
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: gql
Requires-Dist: aiohttp
Requires-Dist: hera
Requires-Dist: requests
Requires-Dist: PyYAML
Requires-Dist: pillow
Requires-Dist: numpy
Requires-Dist: h5py
Requires-Dist: dotenv
Requires-Dist: python-keycloak
Requires-Dist: pytest-asyncio
Requires-Dist: asyncio
Dynamic: author
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-python

[![CI](https://github.com/DiamondLightSource/python-workflow-submitter/actions/workflows/ci.yml/badge.svg)](https://github.com/DiamondLightSource/python-workflow-submitter/actions/workflows/ci.yml)
[![Coverage](https://codecov.io/gh/DiamondLightSource/python-workflow-submitter/branch/main/graph/badge.svg)](https://codecov.io/gh/DiamondLightSource/python-workflow-submitter)

[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
[![Copier](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/copier-org/copier/master/img/badge/badge-grayscale-inverted-border-orange.json)](https://github.com/copier-org/copier)
# python_workflow_submitter

 Python alternative to creating and running argo workflows in the Data Analysis Platform

This allows for the submission of yaml files to Diamond's GraphQL API.
This automatically lints yaml files before submission.

Notably, this requires a .env file in your src/ folder.

What            | Where
:---:           | :---:
Source          | <https://github.com/DiamondLightSource/python-workflow-submitter>
Docker          | `docker run ghcr.io/DiamondLightSource/python-workflow-submitter:latest`
Releases        | <https://github.com/DiamondLightSource/python-workflow-submitter/releases>

To create a helm template in your helm chart folder:
```python
import asyncio
from python_workflow_submitter.create_helm_yaml import create_helm_yaml

create_helm_yaml("notebook.yaml", "/workspaces/your_path/helm", "values/values.yaml")
```

To lint a yaml file (automatically called upon submitting workflows):
```python
import asyncio
from python_workflow_submitter.lintyaml import lint_yaml

lint_yaml("notebook.yaml")
```

To submit your workflow written in a notebook:

```python
from python_workflow_submitter.submit_workflow import submit_workflow_yaml

await submit_workflow_yaml("example.yaml")
```
To submit a workflow script:
```python
import asyncio
from python_workflow_submitter.submit_workflow import submit_workflow_yaml

asyncio.run(submit_workflow_yaml("example.yaml", visit="ks10000-3"))
```

To submit a generic workflow via a GraphQL mutation:

```python
import asyncio
from python_workflow_submitter.submit_workflow import submit_workflow

asyncio.run(
    submit_workflow(
        "example-template",
        {"png": True, "jpg": False, "jpeg": True, "tif": True, "tiff": False},
        visit=str(os.environ.get("VISIT")),
    )
)
```

To list workflow templates available to run:
```python
import asyncio
from python_workflow_submitter.list_workflows import list_workflows

asyncio.run(list_workflows(limit=5, filter="EXAMPLES"))
```
To list workflows in specific visit with optional filtering:
```python
import asyncio
from python_workflow_submitter.list_workflows import list_workflows_in_visit

asyncio.run(list_workflows_in_visit(limit=5,filter=filter: {
    "creator": "gmg29649",
    "template": "example-template",
  	"workflowStatusFilter": {"succeeded": True}
  }))

```

To list information about a workflow in a visit with a specific name:
```python
import asyncio
from python_workflow_submitter.list_workflows import info_about_workflow

asyncio.run(info_about_workflow(name="conditional-steps-tswxm", visit="ks10000-3"))
```
