diff --git a/babs/babs.py b/babs/babs.py index e130d80b..1ba427da 100644 --- a/babs/babs.py +++ b/babs/babs.py @@ -991,6 +991,39 @@ def babs_check_setup(self, input_ds, flag_job_test): if flag_warning_output_ria: print("\nPlease check out the warning for output RIA!") + def babs_update_setup(self, input_ds, container_config_yaml_file): + """ + This is to update setup of jobs run in a BABS project. + + Parameters: + -------------- + input_ds: class `Input_ds` + information of input dataset(s) + container_config_yaml_file: str + Path to an updated container's configuration YAML file. + """ + + babs_proj_config = read_yaml(self.config_path, if_filelock=True) + + # Sanity check: if the user has changed `required_files` section in YAML file: + # if changed, throw out a warning. + # TODO^^ + + # ============================================================== + # Redo: Bootstrap scripts: + # ============================================================== + + # Re-generate `_zip.sh`: ---------------------------------- + # which is a bash script of singularity run + zip + # in folder: `analysis/code` + print("\nRe-generating a bash script for running container and zipping the outputs...") + print("This bash script will be named as `" + container_name + "_zip.sh`") + bash_path = op.join(self.analysis_path, "code", container_name + "_zip.sh") + container.generate_bash_run_bidsapp(bash_path, input_ds, self.type_session) + self.datalad_save(path="code/" + container_name + "_zip.sh", + message="Generate script of running container") + + def babs_submit(self, count=1, df_job_specified=None): """ This function submits jobs and prints out job status. diff --git a/babs/cli.py b/babs/cli.py index cefe2f84..45401eae 100644 --- a/babs/cli.py +++ b/babs/cli.py @@ -79,7 +79,8 @@ def babs_init_cli(): parser.add_argument( '--container_config_yaml_file', '--container-config-yaml-file', help="Path to a YAML file that contains the configurations" - " of how to run the BIDS App container") + " of how to run the BIDS App container", + required=True) parser.add_argument( "--type_session", "--type-session", choices=['single-ses', 'single_ses', 'single-session', 'single_session', @@ -295,6 +296,51 @@ def babs_check_setup_main(): # Call method `babs_check_setup()`: babs_proj.babs_check_setup(input_ds, args.job_test) +def babs_update_setup_cli(): + """ + CLI for: Update setups for job running in a BABS project, + e.g., cluster resources request, script preamble. + """ + + parser = argparse.ArgumentParser( + description="Update setups for running jobs.") + parser.add_argument( + "--project_root", "--project-root", + help="Absolute path to the root of BABS project." + " For example, '/path/to/my_BABS_project/'.", + required=True) + parser.add_argument( + '--container_config_yaml_file', '--container-config-yaml-file', + help="Path to an updated YAML file that contains the configurations" + " of how to run the BIDS App container", + required=True) + + return parser + +def babs_update_setup_main(): + """ + Update setups for job running in a BABS project, + e.g., cluster resources request, script preamble. + + Parameters: + -------------- + project_root: str + Absolute path to the root of BABS project. + container_config_yaml_file: str + Path to an updated container's configuration YAML file. + """ + + # Get arguments: + args = babs_check_setup_cli().parse_args() + project_root = args.project_root + + # Get class `BABS` based on saved `analysis/code/babs_proj_config.yaml`: + babs_proj, input_ds = get_existing_babs_proj(project_root) + + # Call `babs_update_setup()`: + babs_proj.babs_update_setup(input_ds, args.container_config_yaml_file) + + def babs_submit_cli(): """ Submit jobs.