diff --git a/autosubmit/autosubmit.py b/autosubmit/autosubmit.py index 16c71d182b33d9bebfefe0b6399c121b26b3de60..4e7e8a1066220cb8608d2f87a8ebce8b04a1666b 100644 --- a/autosubmit/autosubmit.py +++ b/autosubmit/autosubmit.py @@ -86,7 +86,7 @@ from typing import List import autosubmit.history.utils as HUtils import autosubmit.helpers.autosubmit_helper as AutosubmitHelper import autosubmit.statistics.utils as StatisticsUtils -from autosubmit.helpers.utils import proccess_id, terminate_child_process +from autosubmit.helpers.utils import proccess_id, terminate_child_process, check_jobs_file_exists from contextlib import suppress @@ -1485,6 +1485,7 @@ class Autosubmit: signal.signal(signal.SIGINT, signal_handler) as_conf = AutosubmitConfig(expid, BasicConfig, YAMLParserFactory()) as_conf.check_conf_files(True) + project_type = as_conf.get_project_type() safetysleeptime = as_conf.get_safetysleeptime() Log.debug("The Experiment name is: {0}", expid) @@ -2501,6 +2502,12 @@ class Autosubmit: save_2 = False wrapper_errors = {} any_job_submitted = False + # Check section jobs + if not only_wrappers and not inspect : + jobs_section = set([job.section for job in job_list.get_ready()]) + for section in jobs_section: + if check_jobs_file_exists(as_conf, section): + raise AutosubmitCritical(f"Job {self.name} does not have a correct template// template not found", 7014) try: for platform in platforms_to_test: packager = JobPackager(as_conf, platform, job_list, hold=hold) diff --git a/autosubmit/helpers/utils.py b/autosubmit/helpers/utils.py index b712d1f2cfd61ee6830041f2f7fa93767126e68b..7ccca9cf89a6e60664192a305baa158ce13aa0f5 100644 --- a/autosubmit/helpers/utils.py +++ b/autosubmit/helpers/utils.py @@ -1,4 +1,3 @@ -import collections import subprocess import os import pwd @@ -11,6 +10,30 @@ from autosubmit.notifications.notifier import Notifier from autosubmitconfigparser.config.basicconfig import BasicConfig from log.log import AutosubmitCritical, Log + +def check_jobs_file_exists(as_conf, current_section_name=None): + if str(as_conf.experiment_data.get("PROJECT", {}).get("PROJECT_TYPE", "none")).lower() != "none": + templates_dir = f"{as_conf.experiment_data.get('ROOTDIR','')}/proj/{as_conf.experiment_data.get('PROJECT', {}).get('PROJECT_DESTINATION', '')}" + if not os.path.exists(templates_dir): + raise AutosubmitCritical(f"Templates directory {templates_dir} does not exist", 7011) + + # List of files that doesn't exist. + missing_files = "" + # Check if all files in jobs_data exist or only current section + if current_section_name: + jobs_data = [as_conf.jobs_data.get(current_section_name, {})] + else: + jobs_data = as_conf.jobs_data.values() + for data in jobs_data: + if "SCRIPT" not in data: + if "FILE" in data: + if not os.path.exists(f"{templates_dir}/{data['FILE']}"): + missing_files += f"{templates_dir}/{data['FILE']} \n" + else: + Log.result(f"File {templates_dir}/{data['FILE']} exists") + if missing_files: + raise AutosubmitCritical(f"Templates not found:\n{missing_files}", 7011) + def terminate_child_process(expid, platform=None): # get pid of the main process pid = os.getpid() diff --git a/autosubmit/job/job.py b/autosubmit/job/job.py index 9b892d2671da93bcc4b9620a2b8c0cd0b6069029..bad576df257f0f7696f6546510c84029b7fc6b76 100644 --- a/autosubmit/job/job.py +++ b/autosubmit/job/job.py @@ -1995,8 +1995,9 @@ class Job(object): :rtype: str """ self.update_parameters(as_conf, self.parameters) - if self.script and self.file: - Log.warning(f"Custom script for job {self.name} is being used, file contents are ignored.") + if self.script: + if self.file: + Log.warning(f"Custom script for job {self.name} is being used, file contents are ignored.") template = self.script else: try: