@@ -17,29 +17,20 @@ export CMOR_TRACKER_DB="{{ db_path }}"
1717export 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
2421from pathlib import Path
25-
26- # Add any necessary paths
2722sys.path.insert(0, '{{ package_path }}')
28-
2923from access_mopper import ACCESS_ESM_CMORiser
3024from access_mopper.tracking import TaskTracker
3125
32- # Configuration
33- config = {{ config|tojson }}
26+ config = json.loads('{{ config | tojson | replace(\" '\" , \"\\ '\" ) }}')
3427variable = os.environ['VARIABLE']
3528db_path = os.environ['CMOR_TRACKER_DB']
3629
37- # Find input files
3830input_folder = config['input_folder']
3931pattern = config.get('file_patterns', {}).get(variable)
4032if not pattern:
4133 raise ValueError(f'No pattern found for variable {variable}')
42-
4334full_pattern = str(Path(input_folder) / pattern)
4435input_files = glob.glob(full_pattern)
4536if not input_files:
@@ -48,18 +39,14 @@ if not input_files:
4839print(f'Processing {variable} with {len(input_files)} files')
4940
5041try:
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,
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-
8164except 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