From 3a8c5cf3d17a06f158e83443f33c0c2941eb4206 Mon Sep 17 00:00:00 2001 From: dbeltran Date: Fri, 21 May 2021 16:26:11 +0200 Subject: [PATCH 1/4] First version is a bit rough code. Gonna test on vdevel --- autosubmit/config/config_common.py | 10 ++++++++++ autosubmit/job/job.py | 6 +++--- autosubmit/job/job_dict.py | 2 +- autosubmit/job/job_packages.py | 1 - autosubmit/platforms/lsfplatform.py | 5 ++++- autosubmit/platforms/paramiko_platform.py | 20 +++++++++++++++----- autosubmit/platforms/slurmplatform.py | 20 ++++++++++++++------ 7 files changed, 47 insertions(+), 17 deletions(-) diff --git a/autosubmit/config/config_common.py b/autosubmit/config/config_common.py index 87046c0a3..e3d4636bb 100644 --- a/autosubmit/config/config_common.py +++ b/autosubmit/config/config_common.py @@ -188,6 +188,16 @@ class AutosubmitConfig(object): """ return self._jobs_parser.get_option(section, 'WALLCLOCK', '') + def get_modules(self, section): + """ + Gets command line for being submitted with + :param section: job type + :type section: str + :return: wallclock time + :rtype: str + """ + return self._jobs_parser.get_option(section, 'MODULES', None) + def get_wchunkinc(self, section): """ Gets the chunk increase to wallclock diff --git a/autosubmit/job/job.py b/autosubmit/job/job.py index 7296bc39a..0ad496e79 100644 --- a/autosubmit/job/job.py +++ b/autosubmit/job/job.py @@ -969,11 +969,11 @@ class Job(object): template += template_file.read() else: if self.type == Type.BASH: - template = 'sleep 5' + template = 'sleep 30' elif self.type == Type.PYTHON: - template = 'time.sleep(5)' + template = 'time.sleep(30)' elif self.type == Type.R: - template = 'Sys.sleep(5)' + template = 'Sys.sleep(30)' else: template = '' except: diff --git a/autosubmit/job/job_dict.py b/autosubmit/job/job_dict.py index ad948e2bb..d56601839 100644 --- a/autosubmit/job/job_dict.py +++ b/autosubmit/job/job_dict.py @@ -333,7 +333,7 @@ class DicJobs: job.file = self.get_option(section, "FILE", None) job.queue = self.get_option(section, "QUEUE", None) job.check = str(self.get_option(section, "CHECK", 'True')).lower() - + job.modules = str(self.get_option(section, "MODULES", None)) job.processors = str(self.get_option(section, "PROCESSORS", 1)) job.threads = str(self.get_option(section, "THREADS", 1)) job.tasks = str(self.get_option(section, "TASKS", '0')) diff --git a/autosubmit/job/job_packages.py b/autosubmit/job/job_packages.py index c913d865a..80c733c93 100644 --- a/autosubmit/job/job_packages.py +++ b/autosubmit/job/job_packages.py @@ -178,7 +178,6 @@ class JobPackageBase(object): dataThread.join() self._common_script = self._create_common_script() if not only_generate: - Log.debug("Sending Files") self._send_files() Log.debug("Submitting") diff --git a/autosubmit/platforms/lsfplatform.py b/autosubmit/platforms/lsfplatform.py index bf82cf702..f36901b94 100644 --- a/autosubmit/platforms/lsfplatform.py +++ b/autosubmit/platforms/lsfplatform.py @@ -88,7 +88,10 @@ class LsfPlatform(ParamikoPlatform): return self._checkjob_cmd + str(job_id) def get_submit_cmd(self, job_script, job): - return self._submit_cmd + job_script + if job.modules == "none" or job.modules == "None" or job.modules is None or job.modules == "": + return self._submit_cmd + job_script + else: + return job.modules + " ; "+self._submit_cmd + job_script @staticmethod def wrapper_header(filename, queue, project, wallclock, num_procs, dependency, directives): diff --git a/autosubmit/platforms/paramiko_platform.py b/autosubmit/platforms/paramiko_platform.py index 34090fb51..bf2003c74 100644 --- a/autosubmit/platforms/paramiko_platform.py +++ b/autosubmit/platforms/paramiko_platform.py @@ -743,11 +743,21 @@ class ParamikoPlatform(Platform): elif job.type == Type.R: executable = 'Rscript' remote_logs = (job.script_name + ".out", job.script_name + ".err") - return 'nohup ' + executable + ' {0} > {1} 2> {2} & echo $!'.format( - os.path.join(self.remote_log_dir, job_script), - os.path.join(self.remote_log_dir, remote_logs[0]), - os.path.join(self.remote_log_dir, remote_logs[1]) - ) + if job.modules == "none" or job.modules == "None" or job.modules is None or job.modules == "": + command = 'nohup ' + executable + ' {0} > {1} 2> {2} & echo $!'.format( + os.path.join(self.remote_log_dir, job_script), + os.path.join(self.remote_log_dir, remote_logs[0]), + os.path.join(self.remote_log_dir, remote_logs[1]) + ) + else: + command = job.modules + ' ; nohup ' + executable + ' {0} > {1} 2> {2} & echo $!'.format( + os.path.join(self.remote_log_dir, job_script), + os.path.join(self.remote_log_dir, remote_logs[0]), + os.path.join(self.remote_log_dir, remote_logs[1]), + + ) + return command + @staticmethod def get_pscall(job_id): diff --git a/autosubmit/platforms/slurmplatform.py b/autosubmit/platforms/slurmplatform.py index 9e793923f..e03732dfb 100644 --- a/autosubmit/platforms/slurmplatform.py +++ b/autosubmit/platforms/slurmplatform.py @@ -341,13 +341,21 @@ class SlurmPlatform(ParamikoPlatform): return [int(element.firstChild.nodeValue) for element in jobs_xml] def get_submit_cmd(self, job_script, job, hold=False): - if not hold: - self._submit_script_file.write( - self._submit_cmd + job_script + "\n") + if job.modules == "none" or job.modules == "None" or job.modules is None or job.modules == "": + if not hold: + self._submit_script_file.write( + self._submit_cmd + job_script + "\n") + else: + self._submit_script_file.write( + self._submit_hold_cmd + job_script + "\n") else: - self._submit_script_file.write( - self._submit_hold_cmd + job_script + "\n") - + if not hold: + self._submit_script_file.write( + job.modules + " ; " + self._submit_cmd + job_script + "\n") + else: + self._submit_script_file.write( + job.modules + " ; " + self._submit_hold_cmd + job_script + "\n") + return job.modules + " ; "+self._submit_cmd + job_script def get_checkjob_cmd(self, job_id): return 'sacct -n -X --jobs {1} -o "State"'.format(self.host, job_id) -- GitLab From aad163ebf01e1e6a28c831b43ad39c86e3d2948b Mon Sep 17 00:00:00 2001 From: dbeltran Date: Tue, 25 May 2021 10:57:59 +0200 Subject: [PATCH 2/4] Bug found on get --- autosubmit/platforms/paramiko_platform.py | 3 ++- autosubmit/platforms/platform.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/autosubmit/platforms/paramiko_platform.py b/autosubmit/platforms/paramiko_platform.py index bf2003c74..26fd44288 100644 --- a/autosubmit/platforms/paramiko_platform.py +++ b/autosubmit/platforms/paramiko_platform.py @@ -260,6 +260,7 @@ class ParamikoPlatform(Platform): self._ftpChannel.get(remote_path, file_path) return True except Exception as e: + os.remove(file_path) if str(e) in "Garbage": if not ignore_log: Log.printlog( @@ -416,7 +417,7 @@ class ParamikoPlatform(Platform): sleep_time = sleep_time + 5 self.send_command(self.get_checkjob_cmd(job_id)) if retries >= 0: - #Log.debug('Successful check job command: {0}', self.get_checkjob_cmd(job_id)) + Log.debug('Successful check job command: {0}', self.get_checkjob_cmd(job_id)) job_status = self.parse_job_output( self.get_ssh_output()).strip("\n") # URi: define status list in HPC Queue Class diff --git a/autosubmit/platforms/platform.py b/autosubmit/platforms/platform.py index a2af24d6d..98e4676cf 100644 --- a/autosubmit/platforms/platform.py +++ b/autosubmit/platforms/platform.py @@ -230,7 +230,7 @@ class Platform(object): else: return False if self.check_file_exists('{0}_COMPLETED'.format(job_name), wrapper_failed=wrapper_failed): - if self.get_file('{0}_COMPLETED'.format(job_name), False, wrapper_failed=wrapper_failed): + if self.get_file('{0}_COMPLETED'.format(job_name), True, wrapper_failed=wrapper_failed): return True else: return False -- GitLab From a305f29542de9055cb984cb123ff8b1fcd2ba4c7 Mon Sep 17 00:00:00 2001 From: dbeltran Date: Tue, 25 May 2021 11:49:01 +0200 Subject: [PATCH 3/4] Bug found on get ftp file --- autosubmit/platforms/paramiko_platform.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/autosubmit/platforms/paramiko_platform.py b/autosubmit/platforms/paramiko_platform.py index 26fd44288..893346ab1 100644 --- a/autosubmit/platforms/paramiko_platform.py +++ b/autosubmit/platforms/paramiko_platform.py @@ -260,7 +260,10 @@ class ParamikoPlatform(Platform): self._ftpChannel.get(remote_path, file_path) return True except Exception as e: - os.remove(file_path) + try: + os.remove(file_path) + except: + pass if str(e) in "Garbage": if not ignore_log: Log.printlog( -- GitLab From 30c2ebbae8571841553a62223405169b6723a7fd Mon Sep 17 00:00:00 2001 From: dbeltran Date: Wed, 26 May 2021 11:44:59 +0200 Subject: [PATCH 4/4] MODULES now is able to use experiment variables --- autosubmit/job/job.py | 15 +++++++++++++++ autosubmit/job/job_list.py | 1 + 2 files changed, 16 insertions(+) diff --git a/autosubmit/job/job.py b/autosubmit/job/job.py index 0ad496e79..6f0b96070 100644 --- a/autosubmit/job/job.py +++ b/autosubmit/job/job.py @@ -135,6 +135,7 @@ class Job(object): self.hold = False self.distance_weight = 0 self.level = 0 + self.modules = "none" def __getstate__(self): odict = self.__dict__ @@ -940,6 +941,20 @@ class Job(object): parameters['NUMMEMBERS'] = len(as_conf.get_member_list()) parameters['WRAPPER'] = as_conf.get_wrapper_type() + if self.modules != "none": + variables = re.findall('%(? 0: + variables = [variable[1:-1] for variable in variables] + for key in variables: + try: + self.modules = re.sub( + '%(? 0: # Found -- GitLab