Skip to content

Commit 69d2149

Browse files
authored
Merge pull request #53 from neuroscout/multiple
Update to handle multiple bundles
2 parents 4e6b667 + 80bbbca commit 69d2149

File tree

3 files changed

+18
-20
lines changed

3 files changed

+18
-20
lines changed

neuroscout_cli/cli.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,29 @@
22
neuroscout
33
44
Usage:
5-
neuroscout run <bundle_id> [-dn -o <out_dir> -i <install_dir> --n-cpus=<n> --work-dir=<dir> --dataset-name=<name>]
6-
neuroscout install <bundle_id> [-dn -i <install_dir>]
5+
neuroscout run <outdir> <bundle_id>... [options]
6+
neuroscout install <bundle_id>... [-n -i <install_dir>]
77
neuroscout ls <bundle_id>
88
neuroscout -h | --help
99
neuroscout --version
1010
1111
Options:
1212
-i <install_dir> Directory to download dataset and bundle [default: .]
13-
-o <out_dir> Output directory [default: bundle_dir]
1413
--work-dir=<dir> Working directory
1514
--n-cpus=<n> Maximum number of threads across all processes [default: 1]
1615
-n, --no-download Dont download dataset (if available locally)
1716
--dataset-name=<name> Manually specify dataset name
1817
-h --help Show this screen
1918
-v, --version Show version
20-
-d, --debug Debug mode
2119
2220
Commands:
2321
run Runs a first level, group level, or full analysis.
2422
install Installs a bundle and/or dataset.
2523
ls Lists the available files in a bundle's dataset.
2624
2725
Examples:
28-
neuroscout run 5xh -n
26+
neuroscout run 5xhaS /out -n
27+
neuroscout run 5xhaS 38fdx /out
2928
3029
Help:
3130
For help using this tool, please open an issue on the Github
@@ -36,20 +35,22 @@
3635

3736
from docopt import docopt
3837
from . import __version__ as VERSION
39-
import logging
4038
import sys
4139

4240
def main():
4341
# CLI entry point
4442
import neuroscout_cli.commands
4543
args = docopt(__doc__, version=VERSION)
4644

47-
if args.get('--debug'):
48-
logging.basicConfig(level=logging.DEBUG)
49-
5045
for (k, v) in args.items():
5146
if hasattr(neuroscout_cli.commands, k) and v:
5247
k = k[0].upper() + k[1:]
5348
command = getattr(neuroscout_cli.commands, k)
54-
command(args).run()
49+
if k in ['Run', 'Install']:
50+
bundles = args.pop('<bundle_id>')
51+
# Loop over bundles
52+
for b in bundles:
53+
print("Running bundle {}".format(b))
54+
args['<bundle_id>'] = b
55+
command(args).run()
5556
sys.exit(0)

neuroscout_cli/commands/install.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def run(self):
9797
return self.bundle_dir.absolute()
9898
else:
9999
raise ValueError(
100-
"Manually specified dastaset directory does not contain",
100+
"Manually specified dataset directory does not contain",
101101
"analysis bundle. Try again, or re-download bundle.")
102102
else:
103103
return self.download_data()

neuroscout_cli/commands/run.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
import shutil
66
from pathlib import Path
77

8+
# Options not to be passed onto fitlins
9+
INVALID = ['--no-download', '--version', '--help', '-i', 'run', '<bundle_id>', '--dataset-name']
10+
811
class Run(Command):
912
''' Command for running neuroscout workflows. '''
1013

@@ -13,12 +16,7 @@ def run(self):
1316
install_command = Install(self.options.copy())
1417
bundle_path = install_command.run()
1518

16-
out_dir = self.options.pop('-o')
17-
if out_dir == "bundle_dir":
18-
out_dir = (install_command.bundle_dir).absolute()
19-
else:
20-
out_dir = Path(out_dir)
21-
19+
out_dir = Path(self.options.pop('<outdir>'))
2220
tmp_out = mkdtemp()
2321

2422
dataset_dir = install_command.dataset_dir.absolute()
@@ -33,8 +31,7 @@ def run(self):
3331
]
3432

3533
# Fitlins invalid keys
36-
invalid = ['--no-download', '--version', '--help', '-i', 'run', '<bundle_id>', '--dataset-name']
37-
for k in invalid:
34+
for k in INVALID:
3835
self.options.pop(k, None)
3936

4037
# Add remaining optional arguments
@@ -51,4 +48,4 @@ def run(self):
5148
# Call fitlins as if CLI
5249
run_fitlins(fitlins_args)
5350
# Copy to out_dir (doing this because of Windows volume)
54-
shutil.copytree(Path(tmp_out) / 'fitlins', out_dir / 'fitlins')
51+
shutil.copytree(Path(tmp_out) / 'fitlins', out_dir / self.bundle_id)

0 commit comments

Comments
 (0)