Skip to content

Commit cb20c49

Browse files
committed
feat(pre-commit): enforces yamls are up to date before a commit
1 parent e8d85ea commit cb20c49

6 files changed

Lines changed: 37 additions & 22 deletions

File tree

.pre-commit-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ repos:
1717
types: [python]
1818
require_serial: true
1919

20+
- id: run_files
21+
name: run yaml-making files
22+
language: system
23+
entry: bash runthefiles
24+
types: [python]
25+
pass_filenames: true
26+
require_serial: true
27+
2028
- id: ruff-format
2129
name: format with ruff
2230
language: system

runthefiles

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
cd src/python_interface_to_workflows/workflow_definitions
3+
for file in *
4+
do
5+
uv run "$file"
6+
done
7+
mv *.yaml ../templates/
8+
git add -u
File renamed without changes.

src/python_interface_to_workflows/submit_to_graphql.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ def submit_to_graphql():
1414
mutation = gql("""
1515
mutation SubmitDivision {
1616
submitWorkflowTemplate(
17-
name: "division"
17+
name: "divisionyaml.yaml"
1818
visit: {
1919
proposalCode: "ks",
2020
proposalNumber: 10000,
2121
number: 3
2222
}
23-
parameters: {
24-
numinput: "19",
25-
numdivisor: "10"
26-
}
23+
parameters: {
24+
x: "19",
25+
y: "10"
26+
}
2727
){
2828
name
2929
}
@@ -33,3 +33,6 @@ def submit_to_graphql():
3333
visit = "ks10000-3/c"
3434
name = str(result["submitWorkflowTemplate"]["name"])
3535
print(f"Job '{visit}-{name}' submitted.")
36+
37+
38+
submit_to_graphql()

src/divisionyaml.yaml renamed to src/python_interface_to_workflows/templates/divisionyaml.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
apiVersion: argoproj.io/v1alpha1
22
kind: ClusterWorkflowTemplate
33
metadata:
4-
generateName: hera-division
5-
namespace: https://staging.workflows.diamond.ac.uk/workflows/
4+
name: hera-division
5+
generateName: hera-division-
6+
namespace: ks10000-3
67
annotations:
78
workflows.argoproj.io/description: |-
89
Takes a numerical input and returns the

src/python_interface_to_workflows/create_division_yaml.py renamed to src/python_interface_to_workflows/workflow_definitions/create_division_yaml.py

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
import json
22

3+
from hera.shared import global_config
34
from hera.workflows import (
45
Artifact,
56
Steps,
67
Volume,
78
Workflow,
8-
WorkflowsService,
99
script, # pyright: ignore[reportUnknownVariableType]
1010
)
1111
from hera.workflows import models as m
1212

13+
global_config.host = "https://argo-workflows.staging.workflows.diamond.ac.uk/"
14+
global_config.image = "python:3.10"
15+
global_config.token = "Token"
16+
1317

1418
@script(
1519
volume_mounts=[m.VolumeMount(name="output-dir", mount_path="/output-dir/")],
@@ -29,9 +33,10 @@ def do_devision(x: int, y: int):
2933

3034

3135
with Workflow(
32-
generate_name="hera-division",
36+
generate_name="hera-division-",
3337
entrypoint="divide",
34-
namespace="https://staging.workflows.diamond.ac.uk/workflows/",
38+
namespace="ks10000-3",
39+
name="hera-division",
3540
api_version="argoproj.io/v1alpha1",
3641
kind="ClusterWorkflowTemplate",
3742
labels={"workflows.diamond.ac.uk/science-group-examples": "true"},
@@ -47,17 +52,7 @@ def do_devision(x: int, y: int):
4752
do_devision(name="first", arguments={"x": 2, "y": 5})
4853

4954

50-
with open("src/divisionyaml.yaml", "w") as div:
55+
with open("divisionyaml.yaml", "w") as div:
5156
div.write(w.to_yaml()) # pyright: ignore[reportUnknownMemberType]
5257

53-
sendthis = m.WorkflowSubmitRequest(
54-
namespace="https://staging.workflows.diamond.ac.uk/workflows/",
55-
resource_kind="ClusterWorkflowTemplate",
56-
resource_name="hera-division",
57-
)
58-
a = WorkflowsService(
59-
host="https://staging.workflows.diamond.ac.uk/graphql",
60-
namespace="https://staging.workflows.diamond.ac.uk/workflows/",
61-
token="a",
62-
)
63-
WorkflowsService.submit_workflow(a, req=sendthis)
58+
# w.create()

0 commit comments

Comments
 (0)