-
Notifications
You must be signed in to change notification settings - Fork 18
Add --extra-inputs to containers-add
#190
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
Changes from all commits
51f949a
574c9d6
14ef7f8
9793587
90428eb
972f16e
25c768f
be5f29a
a64ff9b
35cbd48
d35dd4e
9be3434
fa15b81
4f0ecec
9234493
1f118ec
9c124f2
3dc7366
88b52c7
d193298
a8d0b91
43c37ee
f13ffd5
738f1a1
af1034b
64ea256
00888ce
d46b443
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| ### 🚀 Enhancements and New Features | ||
|
|
||
| - Add `--extra-inputs` to `containers-add`. Fixes [#189](https://github.com/datalad/datalad-container/issues/189) via [PR #190](https://github.com/datalad/datalad-container/pull/190) (by [@nobodyinperson](https://github.com/nobodyinperson)) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ | |
| from datalad.distribution.dataset import datasetmethod | ||
| from datalad.distribution.dataset import require_dataset | ||
| from datalad.interface.base import eval_results | ||
| from datalad.utils import ensure_iter | ||
|
|
||
| from datalad.interface.results import get_status_dict | ||
| from datalad.core.local.run import ( | ||
|
|
@@ -114,6 +115,7 @@ def __call__(cmd, container_name=None, dataset=None, | |
| img=image_path, | ||
| cmd=cmd, | ||
| img_dspath=image_dspath, | ||
| img_dirpath=op.dirname(image_path) or ".", | ||
| ) | ||
| cmd = callspec.format(**cmd_kwargs) | ||
| except KeyError as exc: | ||
|
|
@@ -131,14 +133,36 @@ def __call__(cmd, container_name=None, dataset=None, | |
| # just prepend and pray | ||
| cmd = container['path'] + ' ' + cmd | ||
|
|
||
| extra_inputs = [] | ||
| for extra_input in ensure_iter(container.get("extra-input",[]), set): | ||
| try: | ||
| xi_kwargs = dict( | ||
| img_dspath=image_dspath, | ||
| img_dirpath=op.dirname(image_path) or ".", | ||
| ) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. codeclimate btw warned about code duplication here. I think it is ok, although indeed duplicates with cmd_kwargs definition above so we could have some |
||
| extra_inputs.append(extra_input.format(**xi_kwargs)) | ||
| except KeyError as exc: | ||
| yield get_status_dict( | ||
| 'run', | ||
| ds=ds, | ||
| status='error', | ||
| message=( | ||
| 'Unrecognized extra_input placeholder: %s. ' | ||
| 'See containers-add for information on known ones: %s', | ||
| exc, | ||
| ", ".join(xi_kwargs))) | ||
| return | ||
|
|
||
| lgr.debug("extra_inputs = %r", extra_inputs) | ||
|
|
||
| with patch.dict('os.environ', | ||
| {CONTAINER_NAME_ENVVAR: container['name']}): | ||
| # fire! | ||
| for r in run_command( | ||
| cmd=cmd, | ||
| dataset=dataset or (ds if ds.path == pwd else None), | ||
| inputs=inputs, | ||
| extra_inputs=[image_path], | ||
| extra_inputs=[image_path] + extra_inputs, | ||
| outputs=outputs, | ||
| message=message, | ||
| expand=expand, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
feel welcome to expand here on how/when to use this feature, e.g. close to your use case.