Skip to content

Commit 30821fd

Browse files
committed
feat(copier): updates copier template and generator copy correctly
1 parent 5418037 commit 30821fd

13 files changed

Lines changed: 39 additions & 29 deletions

File tree

scripts/lintyaml.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
cd src/python_interface_to_workflows/templates
3-
for file in *
3+
for file in *.yaml;
44
do
55
argo lint "$file" --offline
66
SUCCESSFULLINT=$?

scripts/makecopiercorrect.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,36 @@ cp ../templates/*example*.txt "../../copier_template/src/{{ project_name }}/temp
77
for file in "../../copier_template/src/{{ project_name }}/workflow_definitions"/*
88
do
99
[[ $file == *.jinja ]] && continue
10+
1011
sed -i 's/python-interface-to-workflows/{{repo_name}}/g' "$file"
1112
sed -i 's/DiamondLightSource/{{github_org}}/g' "$file"
13+
14+
sed -i '1i{% raw %}' "$file"
15+
echo '{% endraw %}' >> "$file"
16+
17+
sed -i \
18+
-e 's/{{repo_name}}/{% endraw %}{{repo_name}}{% raw %}/g' \
19+
-e 's/{{github_org}}/{% endraw %}{{github_org}}{% raw %}/g' \
20+
"$file"
21+
1222
mv "$file" "$file.jinja"
1323
done
1424

1525
for file in "../../copier_template/src/{{ project_name }}/templates"/*
1626
do
1727
[[ $file == *.jinja ]] && continue
28+
1829
sed -i 's/python-interface-to-workflows/{{repo_name}}/g' "$file"
1930
sed -i 's/DiamondLightSource/{{github_org}}/g' "$file"
31+
32+
sed -i '1i{% raw %}' "$file"
33+
echo '{% endraw %}' >> "$file"
34+
35+
sed -i \
36+
-e 's/{{repo_name}}/{% endraw %}{{repo_name}}{% raw %}/g' \
37+
-e 's/{{github_org}}/{% endraw %}{{github_org}}{% raw %}/g' \
38+
"$file"
39+
2040
mv "$file" "$file.jinja"
2141
done
2242
git add "../../copier_template/src/{{ project_name }}/workflow_definitions"/*

scripts/runthefiles.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ do
55
uv run "$file"
66
done
77
mv *.yaml ../templates/
8+
mv *.txt ../templates/
89
git add -u ../templates/

src/copier_template/pyproject.toml.jinja

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ reportMissingImports = false # Ignore missing stubs in imported modules
6868
reportMissingTypeStubs = "none"
6969
reportMissingModuleSource="warning"
7070
reportInvalidTypeForm="warning"
71-
reportMissingImports="warning"
7271
reportUndefinedVariable="warning"
7372
reportAbstractUsage="warning"
7473
reportArgumentType="warning"

src/copier_template/scripts/lintyaml.sh.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
cd src/{{project_name}}/templates
3-
for file in *
3+
for file in *.yaml;
44
do
55
argo lint "$file" --offline
66
SUCCESSFULLINT=$?
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#!/bin/bash
2-
cd src/{{project_name}}/workflow_definitions
2+
cd src/python_interface_to_workflows/workflow_definitions
33
for file in *
44
do
55
uv run "$file"
66
done
77
mv *.yaml ../templates/
8+
mv *.txt ../templates/
89
git add -u ../templates/

src/copier_template/src/{{ project_name }}/auth/keycloak_checker.py.jinja

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,15 @@ from keycloak.pkce_utils import generate_code_challenge, generate_code_verifier
77
from {{project_name}}.auth.open_auth_url import open_auth_url
88

99

10-
def set_token_env_variable(staging: bool) -> str:
11-
match staging:
12-
case True:
13-
keycloak_openid = KeycloakOpenID(
14-
server_url="https://identity-test.diamond.ac.uk/",
15-
client_id="workflows-ui-dev",
16-
realm_name="dls",
17-
client_secret_key="",
18-
pool_maxsize=1,
19-
)
20-
port = 5173
21-
case False:
22-
keycloak_openid = KeycloakOpenID(
23-
client_id="workflows-dashboard",
10+
def set_token_env_variable() -> str:
11+
keycloak_openid = KeycloakOpenID(
12+
client_id="workflows-cli",
2413
server_url="https://identity.diamond.ac.uk/",
2514
realm_name="dls",
2615
client_secret_key="",
2716
pool_maxsize=1,
2817
)
29-
port = 8000
18+
port = 8000
3019
code_verifier = generate_code_verifier()
3120
code_challenge, code_challenge_method = generate_code_challenge(code_verifier)
3221
auth_url = keycloak_openid.auth_url(

src/copier_template/src/{{ project_name }}/auth/open_auth_url.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ def do_GET(self):
3131

3232
def open_auth_url(auth_url: str, port: int) -> bool:
3333
dotenv.load_dotenv(dotenv_path="src/.env", override=True)
34-
expiry_str: str = os.environ.get("EXPIRY") # pyright: ignore
35-
print(f"expiry_str: {expiry_str}", str(time.time()))
34+
expiry_str: str = os.environ.get("EXPIRY").strip("'") # pyright: ignore
3635
if (expiry_str == "" or int(expiry_str)) <= float(time.time()):
3736
httpd = _ReusingHTTPServer(("localhost", port), CallbackHandler)
3837
webbrowser.open(auth_url)
@@ -49,5 +48,4 @@ def open_auth_url(auth_url: str, port: int) -> bool:
4948
httpd.server_close()
5049
return True
5150
else:
52-
print("using refresh token")
5351
return False

src/copier_template/src/{{ project_name }}/templates/example.txt.jinja

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{% raw %}
12
apiVersion: argoproj.io/v1alpha1
23
kind: Workflow
34
metadata:
@@ -7,7 +8,7 @@ metadata:
78
Replicates the functionality of
89
example.yaml
910
workflows.argoproj.io/title: example remade via hera
10-
workflows.diamond.ac.uk/repository: https://github.com/{{github_org}}/{{repo_name}}
11+
workflows.diamond.ac.uk/repository: https://github.com/{% endraw %}{{github_org}}{% raw %}/{% endraw %}{{repo_name}}{% raw %}
1112
labels:
1213
workflows.diamond.ac.uk/science-group-examples: 'true'
1314
spec:
@@ -212,3 +213,4 @@ spec:
212213
resources:
213214
requests:
214215
storage: 1Gi
216+
{% endraw %}

src/copier_template/src/{{ project_name }}/workflow_definitions/create_example_template.py.jinja

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{% raw %}
12
from hera.workflows import (
23
DAG,
34
Artifact,
@@ -153,7 +154,7 @@ with Workflow(
153154
"workflows.argoproj.io/title": "example remade via hera",
154155
"workflows.argoproj.io/description": """Replicates the functionality of
155156
example.yaml""",
156-
"workflows.diamond.ac.uk/repository": "https://github.com/{{github_org}}/{{repo_name}}",
157+
"workflows.diamond.ac.uk/repository": "https://github.com/{% endraw %}{{github_org}}{% raw %}/{% endraw %}{{repo_name}}{% raw %}",
157158
},
158159
volumes=Volume(name="tmpdir", mount_path="/tmp/", size="1Gi"),
159160
) as w:
@@ -178,5 +179,6 @@ example.yaml""",
178179
[install, params] >> makeimages >> makehdf5 # pyright: ignore
179180

180181

181-
with open("_example.yaml", "w") as div:
182+
with open("example.txt", "w") as div:
182183
div.write(w.to_yaml()) # pyright: ignore[reportUnknownMemberType]
184+
{% endraw %}

0 commit comments

Comments
 (0)