Skip to content

Commit

Permalink
Added job_name to milex-schedule to make it easier to submit jobs wit…
Browse files Browse the repository at this point in the history
…h dependencies
  • Loading branch information
AlexandreAdam committed Sep 11, 2024
1 parent d4f330b commit bbc9731
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/milex_scheduler/apps/milex_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def parse_args():
parser.add_argument('script', help='Name of the script to schedule.')
parser.add_argument('--name', default=None, help='Name of the job bundle (JSON file containing multiple jobs/scripts to be scheduled). '
'If not provided, the script name is used as the bundle name.')
parser.add_argument('--job_name', default=None, help='Name of the job to schedule. If not provided, the script name is used as the job name.')
parser.add_argument('--append', action='store_true', help='Append the job to an existing bundle. '
'If not provided, a new unique bundle is created using current timestamp.')
parser.add_argument('--submit', action='store_true', help='Submit the job immediately after scheduling it.')
Expand Down Expand Up @@ -86,6 +87,7 @@ def parse_args():
def main():
args, script_args = parse_args()
job = {
"name": args.script if args.job_name is None else args.job_name,
"script": args.script,
"script_args": script_args,
"dependencies": args.dependencies,
Expand Down
8 changes: 6 additions & 2 deletions tests/integration/test_milex_job_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def mock_parse_known_args():
Namespace(
script="job_name",
name="bundle_name",
job_name=None,
job=None,
append=False,
submit=False,
Expand Down Expand Up @@ -115,7 +116,7 @@ def test_parse_script_args_success(mock_run):
# )


def test_cli(mock_parse_known_args, mock_run):
def test_schedule_cli(mock_parse_known_args, mock_run):
# Adjust the mock to return a JSON string that matches the expected output from the CLI application
mock_run.return_value = MagicMock(
returncode=0,
Expand All @@ -128,7 +129,9 @@ def test_cli(mock_parse_known_args, mock_run):
assert expected_job_args == {"custom_arg1": "value1", "custom_arg2": "value2"}


def test_main(mock_submit_job, mock_parse_known_args, mock_run, mock_load_config):
def test_schedule_main(
mock_submit_job, mock_parse_known_args, mock_run, mock_load_config
):
# Adjust mock_run to simulate the output from a successful CLI application run
mock_run.return_value = MagicMock(
returncode=0,
Expand All @@ -141,6 +144,7 @@ def test_main(mock_submit_job, mock_parse_known_args, mock_run, mock_load_config
Namespace(
script="job_name",
name="bundle_name",
job_name=None,
job=None,
append=False,
submit=True,
Expand Down

0 comments on commit bbc9731

Please sign in to comment.