diff --git a/tests/test_lsf_submit.py b/tests/test_lsf_submit.py index 544d2f9..94d79a5 100644 --- a/tests/test_lsf_submit.py +++ b/tests/test_lsf_submit.py @@ -24,6 +24,9 @@ class TestSubmitter(unittest.TestCase): @patch.object( CookieCutter, CookieCutter.get_default_mem_mb.__name__, return_value=1000 ) + @patch.object( + CookieCutter, CookieCutter.get_default_project.__name__, return_value="proj" + ) @patch.object(OSLayer, OSLayer.get_uuid4_string.__name__, return_value="random") def test___several_trivial_getter_methods(self, *mocks): argv = [ @@ -72,7 +75,7 @@ def test___several_trivial_getter_methods(self, *mocks): self.assertEqual( lsf_submit.submit_cmd, "bsub -M {mem} -n 1 -R 'select[mem>{mem}] rusage[mem={mem}] span[hosts=1]' " - "{jobinfo} -q q1 cluster_opt_1 cluster_opt_2 cluster_opt_3 " + "{jobinfo} -q q1 -P proj cluster_opt_1 cluster_opt_2 cluster_opt_3 " "real_jobscript.sh".format(mem=expected_mem, jobinfo=expected_jobinfo_cmd), ) @@ -140,6 +143,9 @@ def test____submit_cmd_and_get_external_job_id___output_stream_has_no_jobid( @patch.object( CookieCutter, CookieCutter.get_default_mem_mb.__name__, return_value=1000 ) + @patch.object( + CookieCutter, CookieCutter.get_default_project.__name__, return_value="proj" + ) @patch.object(OSLayer, OSLayer.get_uuid4_string.__name__, return_value="random") @patch.object(OSLayer, OSLayer.mkdir.__name__) @patch.object(OSLayer, OSLayer.remove_file.__name__) @@ -191,7 +197,7 @@ def test___submit___successfull_submit( expected_mem = "2662" run_process_mock.assert_called_once_with( "bsub -M {mem} -n 1 -R 'select[mem>{mem}] rusage[mem={mem}] span[hosts=1]' " - "{jobinfo} -q q1 cluster_opt_1 cluster_opt_2 cluster_opt_3 " + "{jobinfo} -q q1 -P proj cluster_opt_1 cluster_opt_2 cluster_opt_3 " "real_jobscript.sh".format(mem=expected_mem, jobinfo=expected_jobinfo_cmd) ) print_mock.assert_called_once_with( @@ -204,6 +210,9 @@ def test___submit___successfull_submit( @patch.object( CookieCutter, CookieCutter.get_default_mem_mb.__name__, return_value=1000 ) + @patch.object( + CookieCutter, CookieCutter.get_default_project.__name__, return_value="proj" + ) @patch.object(OSLayer, OSLayer.get_uuid4_string.__name__, return_value="random") @patch.object(OSLayer, OSLayer.mkdir.__name__) @patch.object(OSLayer, OSLayer.remove_file.__name__) @@ -247,7 +256,7 @@ def test___submit___failed_submit_bsub_invocation_error( expected_mem = "2662" run_process_mock.assert_called_once_with( "bsub -M {mem} -n 1 -R 'select[mem>{mem}] rusage[mem={mem}] span[hosts=1]' " - "{jobinfo} -q q1 cluster_opt_1 cluster_opt_2 cluster_opt_3 " + "{jobinfo} -q q1 -P proj cluster_opt_1 cluster_opt_2 cluster_opt_3 " "real_jobscript.sh".format(mem=expected_mem, jobinfo=expected_jobinfo_cmd) ) print_mock.assert_not_called() @@ -335,6 +344,9 @@ def test_rule_specific_params_are_submitted(self, *mocks): @patch.object( CookieCutter, CookieCutter.get_default_mem_mb.__name__, return_value=1000 ) + @patch.object( + CookieCutter, CookieCutter.get_default_project.__name__, return_value="proj" + ) @patch.object(OSLayer, OSLayer.get_uuid4_string.__name__, return_value="random") def test_lsf_mem_unit_is_kb_and_mem_mb_is_converted_accordingly(self, *mocks): argv = [ @@ -373,7 +385,7 @@ def test_lsf_mem_unit_is_kb_and_mem_mb_is_converted_accordingly(self, *mocks): ).format(outlog=expected_outlog, errlog=expected_errlog) expected = ( "bsub -M {mem} -n 1 -R 'select[mem>{mem}] rusage[mem={mem}] span[hosts=1]' " - "{jobinfo} -q q1 cluster_opt_1 cluster_opt_2 cluster_opt_3 " + "{jobinfo} cluster_opt_1 cluster_opt_2 cluster_opt_3 " "-q queue -gpu - -P project " "real_jobscript.sh".format(mem=expected_mem, jobinfo=expected_jobinfo_cmd) ) @@ -383,6 +395,9 @@ def test_lsf_mem_unit_is_kb_and_mem_mb_is_converted_accordingly(self, *mocks): @patch.object( CookieCutter, CookieCutter.get_log_dir.__name__, return_value="logdir" ) + @patch.object( + CookieCutter, CookieCutter.get_default_project.__name__, return_value="proj" + ) @patch.object( CookieCutter, CookieCutter.get_default_mem_mb.__name__, return_value=1000 ) @@ -426,7 +441,7 @@ def test_lsf_mem_unit_is_tb_and_mem_mb_is_converted_and_rounded_up_to_int( ).format(outlog=expected_outlog, errlog=expected_errlog) expected = ( "bsub -M {mem} -n 1 -R 'select[mem>{mem}] rusage[mem={mem}] span[hosts=1]' " - "{jobinfo} -q q1 cluster_opt_1 cluster_opt_2 cluster_opt_3 " + "{jobinfo} cluster_opt_1 cluster_opt_2 cluster_opt_3 " "-q queue -gpu - -P project " "real_jobscript.sh".format(mem=expected_mem, jobinfo=expected_jobinfo_cmd) ) diff --git a/{{cookiecutter.profile_name}}/lsf_submit.py b/{{cookiecutter.profile_name}}/lsf_submit.py index 8771aa3..9b01450 100755 --- a/{{cookiecutter.profile_name}}/lsf_submit.py +++ b/{{cookiecutter.profile_name}}/lsf_submit.py @@ -165,7 +165,7 @@ def jobinfo_cmd(self) -> str: @property def queue(self) -> str: - if re.match(r"-q ", self.rule_specific_params): + if re.search(r"-q ", self.rule_specific_params): return "" return self.cluster.get("queue", CookieCutter.get_default_queue()) @@ -179,7 +179,7 @@ def rule_specific_params(self) -> str: @property def proj(self) -> str: - if re.match(r"-P ", self.rule_specific_params): + if re.search(r"-P ", self.rule_specific_params): return "" return self.cluster.get("project", CookieCutter.get_default_project())