Skip to content

Commit 08fc331

Browse files
committed
docs(copier): updates copier template and improves example
1 parent 35537bf commit 08fc331

9 files changed

Lines changed: 181 additions & 862 deletions

File tree

scripts/makecopiercorrect.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ do
1111

1212
sed -i 's/python-interface-to-workflows/{{repo_name}}/g' "$file"
1313
sed -i 's/DiamondLightSource/{{github_org}}/g' "$file"
14+
sed -i 's/python_interface_to_workflows/{{project_name}}/g' "$file"
1415

1516
sed -i '1i{% raw %}' "$file"
1617
echo '{% endraw %}' >> "$file"
1718

1819
sed -i \
1920
-e 's/{{repo_name}}/{% endraw %}{{repo_name}}{% raw %}/g' \
2021
-e 's/{{github_org}}/{% endraw %}{{github_org}}{% raw %}/g' \
22+
-e 's/{{project_name}}/{% endraw %}{{project_name}}{% raw %}/g' \
2123
"$file"
2224

2325
mv "$file" "$file.jinja"
@@ -30,12 +32,14 @@ do
3032
sed -i 's/python-interface-to-workflows/{{repo_name}}/g' "$file"
3133
sed -i 's/DiamondLightSource/{{github_org}}/g' "$file"
3234

35+
sed -i 's/python_interface_to_workflows/{{project_name}}/g' "$file"
3336
sed -i '1i{% raw %}' "$file"
3437
echo '{% endraw %}' >> "$file"
3538

3639
sed -i \
3740
-e 's/{{repo_name}}/{% endraw %}{{repo_name}}{% raw %}/g' \
3841
-e 's/{{github_org}}/{% endraw %}{{github_org}}{% raw %}/g' \
42+
-e 's/{{project_name}}/{% endraw %}{{project_name}}{% raw %}/g' \
3943
"$file"
4044

4145

@@ -48,13 +52,14 @@ do
4852

4953
sed -i 's/python-interface-to-workflows/{{repo_name}}/g' "$file"
5054
sed -i 's/DiamondLightSource/{{github_org}}/g' "$file"
51-
55+
sed -i 's/python_interface_to_workflows/{{project_name}}/g' "$file"
5256
sed -i '1i{% raw %}' "$file"
5357
echo '{% endraw %}' >> "$file"
5458

5559
sed -i \
5660
-e 's/{{repo_name}}/{% endraw %}{{repo_name}}{% raw %}/g' \
5761
-e 's/{{github_org}}/{% endraw %}{{github_org}}{% raw %}/g' \
62+
-e 's/{{project_name}}/{% endraw %}{{project_name}}{% raw %}/g' \
5863
"$file"
5964

6065
mv "$file" "$file.jinja"

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

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ metadata:
1313
workflows.diamond.ac.uk/science-group-examples: 'true'
1414
spec:
1515
entrypoint: workflowentry
16+
podSpecPatch: '{"containers": [{"name": "main", "resources": {"limits": {"cpu":
17+
"1", "memory": "1Gi",}, "requests": {"cpu": "1", "memory":
18+
"1Gi",}}}]}'
1619
templates:
1720
- name: workflowentry
1821
dag:
1922
tasks:
20-
- name: install
21-
template: install-dependencies
2223
- name: params
2324
template: generate-parameters
2425
arguments:
@@ -34,7 +35,7 @@ spec:
3435
- name: tiff
3536
value: 'True'
3637
- name: create-image
37-
depends: install && params
38+
depends: params
3839
template: create-image
3940
withParam: '{{tasks.params.outputs.parameters.out-parameters}}'
4041
arguments:
@@ -54,22 +55,6 @@ spec:
5455
parameters:
5556
- name: paths
5657
value: '{{tasks.create-image.outputs.parameters.out-paths}}'
57-
- name: install-dependencies
58-
script:
59-
image: python:3.10
60-
source: |-
61-
import os
62-
import sys
63-
sys.path.append(os.getcwd())
64-
import subprocess
65-
print('creating venv')
66-
subprocess.check_call(['python', '-m', 'venv', '/tmp/venv'])
67-
subprocess.check_call(['/tmp/venv/bin/pip', 'install', 'pillow', 'h5py', 'numpy', 'hera'])
68-
command:
69-
- python
70-
volumeMounts:
71-
- name: tmpdir
72-
mountPath: /tmp
7358
- name: generate-parameters
7459
inputs:
7560
parameters:
@@ -84,7 +69,7 @@ spec:
8469
valueFrom:
8570
path: /tmp/parameters.json
8671
script:
87-
image: python:3.10
72+
image: ghcr.io/diamondlightsource/{% endraw %}{{repo_name}}{% raw %}-image
8873
source: |-
8974
import os
9075
import sys
@@ -129,7 +114,7 @@ spec:
129114
valueFrom:
130115
path: /tmp/{{inputs.parameters.extension}}-path.json
131116
script:
132-
image: python:3.10
117+
image: ghcr.io/diamondlightsource/{% endraw %}{{repo_name}}{% raw %}-image
133118
source: |-
134119
import os
135120
import sys
@@ -163,7 +148,7 @@ spec:
163148
with open(f'/tmp/{extension}-path.json', 'w') as f:
164149
json.dump(path, f)
165150
command:
166-
- /tmp/venv/bin/python
151+
- python
167152
volumeMounts:
168153
- name: tmpdir
169154
mountPath: /tmp
@@ -178,7 +163,7 @@ spec:
178163
archive:
179164
none: {}
180165
script:
181-
image: python:3.10
166+
image: ghcr.io/diamondlightsource/{% endraw %}{{repo_name}}{% raw %}-image
182167
source: |-
183168
import os
184169
import sys
@@ -200,10 +185,22 @@ spec:
200185
f.create_dataset(f'image_{i}', data=arr, dtype=arr.dtype)
201186
print('done')
202187
command:
203-
- /tmp/venv/bin/python
188+
- python
204189
volumeMounts:
205190
- name: tmpdir
206191
mountPath: /tmp
192+
tolerations:
193+
- effect: NoSchedule
194+
key: nvidia.com/gpu
195+
operator: Exists
196+
- effect: NoSchedule
197+
key: nodetype
198+
operator: Equal
199+
value: gpu
200+
- effect: NoSchedule
201+
key: nodegroup
202+
operator: Equal
203+
value: workflows
207204
volumeClaimTemplates:
208205
- metadata:
209206
name: tmpdir

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

Lines changed: 0 additions & 198 deletions
This file was deleted.

0 commit comments

Comments
 (0)