This repository has been archived by the owner on Oct 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from flywheel-apps/return-value
Fix Retry on Failure, log to file
- Loading branch information
Showing
4 changed files
with
82 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/log2.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 |