-
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 #26 from jhlegarreta/AddOSFDataFetcher
ENH: Add data fetcher
- Loading branch information
Showing
9 changed files
with
686 additions
and
12 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
import argparse | ||
from pathlib import Path | ||
|
||
from tractolearn.tractoio.dataset_fetch import Dataset, retrieve_dataset | ||
|
||
|
||
def _build_arg_parser(): | ||
|
||
parser = argparse.ArgumentParser( | ||
description="Fetch tractolearn dataset", | ||
formatter_class=argparse.ArgumentDefaultsHelpFormatter, | ||
) | ||
parser.add_argument( | ||
"dastaset_name", | ||
type=Dataset.argparse, | ||
choices=list(Dataset), | ||
help="Dataset name", | ||
) | ||
parser.add_argument( | ||
"out_path", | ||
type=Path, | ||
help="Output path", | ||
) | ||
|
||
return parser | ||
|
||
|
||
def main(): | ||
|
||
# Parse arguments | ||
parser = _build_arg_parser() | ||
args = parser.parse_args() | ||
|
||
_ = retrieve_dataset(Dataset(args.dastaset_name).name, args.out_path) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Empty file.
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,47 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
import os | ||
import tempfile | ||
from os import listdir | ||
from os.path import isfile, join | ||
|
||
|
||
def test_help_option(script_runner): | ||
|
||
ret = script_runner.run( | ||
"fetch_data.py", "--help" | ||
) | ||
assert ret.success | ||
|
||
|
||
def test_execution(script_runner): | ||
|
||
# Test the lightest datasets | ||
with tempfile.TemporaryDirectory() as tmp_dir: | ||
|
||
os.chdir(os.path.expanduser(tmp_dir)) | ||
|
||
ret = script_runner.run( | ||
"fetch_data.py", | ||
"contrastive_autoencoder_weights", | ||
tmp_dir) | ||
|
||
assert ret.success | ||
|
||
files = [f for f in listdir(tmp_dir) if isfile(join(tmp_dir, f))] | ||
assert len(files) == 1 | ||
|
||
with tempfile.TemporaryDirectory() as tmp_dir: | ||
|
||
os.chdir(os.path.expanduser(tmp_dir)) | ||
|
||
ret = script_runner.run( | ||
"fetch_data.py", | ||
"mni2009cnonlinsymm_anat", | ||
tmp_dir) | ||
|
||
assert ret.success | ||
|
||
files = [f for f in listdir(tmp_dir) if isfile(join(tmp_dir, f))] | ||
assert len(files) == 1 |
Oops, something went wrong.