Dev Genius

Coding, Tutorials, News, UX, UI and much more related to development

Follow publication

Argo Workflow: DAG

DaeGon Kim
Dev Genius
Published in
3 min readDec 24, 2024

In a previous article, we described steps that compose a set of workflow templates into a sequential execution by grouping them. Here, we will take a look at DAG (Directed Acyclic Graph), a more general execution of the set where the order of workflow template executions is specified by dependencies.

We will reuse the working example in the steps article. We extend it such that the extracted text will be translated into other languages.

Here is the workflow template that we will use.

---
apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
name: translate-ai
spec:
templates:
- name: pil-image-checker
inputs:
parameters:
- name: filename
value: "demo_image.jpg"
artifacts:
- name: inputfile
path: "/tmp/{{inputs.parameters.filename}}"
s3:
key: "input/{{inputs.parameters.filename}}"
outputs:
parameters:
- name: inputfile
valueFrom:
default: "demo_image"
path: "/tmp/inputname"
script:
image: [container-repo]/translation-ai:latest
command: [bash]
source: |
python3 verify_image_extension.py -i "/tmp/{{inputs.parameters.filename}}"
echo "{{inputs.parameters.filename}}" | cut -f1 -d"." > /tmp/inputname
- name: ocr-florence2
inputs:
parameters:
- name: filename
value: "demo_image.jpg"
artifacts:
- name: inputfile
path: "/tmp/{{inputs.parameters.filename}}"
s3:
key: "input/{{inputs.parameters.filename}}"
outputs:
artifacts:
- name: output-json
path: "/tmp/ocr-output.json"
- name: output-txt
path: "/tmp/ocr-output.txt"
script:
image: [container-repo]/translation-ai:latest
command: [bash]
source: |
python3 ocr_florence2.py -i "/tmp/{{inputs.parameters.filename}}" -o "/tmp/ocr-output"
- name: translate-text
inputs:
parameters:
- name: inputname
value: "demo_image"
- name: translator
value: "google"
- name: target-language
value: "fr"
artifacts:
- name: inputfile
path: "/tmp/input.txt"
outputs:
artifacts:
- name: output_txt
path: "/tmp/output.txt"
s3:
key: "output/{{inputs.parameters.inputname}}-{{inputs.parameters.translator}}-{{inputs.parameters.target-language}}.txt.tgz"
script:
image: [container-repo]/translation-ai:latest
command: [bash]
source: |…

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

No responses yet

Write a response