Skip to content

Commit 34cd189

Browse files
committed
Fix template
1 parent 34e298a commit 34cd189

File tree

2 files changed

+5
-24
lines changed

2 files changed

+5
-24
lines changed

src/access_mopper/examples/batch_config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ grid_label: gn
2222
activity_id: CMIP
2323

2424
# Required: Input and output paths
25-
input_folder: /g/data/p73/archive/CMIP7/ACCESS-ESM1-6/spinup/JuneSpinUp-JuneSpinUp-bfaa9c5b
26-
output_folder: /scratch/tm70/rb5533/mopper_output
25+
input_folder: "/g/data/p73/archive/CMIP7/ACCESS-ESM1-6/spinup/JuneSpinUp-JuneSpinUp-bfaa9c5b"
26+
output_folder: "/scratch/tm70/rb5533/mopper_output"
2727

2828

2929
# Optional: File patterns for each variable

src/access_mopper/templates/cmor_job_script.j2

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,20 @@ export CMOR_TRACKER_DB="{{ db_path }}"
1717
export VARIABLE="{{ variable }}"
1818

1919
# Run the CMORisation for this variable
20-
python -c "
21-
import os
22-
import glob
23-
import sys
20+
python -c "import os, glob, sys, json
2421
from pathlib import Path
25-
26-
# Add any necessary paths
2722
sys.path.insert(0, '{{ package_path }}')
28-
2923
from access_mopper import ACCESS_ESM_CMORiser
3024
from access_mopper.tracking import TaskTracker
3125
32-
# Configuration
33-
config = {{ config|tojson }}
26+
config = json.loads('{{ config | tojson | replace(\"'\", \"\\'\") }}')
3427
variable = os.environ['VARIABLE']
3528
db_path = os.environ['CMOR_TRACKER_DB']
3629
37-
# Find input files
3830
input_folder = config['input_folder']
3931
pattern = config.get('file_patterns', {}).get(variable)
4032
if not pattern:
4133
raise ValueError(f'No pattern found for variable {variable}')
42-
4334
full_pattern = str(Path(input_folder) / pattern)
4435
input_files = glob.glob(full_pattern)
4536
if not input_files:
@@ -48,18 +39,14 @@ if not input_files:
4839
print(f'Processing {variable} with {len(input_files)} files')
4940
5041
try:
51-
# Initialize tracking
5242
exp = config['experiment_id']
5343
tracker = TaskTracker(Path(db_path))
5444
tracker.add_task(variable, exp)
55-
5645
if tracker.is_done(variable, exp):
5746
print(f'Skipped: {variable} (already done)')
5847
sys.exit(0)
59-
6048
tracker.mark_running(variable, exp)
6149
62-
# Create CMORiser with Dask parallelization
6350
cmoriser = ACCESS_ESM_CMORiser(
6451
input_paths=input_files,
6552
compound_name=variable,
@@ -71,19 +58,13 @@ try:
7158
output_path=config['output_folder'],
7259
drs_root=config.get('drs_root'),
7360
)
74-
75-
# Run the CMORisation
7661
cmoriser.run()
7762
tracker.mark_done(variable, exp)
78-
7963
print(f'Completed: {variable}')
80-
8164
except Exception as e:
8265
print(f'Error processing {variable}: {e}', file=sys.stderr)
8366
try:
84-
exp = config['experiment_id']
85-
tracker = TaskTracker(Path(db_path))
8667
tracker.mark_failed(variable, exp, str(e))
8768
except:
8869
pass
89-
sys.exit(1)
70+
sys.exit(1)"

0 commit comments

Comments
 (0)