diff --git a/autosubmit/autosubmit.py b/autosubmit/autosubmit.py index 24439f359ce36c79d55be92003e631b2c667d765..dc4c9fd3a4b7de820712ae3629b6a45935200160 100644 --- a/autosubmit/autosubmit.py +++ b/autosubmit/autosubmit.py @@ -619,13 +619,17 @@ class Autosubmit: else: content = resource_string('autosubmit.config', 'files/' + filename) + # If autosubmitrc [conf] custom_platforms has been set and file exists, replace content + if filename.startswith("platforms") and os.path.isfile(BasicConfig.CUSTOM_PLATFORMS_PATH): + content = open(BasicConfig.CUSTOM_PLATFORMS_PATH, 'r').read() + conf_new_filename = os.path.join(BasicConfig.LOCAL_ROOT_DIR, exp_id, "conf", new_filename) Log.debug(conf_new_filename) open(conf_new_filename, 'w').write(content) Autosubmit._prepare_conf_files(exp_id, hpc, Autosubmit.autosubmit_version, dummy) except (OSError, IOError) as e: - Log.error("Can not create experiment: {0}\nCleaning...".format(e)) - Autosubmit._delete_expid(exp_id) + Log.error("Can not create experiment: {0}\nCleaning...".format(e)) + Autosubmit._delete_expid(exp_id, True) return '' else: try: @@ -640,9 +644,13 @@ class Autosubmit: conf_copy_id = os.path.join(BasicConfig.LOCAL_ROOT_DIR, copy_id, "conf") files = os.listdir(conf_copy_id) for filename in files: - if os.path.isfile(os.path.join(conf_copy_id, filename)): + if os.path.isfile(os.path.join(conf_copy_id, filename)): new_filename = filename.replace(copy_id, exp_id) content = open(os.path.join(conf_copy_id, filename), 'r').read() + # If autosubmitrc [conf] custom_platforms has been set and file exists, replace content + if filename.startswith("platforms") and os.path.isfile(BasicConfig.CUSTOM_PLATFORMS_PATH): + content = open(BasicConfig.CUSTOM_PLATFORMS_PATH, 'r').read() + open(os.path.join(dir_exp_id, "conf", new_filename), 'w').write(content) Autosubmit._prepare_conf_files(exp_id, hpc, Autosubmit.autosubmit_version, dummy) ##### @@ -661,7 +669,7 @@ class Autosubmit: return '' except (OSError, IOError) as e: Log.error("Can not create experiment: {0}\nCleaning...".format(e)) - Autosubmit._delete_expid(exp_id) + Autosubmit._delete_expid(exp_id, True) return '' Log.debug("Creating temporal directory...") diff --git a/autosubmit/config/basicConfig.py b/autosubmit/config/basicConfig.py index 528b66276abff205e20b3dee851247e2faf975ea..c9bec16cc469627406f76573aaac9ac3103138ac 100755 --- a/autosubmit/config/basicConfig.py +++ b/autosubmit/config/basicConfig.py @@ -43,6 +43,7 @@ class BasicConfig: LOCAL_ASLOG_DIR = 'ASLOGS' LOCAL_PROJ_DIR = 'proj' DEFAULT_PLATFORMS_CONF = '' + CUSTOM_PLATFORMS_PATH = '' DEFAULT_JOBS_CONF = '' SMTP_SERVER = '' MAIL_FROM = '' @@ -80,6 +81,8 @@ class BasicConfig: BasicConfig.LOCAL_ROOT_DIR = parser.get('local', 'path') if parser.has_option('conf', 'platforms'): BasicConfig.DEFAULT_PLATFORMS_CONF = parser.get('conf', 'platforms') + if parser.has_option('conf', 'custom_platforms'): + BasicConfig.CUSTOM_PLATFORMS_PATH = parser.get('conf', 'custom_platforms') if parser.has_option('conf', 'jobs'): BasicConfig.DEFAULT_JOBS_CONF = parser.get('conf', 'jobs') if parser.has_option('mail', 'smtp_server'): diff --git a/docs/source/usage/create_exp.rst b/docs/source/usage/create_exp.rst index d0f097ceb89393768bae9f99b88d44d8c5657d58..e7bba1859cb2183642ff69f825da9b95327d052d 100644 --- a/docs/source/usage/create_exp.rst +++ b/docs/source/usage/create_exp.rst @@ -25,6 +25,18 @@ Example: autosubmit expid --HPC ithaca --description "experiment is about..." +If there is an autosubmitrc or .autosubmitrc file in your home directory (cd ~), you can setup a default file from where the contents of platforms_expid.conf should be copied. + +In this autosubmitrc or .autosubmitrc file, include the configuration setting custom_platforms: + +Example: +:: + [conf] + custom_platforms=/home/Earth/user/custom.conf + +Where the specified path should be complete, as something you would get when executing pwd, and also include the filename of your custom platforms content. + + How to create a copy of an experiment ===================================== This option makes a copy of an existing experiment. @@ -42,8 +54,20 @@ Example: autosubmit expid -y cxxx -H ithaca -d "experiment is about..." +If there is an autosubmitrc or .autosubmitrc file in your home directory (cd ~), you can setup a default file from where the contents of platforms_expid.conf should be copied. + +In this autosubmitrc or .autosubmitrc file, include the configuration setting custom_platforms: + +Example: +:: + [conf] + custom_platforms=/home/Earth/user/custom.conf + +Where the specified path should be complete, as something you would get when executing pwd, and also include the filename of your custom platforms content. + .. warning:: You can only copy experiments created with Autosubmit 3.0 or above. + How to create a dummy experiment ================================ This command creates a new experiment with default values, useful for testing: