From c4d243f08e3c3f747420b7f37398374ae30758e1 Mon Sep 17 00:00:00 2001 From: Andy Worth Date: Wed, 23 Mar 2022 14:17:00 -0400 Subject: [PATCH 1/8] return 0 on seccess --- manifest.json | 8 ++++---- run.py | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest.json b/manifest.json index 64916a5..6324aa7 100644 --- a/manifest.json +++ b/manifest.json @@ -292,7 +292,7 @@ }, "verbose": { "default": "", - "description": "increases log verbosity for each occurence, debug level is -vvv", + "description": "increases log verbosity for each occurrence, debug level is -vvv", "enum": [ "", "v", @@ -308,13 +308,13 @@ } }, "custom": { - "docker-image": "flywheel/bids-fmriprep:1.2.8_20.2.6", + "docker-image": "flywheel/bids-fmriprep:1.2.9_20.2.6", "flywheel": { "suite": "BIDS Apps" }, "gear-builder": { "category": "analysis", - "image": "flywheel/bids-fmriprep:1.2.8_20.2.6" + "image": "flywheel/bids-fmriprep:1.2.9_20.2.6" }, "license": { "dependencies": [ @@ -388,5 +388,5 @@ "name": "bids-fmriprep", "source": "https://github.com/nipreps/fmriprep", "url": "https://github.com/flywheel-apps/bids-fmriprep/blob/master/README.md", - "version": "1.2.8_20.2.6" + "version": "1.2.9_20.2.6" } diff --git a/run.py b/run.py index c46e4cc..87d61af 100755 --- a/run.py +++ b/run.py @@ -313,11 +313,16 @@ def main(gtk_context): ) except RuntimeError as exc: - return_code = 1 + if num_tries == 2: + return_code = 1 errors.append(exc) log.critical(exc) log.exception("Unable to execute command.") + os.system("echo ") + os.system("echo Disk Information on Failure") + os.system("df -h") + # Save time, etc. resources used in metadata on analysis if Path("time_output.txt").exists(): # some tests won't have this file metadata = { @@ -342,11 +347,6 @@ def main(gtk_context): # Cleanup, move all results to the output directory - if return_code != 0: - os.system("echo ") - os.system("echo Disk Information on Failure") - os.system("df -h") - # Remove all fsaverage* directories if not config.get("gear-keep-fsaverage"): path = output_analysis_id_dir / "freesurfer" From 9db668b5b2f7aff0612d55a1a28a7d95fe4b8fa2 Mon Sep 17 00:00:00 2001 From: Andy Worth Date: Mon, 28 Mar 2022 17:16:11 -0400 Subject: [PATCH 2/8] not re-run if first succeed, add gear-log-to-file --- manifest.json | 16 +++++-- run.py | 9 ++++ tests/data/gear_tests/log_to_file.zip | Bin 0 -> 1908 bytes tests/integration_tests/test_log_to_file.py | 46 ++++++++++++++++++++ tests/unit_tests/test_generate_command.py | 30 +++++++++++++ 5 files changed, 98 insertions(+), 3 deletions(-) create mode 100644 tests/data/gear_tests/log_to_file.zip create mode 100644 tests/integration_tests/test_log_to_file.py diff --git a/manifest.json b/manifest.json index 6324aa7..e289a5a 100644 --- a/manifest.json +++ b/manifest.json @@ -112,6 +112,11 @@ "description": "Text from license file generated during FreeSurfer registration. *Entries should be space separated*", "type": "string" }, + "gear-continuous-output": { + "default": true, + "description": "Continuously ", + "type": "boolean" + }, "gear-dry-run": { "default": false, "description": "Do everything except actually executing the command line", @@ -146,6 +151,11 @@ ], "type": "string" }, + "gear-log-to-file": { + "default": false, + "description": "Instead of logging in real time, save log output of fMRIPrep to the file output/log.txt", + "type": "boolean" + }, "gear-run-bids-validation": { "default": false, "description": "Gear will run BIDS validation before running fMRIPrep and print out all warnings and errors. fMRIPrep runs a version of the bids validator so having the gear run it is not necessary, but might be informative. If validation fails and gear-abort-on-bids-error is true, fMRIPrep will NOT be run.", @@ -308,13 +318,13 @@ } }, "custom": { - "docker-image": "flywheel/bids-fmriprep:1.2.9_20.2.6", + "docker-image": "flywheel/bids-fmriprep:1.2.10_20.2.6", "flywheel": { "suite": "BIDS Apps" }, "gear-builder": { "category": "analysis", - "image": "flywheel/bids-fmriprep:1.2.9_20.2.6" + "image": "flywheel/bids-fmriprep:1.2.10_20.2.6" }, "license": { "dependencies": [ @@ -388,5 +398,5 @@ "name": "bids-fmriprep", "source": "https://github.com/nipreps/fmriprep", "url": "https://github.com/flywheel-apps/bids-fmriprep/blob/master/README.md", - "version": "1.2.9_20.2.6" + "version": "1.2.10_20.2.6" } diff --git a/run.py b/run.py index 87d61af..95e7055 100755 --- a/run.py +++ b/run.py @@ -85,6 +85,7 @@ def generate_command(config, work_dir, output_analysis_id_dir, errors, warnings) skip_pattern = re.compile("gear-|lsf-|singularity-") command_parameters = {} + log_to_file = False for key, val in config.items(): # these arguments are passed directly to the command as is @@ -93,6 +94,10 @@ def generate_command(config, work_dir, output_analysis_id_dir, errors, warnings) for baa in bids_app_args: cmd.append(baa) + elif key == "gear-log-to-file": + if val: + log_to_file = True + elif not skip_pattern.match(key): command_parameters[key] = val @@ -103,6 +108,9 @@ def generate_command(config, work_dir, output_analysis_id_dir, errors, warnings) cmd = build_command_list(cmd, command_parameters) + if log_to_file: + cmd = cmd + [">", "output/log.txt"] + for ii, cc in enumerate(cmd): if cc.startswith("--verbose"): # handle a 'count' argparse argument where manifest gives @@ -311,6 +319,7 @@ def main(gtk_context): shell=True, cont_output=True, ) + break except RuntimeError as exc: if num_tries == 2: diff --git a/tests/data/gear_tests/log_to_file.zip b/tests/data/gear_tests/log_to_file.zip new file mode 100644 index 0000000000000000000000000000000000000000..8cbf6e5867173a02661527f23cad3c8d8e9b6fd8 GIT binary patch literal 1908 zcmWIWW@Zs#U|`^2;B2c2IqQA#&Ln0AhB__=25z8ea(-S~X1ZQhaeiKHn0Nkd3xR#l z!zHZrA8$|oz9mwJi{-^K?v#Aj#DFIrvu5!(E_t)c_1|y4r8g$#TJ4i~R`YpY{;~b< z-M*Z>aK-n-&E*&0zbpSfZSj{i4x$H+>RU`M>)<+AsJ`l(*A?lhU*@e{c3Lw>ZSz$b zwVJ&%&V6F-_?k8EZ{b?OTUNVHW~J9RaNLx9^fg9tb7i~dE<34D+X|W74taU}yu9Ke z$J5fa0UsK!_0(5nPpZ(~c}U>1X>Sl`OTe9KoqIe-AH)S$elimKefxV0k8fiB%gR5Z z$+3Pyo8lw#O<%~|3A=Hu<+kCwgFo$dWI9Pj@3q~Q$NbYIUgw#so;v@P{WYd@Pq&9; zt~o5^yGgqCRDNon&5oA3`Bl%SO5c=Q!+mvrYZkv~!!GyPv6*}7EM!jYD}P{hV^+J? zE-882p6`7T0X1jaOmrc{7lvp^S>HQp3QqARq+Th4QI?6t!5bLE9NIv-3)MlxAXIv>pPgmwAlA4`A-!7ewvZXB~|j& z{OPwI%qb0#zjpo6fw_*CC;qxrsVMBH_IHU$672#4ULBFk?ex43eO9)Z973leZ zZ$Vn?^DRdzX0Ezs{mO*@plLWqs`s)4e#7-|UjF=iUE5z!@Xg0BOLGElt+_2;Emd2o zl3}z!;zQ*m^W~!6$#-uDF{rNmS@-0niKBzBu~|=WWN=c3N^W~d{gyWpXV`dr7A84# z{X8aW)8|!m;9(t(oLEZ6R+J+&^e&2b&rNwK?#Z?J$T`f~2X5Ric zid z`#?SLbbwnEC?y~?v9Q3?1xyR}lmXMUq){EH1>!cebb|06_H=?UA_i^*a;ib-$Mh;F v_8|ZiJjdYrv7`l5f1sxZm@!Klf8#L(BW(nDvw~xY16aR)VPs&)0tX`ioq?~{ literal 0 HcmV?d00001 diff --git a/tests/integration_tests/test_log_to_file.py b/tests/integration_tests/test_log_to_file.py new file mode 100644 index 0000000..b3df103 --- /dev/null +++ b/tests/integration_tests/test_log_to_file.py @@ -0,0 +1,46 @@ +import json +import logging +import os +from pathlib import Path +from unittest import TestCase + +import flywheel_gear_toolkit +from flywheel_gear_toolkit.utils.zip_tools import unzip_archive + +import run + +log = logging.getLogger(__name__) + + +def test_log_to_file_works( + tmp_path, caplog, install_gear, search_caplog_contains, search_caplog +): + + caplog.set_level(logging.DEBUG) + + user_json = Path(Path.home() / ".config/flywheel/user.json") + if not user_json.exists(): + TestCase.skipTest("", f"No API key available in {str(user_json)}") + with open(user_json) as json_file: + data = json.load(json_file) + if "ga" not in data["key"]: + TestCase.skipTest("", "Not logged in to ga.") + + FWV0 = Path.cwd() + + install_gear("log_to_file.zip") + + with flywheel_gear_toolkit.GearToolkitContext(input_args=[]) as gtk_context: + + status = run.main(gtk_context) + + assert status == 1 + log_path = Path("/flywheel/v0/output/log.txt") + assert log_path.exists() + found_it = False + with open(log_path, "r") as ff: + for line in ff: + if "Running fMRIPREP" in line: + found_it = True + break + assert found_it diff --git a/tests/unit_tests/test_generate_command.py b/tests/unit_tests/test_generate_command.py index 5743708..bac4712 100644 --- a/tests/unit_tests/test_generate_command.py +++ b/tests/unit_tests/test_generate_command.py @@ -55,3 +55,33 @@ def test_generate_command_missing_config_works( assert "lsf-ram" not in command assert "singularity-debug" not in command assert search_stdout_contains(captured, "command is:", "out/###") + + +def test_generate_command_log_to_file_works( + capfd, print_captured, search_stdout_contains +): + + with flywheel_gear_toolkit.GearToolkitContext(input_args=[]) as gtk_context: + gtk_context.init_logging("info") + gtk_context.log_config() + log = gtk_context.log + + config = { + "gear-abort-on-bids-error": False, + "gear-log-level": "INFO", + "gear-log-to-file": True, + "gear-run-bids-validation": False, + "gear-save-intermediate-output": False, + "gear-dry-run": True, + "gear-keep-output": False, + } + + errors = [] + warnings = [] + + command = generate_command( + config, Path("work"), Path("out/###"), errors, warnings + ) + + assert command[-2] == ">" + assert command[-1] == "output/log.txt" From d4617bc1a1d681dff2b00b11895add4c5050f1fe Mon Sep 17 00:00:00 2001 From: Andy Worth Date: Tue, 29 Mar 2022 16:32:09 -0400 Subject: [PATCH 3/8] fix log-to-file --- manifest.json | 8 +++--- run.py | 14 ++++----- tests/data/gear_tests/log_to_file.zip | Bin 1908 -> 9298 bytes tests/integration_tests/test_log_to_file.py | 3 +- tests/unit_tests/test_generate_command.py | 30 -------------------- 5 files changed, 12 insertions(+), 43 deletions(-) diff --git a/manifest.json b/manifest.json index e289a5a..461df60 100644 --- a/manifest.json +++ b/manifest.json @@ -153,7 +153,7 @@ }, "gear-log-to-file": { "default": false, - "description": "Instead of logging in real time, save log output of fMRIPrep to the file output/log.txt", + "description": "Instead of logging in real time, save log output of fMRIPrep to the file output/log#.txt (where # is 1 or 2 depending on how many times fMRIPrep was run.", "type": "boolean" }, "gear-run-bids-validation": { @@ -318,13 +318,13 @@ } }, "custom": { - "docker-image": "flywheel/bids-fmriprep:1.2.10_20.2.6", + "docker-image": "flywheel/bids-fmriprep:1.2.13_20.2.6", "flywheel": { "suite": "BIDS Apps" }, "gear-builder": { "category": "analysis", - "image": "flywheel/bids-fmriprep:1.2.10_20.2.6" + "image": "flywheel/bids-fmriprep:1.2.13_20.2.6" }, "license": { "dependencies": [ @@ -398,5 +398,5 @@ "name": "bids-fmriprep", "source": "https://github.com/nipreps/fmriprep", "url": "https://github.com/flywheel-apps/bids-fmriprep/blob/master/README.md", - "version": "1.2.10_20.2.6" + "version": "1.2.13_20.2.6" } diff --git a/run.py b/run.py index 95e7055..69329cd 100755 --- a/run.py +++ b/run.py @@ -94,10 +94,6 @@ def generate_command(config, work_dir, output_analysis_id_dir, errors, warnings) for baa in bids_app_args: cmd.append(baa) - elif key == "gear-log-to-file": - if val: - log_to_file = True - elif not skip_pattern.match(key): command_parameters[key] = val @@ -108,9 +104,6 @@ def generate_command(config, work_dir, output_analysis_id_dir, errors, warnings) cmd = build_command_list(cmd, command_parameters) - if log_to_file: - cmd = cmd + [">", "output/log.txt"] - for ii, cc in enumerate(cmd): if cc.startswith("--verbose"): # handle a 'count' argparse argument where manifest gives @@ -311,6 +304,12 @@ def main(gtk_context): # show what's in the current working directory just before running os.system("tree -alh .") + if config.get("gear-log-to-file"): + if command[-1] == "output/log1.txt": + command[-1] = "output/log2.txt" + else: + command = command + [">", "output/log1.txt"] + # This is what it is all about exec_command( command, @@ -427,7 +426,6 @@ def main(gtk_context): err_type = str(type(err)).split("'")[1] msg += f" {err_type}: {str(err)}\n" log.info(msg) - return_code = 1 if num_tries == 1: log.info("Happily, fMRIPrep worked on the first try.") diff --git a/tests/data/gear_tests/log_to_file.zip b/tests/data/gear_tests/log_to_file.zip index 8cbf6e5867173a02661527f23cad3c8d8e9b6fd8..db00c5027e116a8bc398b55b39489d2e5c12d078 100644 GIT binary patch delta 7581 zcmb7}1ymf_wuT#b2@)hgkU((P1SdEI_u%f*cn1nXfCMKr?(P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WDEm5kwiY7=x$`mJASe z3BqG%P32)^5@Cj!F!_eOIY?Si!3adTDuDG=DHwuyYZV+p)CUDS5M`j~45CUEy+v5r TfDQn)+BLhPgD~JaGrdco( diff --git a/tests/integration_tests/test_log_to_file.py b/tests/integration_tests/test_log_to_file.py index b3df103..33a9a25 100644 --- a/tests/integration_tests/test_log_to_file.py +++ b/tests/integration_tests/test_log_to_file.py @@ -35,7 +35,7 @@ def test_log_to_file_works( status = run.main(gtk_context) assert status == 1 - log_path = Path("/flywheel/v0/output/log.txt") + log_path = Path("/flywheel/v0/output/log2.txt") assert log_path.exists() found_it = False with open(log_path, "r") as ff: @@ -44,3 +44,4 @@ def test_log_to_file_works( found_it = True break assert found_it + assert 0 diff --git a/tests/unit_tests/test_generate_command.py b/tests/unit_tests/test_generate_command.py index bac4712..5743708 100644 --- a/tests/unit_tests/test_generate_command.py +++ b/tests/unit_tests/test_generate_command.py @@ -55,33 +55,3 @@ def test_generate_command_missing_config_works( assert "lsf-ram" not in command assert "singularity-debug" not in command assert search_stdout_contains(captured, "command is:", "out/###") - - -def test_generate_command_log_to_file_works( - capfd, print_captured, search_stdout_contains -): - - with flywheel_gear_toolkit.GearToolkitContext(input_args=[]) as gtk_context: - gtk_context.init_logging("info") - gtk_context.log_config() - log = gtk_context.log - - config = { - "gear-abort-on-bids-error": False, - "gear-log-level": "INFO", - "gear-log-to-file": True, - "gear-run-bids-validation": False, - "gear-save-intermediate-output": False, - "gear-dry-run": True, - "gear-keep-output": False, - } - - errors = [] - warnings = [] - - command = generate_command( - config, Path("work"), Path("out/###"), errors, warnings - ) - - assert command[-2] == ">" - assert command[-1] == "output/log.txt" From cb616ba71b8c2ff5f1cb47c12e3e7eb606791d42 Mon Sep 17 00:00:00 2001 From: Andy Worth Date: Tue, 5 Apr 2022 08:58:15 -0400 Subject: [PATCH 4/8] fix test --- tests/integration_tests/test_log_to_file.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/integration_tests/test_log_to_file.py b/tests/integration_tests/test_log_to_file.py index 33a9a25..8740c35 100644 --- a/tests/integration_tests/test_log_to_file.py +++ b/tests/integration_tests/test_log_to_file.py @@ -44,4 +44,3 @@ def test_log_to_file_works( found_it = True break assert found_it - assert 0 From 2ae104087fd5e8fa6a27e0982033c010babb7122 Mon Sep 17 00:00:00 2001 From: Andy Worth Date: Tue, 5 Apr 2022 15:46:23 -0400 Subject: [PATCH 5/8] rm unused config --- manifest.json | 5 ----- 1 file changed, 5 deletions(-) diff --git a/manifest.json b/manifest.json index 461df60..b30121b 100644 --- a/manifest.json +++ b/manifest.json @@ -112,11 +112,6 @@ "description": "Text from license file generated during FreeSurfer registration. *Entries should be space separated*", "type": "string" }, - "gear-continuous-output": { - "default": true, - "description": "Continuously ", - "type": "boolean" - }, "gear-dry-run": { "default": false, "description": "Do everything except actually executing the command line", From bc5887631a7f9e5f5a4699802eb1b674e14ffe6a Mon Sep 17 00:00:00 2001 From: Jesus Avila Date: Mon, 25 Apr 2022 11:17:24 -0700 Subject: [PATCH 6/8] instantiate gtk_context after hpc checks --- manifest.json | 6 +++--- run.py | 25 ++++++++++++------------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/manifest.json b/manifest.json index b30121b..558562a 100644 --- a/manifest.json +++ b/manifest.json @@ -313,13 +313,13 @@ } }, "custom": { - "docker-image": "flywheel/bids-fmriprep:1.2.13_20.2.6", + "docker-image": "flywheel/bids-fmriprep:1.2.14_20.2.6-rc0", "flywheel": { "suite": "BIDS Apps" }, "gear-builder": { "category": "analysis", - "image": "flywheel/bids-fmriprep:1.2.13_20.2.6" + "image": "flywheel/bids-fmriprep:1.2.14_20.2.6-rc0" }, "license": { "dependencies": [ @@ -393,5 +393,5 @@ "name": "bids-fmriprep", "source": "https://github.com/nipreps/fmriprep", "url": "https://github.com/flywheel-apps/bids-fmriprep/blob/master/README.md", - "version": "1.2.13_20.2.6" + "version": "1.2.14_20.2.6-rc0" } diff --git a/run.py b/run.py index 69329cd..96abc83 100755 --- a/run.py +++ b/run.py @@ -444,21 +444,20 @@ def main(gtk_context): if __name__ == "__main__": - with flywheel_gear_toolkit.GearToolkitContext() as gtk_context: - - # make sure /flywheel/v0 is writable, use a scratch directory if not - scratch_dir = run_in_tmp_dir(gtk_context.config["gear-writable-dir"]) + # make sure /flywheel/v0 is writable, use a scratch directory if not + scratch_dir = run_in_tmp_dir(gtk_context.config["gear-writable-dir"]) + with flywheel_gear_toolkit.GearToolkitContext() as gtk_context: return_code = main(gtk_context) - # clean up (might be necessary when running in a shared computing environment) - if scratch_dir: - log.debug("Removing scratch directory") - for thing in scratch_dir.glob("*"): - if thing.is_symlink(): - thing.unlink() # don't remove anything links point to - log.debug("unlinked %s", thing.name) - shutil.rmtree(scratch_dir) - log.debug("Removed %s", scratch_dir) + # clean up (might be necessary when running in a shared computing environment) + if scratch_dir: + log.debug("Removing scratch directory") + for thing in scratch_dir.glob("*"): + if thing.is_symlink(): + thing.unlink() # don't remove anything links point to + log.debug("unlinked %s", thing.name) + shutil.rmtree(scratch_dir) + log.debug("Removed %s", scratch_dir) sys.exit(return_code) From 12aad1676f32ed32414a90692e07b52732cc57dc Mon Sep 17 00:00:00 2001 From: Jesus Avila Date: Mon, 25 Apr 2022 11:47:52 -0700 Subject: [PATCH 7/8] instantiate gtk_context twice --- manifest.json | 6 +++--- run.py | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/manifest.json b/manifest.json index 558562a..0721cb2 100644 --- a/manifest.json +++ b/manifest.json @@ -313,13 +313,13 @@ } }, "custom": { - "docker-image": "flywheel/bids-fmriprep:1.2.14_20.2.6-rc0", + "docker-image": "flywheel/bids-fmriprep:1.2.14_20.2.6-rc1", "flywheel": { "suite": "BIDS Apps" }, "gear-builder": { "category": "analysis", - "image": "flywheel/bids-fmriprep:1.2.14_20.2.6-rc0" + "image": "flywheel/bids-fmriprep:1.2.14_20.2.6-rc1" }, "license": { "dependencies": [ @@ -393,5 +393,5 @@ "name": "bids-fmriprep", "source": "https://github.com/nipreps/fmriprep", "url": "https://github.com/flywheel-apps/bids-fmriprep/blob/master/README.md", - "version": "1.2.14_20.2.6-rc0" + "version": "1.2.14_20.2.6-rc1" } diff --git a/run.py b/run.py index 96abc83..e7267f1 100755 --- a/run.py +++ b/run.py @@ -445,8 +445,11 @@ def main(gtk_context): if __name__ == "__main__": # make sure /flywheel/v0 is writable, use a scratch directory if not - scratch_dir = run_in_tmp_dir(gtk_context.config["gear-writable-dir"]) + with flywheel_gear_toolkit.GearToolkitContext() as gtk_context: + scratch_dir = run_in_tmp_dir(gtk_context.config["gear-writable-dir"]) + # Has to be instantiated twice here, since parent directories might have + # changed with flywheel_gear_toolkit.GearToolkitContext() as gtk_context: return_code = main(gtk_context) From cb533ce7f20aff50ce2632e231908a394ee548e1 Mon Sep 17 00:00:00 2001 From: Andy Worth Date: Wed, 11 May 2022 15:08:01 -0400 Subject: [PATCH 8/8] rm "rc1" from version --- manifest.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/manifest.json b/manifest.json index 0721cb2..33e466b 100644 --- a/manifest.json +++ b/manifest.json @@ -313,13 +313,13 @@ } }, "custom": { - "docker-image": "flywheel/bids-fmriprep:1.2.14_20.2.6-rc1", + "docker-image": "flywheel/bids-fmriprep:1.2.14_20.2.6", "flywheel": { "suite": "BIDS Apps" }, "gear-builder": { "category": "analysis", - "image": "flywheel/bids-fmriprep:1.2.14_20.2.6-rc1" + "image": "flywheel/bids-fmriprep:1.2.14_20.2.6" }, "license": { "dependencies": [ @@ -393,5 +393,5 @@ "name": "bids-fmriprep", "source": "https://github.com/nipreps/fmriprep", "url": "https://github.com/flywheel-apps/bids-fmriprep/blob/master/README.md", - "version": "1.2.14_20.2.6-rc1" + "version": "1.2.14_20.2.6" }