Skip to content

Commit

Permalink
Updates to python_script.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
DanPorter committed Aug 14, 2024
1 parent a5a7733 commit 3b67619
Showing 1 changed file with 26 additions and 24 deletions.
50 changes: 26 additions & 24 deletions python_script.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,42 @@ metadata:
name: mmg-test-python
spec:
entrypoint: mmg-test-python
arguments:
parameters:
- name: visitdir
valueFrom:
configMapKeyRef:
name: sessionspaces
key: data_directory
volumes:
- name: session
hostPath:
path: "{{ workflow.parameters.visitdir }}"
type: Directory
templates:
- name: mmg-test-python
inputs:
parameters:
- name: size
value: 2000
- name: memory
value: 20Gi
- name: scanno
value: 1057496
- name: python-code
value: |
print(f"Scan command: {cmd}")
script:
image: ghcr.io/diamondlightsource/magnetic-materials-workflows:0.1.0-rc1
volumeMounts:
- name: session
mountPath: "{{ workflow.parameters.visitdir }}"
command: ["python"]
source: |
import numpy as np
import time
import h5py
with h5py.File('1057496.nxs', 'r') as hdf:
filename = '{{workflow.parameters.visitdir}}/{{inputs.parameters.scanno}}.nxs'
print(filename)

with h5py.File(filename, 'r') as hdf:
dataset = hdf['entry1/scan_command']
cmd = dataset.asstr()[()]
print(f"Scan command: {cmd}")
source: |
import numpy as np
import time
import h5py
print('{{namespace}}')
print('{{workflow.inputs.scanno}}')
print('{{workflow.inputs.message}}')
filename = '/dls/i16/data/2024/{{workflow.metadata.namespace}}/{{workflow.inputs.scanno}}.nxs'
print(filename)
with h5py.File(filename, 'r') as hdf:
dataset = hdf['entry1/scan_command']
cmd = dataset.asstr()[()]
print(f"Scan command: {cmd}")
{{inputs.parameters.python-code}}

0 comments on commit 3b67619

Please sign in to comment.