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

[ENH] implement babs-update-setup #59

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
33 changes: 33 additions & 0 deletions babs/babs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<containerName>_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.
Expand Down
48 changes: 47 additions & 1 deletion babs/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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.
Expand Down