From ce887aa93325f50131bf1209baf4093a05f227d3 Mon Sep 17 00:00:00 2001 From: Bouwe Andela Date: Wed, 20 Dec 2023 16:10:04 +0100 Subject: [PATCH] Move code into function in batch job generation script (#3491) --- esmvaltool/utils/batch-jobs/generate.py | 30 ++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/esmvaltool/utils/batch-jobs/generate.py b/esmvaltool/utils/batch-jobs/generate.py index 960ddd3e86..afba37906f 100644 --- a/esmvaltool/utils/batch-jobs/generate.py +++ b/esmvaltool/utils/batch-jobs/generate.py @@ -24,6 +24,7 @@ """ import os import subprocess +import textwrap from pathlib import Path import esmvaltool @@ -230,28 +231,27 @@ 'recipe_pcrglobwb', ] -DEFAULT_DASK_FILE = f""" -cluster: - type: dask_jobqueue.SLURMCluster - queue: compute - account: {account} - cores: 128 - memory: 256GiB - processes: 32 - interface: ib0 - local_directory: /scratch/{os.getlogin()[0]}/{os.getlogin()}/dask-tmp - n_workers: 32 - walltime: '8:00:00' -""" - def generate_submit(): """Generate and submit scripts.""" print("It is recommended that you run the following recipes with the " "configuration in dask.yml in ~/.esmvaltool/dask.yml:") + default_dask_config_file = textwrap.dedent(f""" + cluster: + type: dask_jobqueue.SLURMCluster + queue: compute + account: {account} + cores: 128 + memory: 256GiB + processes: 32 + interface: ib0 + local_directory: /scratch/{os.getlogin()[0]}/{os.getlogin()}/dask-tmp + n_workers: 32 + walltime: '8:00:00' + """) for recipe in DISTRIBUTED_RECIPES: print(f"- {recipe}.yml") - Path('dask.yml').write_text(DEFAULT_DASK_FILE, encoding='utf-8') + Path('dask.yml').write_text(default_dask_config_file, encoding='utf-8') home = os.path.expanduser('~') # Fill the list with the names of the recipes to be excluded