Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #5

Merged
merged 2 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ lint = [
milex-configuration = "milex_scheduler.apps.milex_configuration:main"
milex-submit = "milex_scheduler.apps.milex_submit:main"
milex-schedule = "milex_scheduler.apps.milex_schedule:main"
milex-initialize = "milex_scheduler.apps.milex_initialize:main"
27 changes: 27 additions & 0 deletions src/milex_scheduler/apps/milex_initialize.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import argparse
from ..save_load_jobs import save_bundle


def parse_args():
# fmt: off
parser = argparse.ArgumentParser(description='Initialize a bundle of jobs to run with SLURM')
parser.add_argument('bundle', help='Name of the job bundle (JSON file containing multiple jobs/scripts to be scheduled).')
# fmt: on
args = parser.parse_known_args()
return args


def cli():
import sys
import json

args, script_args = parse_args()
if script_args is None:
sys.exit(1)
print(json.dumps(vars(args), indent=4))
sys.exit(0)


def main():
args = parse_args()
save_bundle({}, args.bundle)
5 changes: 5 additions & 0 deletions tests/unit/test_save_load_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@ def test_save_bundle_no_script_error(mock_load_config):
save_bundle(bundle, bundle_name)


def test_save_bundle_initialize(mock_load_config):
bundle_name = "mock"
save_bundle({}, bundle_name)


def test_save_job_with_same_name_in_append_mode(mock_load_config):
# Check that new bundle is created with an index appended
mock_jobA = {"name": "JobA", "script": "run-joba"}
Expand Down