diff --git a/autosubmit/job/job_packages.py b/autosubmit/job/job_packages.py index 6fe699275b326bdd639f31e5659ccdb2224d1e9b..4090c6d843ed9f4682b21000c2ba007daa727229 100644 --- a/autosubmit/job/job_packages.py +++ b/autosubmit/job/job_packages.py @@ -18,7 +18,7 @@ # along with Autosubmit. If not, see . - +import json import os import random import time @@ -422,6 +422,26 @@ class JobPackageThread(JobPackageBase): else: self.exclusive = jobs[0].exclusive wr_custom_directives = configuration.experiment_data["WRAPPERS"].get(self.current_wrapper_section,{}).get("CUSTOM_DIRECTIVES",[]) + # parse custom_directives + if type(wr_custom_directives) is list: + wr_custom_directives = json.dumps(wr_custom_directives) + wr_custom_directives = wr_custom_directives.replace("\'", "\"").strip("[]").strip(", ") + if wr_custom_directives == '': + if jobs[0].custom_directives is None: + jobs[0].custom_directives = '' + wr_custom_directives = jobs[0].custom_directives + if type(wr_custom_directives) is list: + wr_custom_directives = json.dumps(wr_custom_directives) + wr_custom_directives = wr_custom_directives.replace("\'", "\"").strip("[]").strip(", ") + if wr_custom_directives != '': + if wr_custom_directives[0] != "\"": + wr_custom_directives = "\""+wr_custom_directives + if wr_custom_directives[-1] != "\"": + wr_custom_directives = wr_custom_directives+"\"" + wr_custom_directives = "[" + wr_custom_directives + "]" + wr_custom_directives = json.loads(wr_custom_directives) + else: + wr_custom_directives = [] if len(str(wr_custom_directives)) > 0: self.custom_directives = wr_custom_directives else: diff --git a/test/unit/test_job_package.py b/test/unit/test_job_package.py index 884c307d872d79900a2c34980edd3ebba613f59a..c1acdf4cacf12e83e6c4bf95ba3ced4208af3dde 100644 --- a/test/unit/test_job_package.py +++ b/test/unit/test_job_package.py @@ -3,28 +3,19 @@ from unittest import TestCase import os from pathlib import Path import inspect -from copy import deepcopy -from mock import Mock,MagicMock, mock_open , call +import tempfile +from mock import MagicMock from mock import patch -from autosubmit.job.job_packages import JobPackageSimple, JobPackageVertical from autosubmit.job.job import Job from autosubmit.job.job_common import Status - -import shutil -import tempfile - -from unittest import TestCase -from mock import MagicMock -from autosubmit.job.job_packager import JobPackager from autosubmit.job.job_list import JobList -from autosubmit.job.job_dict import DicJobs -from autosubmit.job.job_utils import Dependency -from autosubmitconfigparser.config.yamlparser import YAMLParserFactory from autosubmit.job.job_list_persistence import JobListPersistenceDb -from random import randrange -from collections import OrderedDict +from autosubmit.job.job_packages import JobPackageSimple, JobPackageVertical from autosubmitconfigparser.config.configcommon import AutosubmitConfig +from autosubmitconfigparser.config.yamlparser import YAMLParserFactory + + class FakeBasicConfig: def __init__(self): pass @@ -82,6 +73,7 @@ class TestJobPackage(TestCase): self.jobs[0].custom_directives = "dummy_directives" self.jobs[0].processors = "9" self.jobs[0]._processors = "9" + self.jobs[0]._platform = self.platform self.jobs[0].retrials = 0 self.jobs[1].wallclock = "00:00" self.jobs[1].threads = "" @@ -92,6 +84,7 @@ class TestJobPackage(TestCase): self.jobs[1].custom_directives = "dummy_directives2" self.jobs[1].processors = "9" self.jobs[1]._processors = "9" + self.jobs[1]._platform = self.platform self.wrapper_type = options.get('TYPE', 'vertical') @@ -155,7 +148,7 @@ class TestJobPackage(TestCase): self.assertEqual(self.job_package_wrapper._wrapper_data["PARTITION"], "bsc32") self.assertEqual(self.job_package_wrapper._wrapper_data["THREADS"], "30") self.assertEqual(self.job_package_wrapper._wrapper_data["TASKS"], "40") - self.assertEqual(self.job_package_wrapper._wrapper_data["CUSTOM_DIRECTIVES"], "['#SBATCH --mem=1000']") + self.assertEqual(self.job_package_wrapper._wrapper_data["CUSTOM_DIRECTIVES"], ['#SBATCH --mem=1000'])