diff --git a/autosubmit/config/config_common.py b/autosubmit/config/config_common.py index 87046c0a3c3c33a264173ae327ee42c5d1d7b4af..e3d4636bbd66fdc7c0e04f3e0e79db439c59144e 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 7296bc39a35be73fe03fde6e32054debe4b50deb..6f0b96070b90eb91271a8443ea7336391a9d4a67 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 diff --git a/autosubmit/job/job_packages.py b/autosubmit/job/job_packages.py index c913d865aa4280030f4ffb3d77ebaaef1956bedb..80c733c93425d7d194b11b6d3f10d274de09ef47 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 bf82cf70291c7d77ea68f8caa124b4f8b0a73666..f36901b94e82c0cc74e106300e59f5dece4e6039 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 34090fb515b03d2362cdfe04e75adee6c7af3e39..893346ab1c13f691f782f0b4d1f57e9402f37745 100644 --- a/autosubmit/platforms/paramiko_platform.py +++ b/autosubmit/platforms/paramiko_platform.py @@ -260,6 +260,10 @@ class ParamikoPlatform(Platform): self._ftpChannel.get(remote_path, file_path) return True except Exception as e: + try: + os.remove(file_path) + except: + pass if str(e) in "Garbage": if not ignore_log: Log.printlog( @@ -416,7 +420,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 @@ -743,11 +747,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/platform.py b/autosubmit/platforms/platform.py index a2af24d6d95b213045c617c64595671b9d19bfad..98e4676cf0cb37e2097080d89c375de63caa2317 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 diff --git a/autosubmit/platforms/slurmplatform.py b/autosubmit/platforms/slurmplatform.py index 9e793923fdbb8f93225b170450f5a74ee2530c10..e03732dfb579e5c41b870866b39bc75b9d0eb1cd 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)