def process_run(args: Namespace) -> None: """ CLI command for running a study. :param [Namespace] `args`: parsed CLI arguments """ print(banner_small) filepath: str = verify_filepath(args.specification) variables_dict: str = parse_override_vars(args.variables) samples_file: Optional[str] = None if args.samples_file: samples_file = verify_filepath(args.samples_file) # pgen checks if args.pargs and not args.pgen_file: raise ValueError( "Cannot use the 'pargs' parameter without specifying a 'pgen'!") if args.pgen_file: verify_filepath(args.pgen_file) study: MerlinStudy = MerlinStudy( filepath, override_vars=variables_dict, samples_file=samples_file, dry_run=args.dry, no_errors=args.no_errors, pgen_file=args.pgen_file, pargs=args.pargs, ) router.run_task_server(study, args.run_mode)
def setUp(self): self.tmpdir = tempfile.mkdtemp() self.merlin_spec_filepath = os.path.join(self.tmpdir, "basic_ensemble.yaml") with open(self.merlin_spec_filepath, "w+") as _file: _file.write(MERLIN_SPEC) self.study = MerlinStudy(self.merlin_spec_filepath)
def test_column_label_conflict(self): """ If there is a common key between Maestro's global.parameters and Merlin's sample/column_labels, an error should be raised. """ merlin_spec_conflict: str = os.path.join( self.tmpdir, "basic_ensemble_conflict.yaml") with open(merlin_spec_conflict, "w+") as _file: _file.write(MERLIN_SPEC_CONFLICT) # for some reason flake8 doesn't believe variables instantiated inside the try/with context are assigned with pytest.raises(ValueError): study_conflict: MerlinStudy = MerlinStudy(merlin_spec_conflict) assert not study_conflict, "study_conflict completed construction without raising a ValueError."
def test_no_env(self): """ A MerlinStudy should be able to support a MerlinSpec that does not contain the optional `env` section. """ merlin_spec_no_env_filepath = os.path.join( self.tmpdir, "basic_ensemble_no_env.yaml") with open(merlin_spec_no_env_filepath, "w+") as _file: _file.write(MERLIN_SPEC_NO_ENV) try: study_no_env = MerlinStudy(merlin_spec_no_env_filepath) except Exception as e: assert False
def test_column_label_conflict(self): """ If there is a common key between Maestro's global.parameters and Merlin's sample/column_labels, an error should be raised. """ merlin_spec_conflict = os.path.join(self.tmpdir, "basic_ensemble_conflict.yaml") with open(merlin_spec_conflict, "w+") as _file: _file.write(MERLIN_SPEC_CONFLICT) try: study_conflict = MerlinStudy(merlin_spec_conflict) except ValueError: pass else: assert False
def test_no_env(self): """ A MerlinStudy should be able to support a MerlinSpec that does not contain the optional `env` section. """ merlin_spec_no_env_filepath: str = os.path.join( self.tmpdir, "basic_ensemble_no_env.yaml") with open(merlin_spec_no_env_filepath, "w+") as _file: _file.write(MERLIN_SPEC_NO_ENV) try: study_no_env: MerlinStudy = MerlinStudy( merlin_spec_no_env_filepath) bad_type_err: str = f"study_no_env failed construction, is type {type(study_no_env)}." assert isinstance(study_no_env, MerlinStudy), bad_type_err except Exception as e: assert False, f"Encountered unexpected exception, {e}, for viable MerlinSpec without optional 'env' section."
def process_run(args): """ CLI command for running a study. :param `args`: parsed CLI arguments """ print(banner_small) filepath = verify_filepath(args.specification) variables_dict = parse_override_vars(args.variables) samples_file = None if args.samples_file: samples_file = verify_filepath(args.samples_file) study = MerlinStudy( filepath, override_vars=variables_dict, samples_file=samples_file, dry_run=args.dry, no_errors=args.no_errors, ) router.run_task_server(study, args.run_mode)
def process_restart(args): """ CLI command for restarting a study. :param `args`: parsed CLI arguments """ print(banner_small) restart_dir = verify_dirpath(args.restart_dir) filepath = os.path.join(args.restart_dir, "merlin_info", "*.expanded.yaml") possible_specs = glob.glob(filepath) if len(possible_specs) == 0: raise ValueError( f"'{filepath}' does not match any provenance spec file to restart from." ) elif len(possible_specs) > 1: raise ValueError( f"'{filepath}' matches more than one provenance spec file to restart from." ) filepath = verify_filepath(possible_specs[0]) LOG.info(f"Restarting workflow at '{restart_dir}'") study = MerlinStudy(filepath, restart_dir=restart_dir) router.run_task_server(study, args.run_mode)