Skip to content

Commit

Permalink
Merge pull request #129 from datalad/bf-4
Browse files Browse the repository at this point in the history
Inherit URL and credentials name config in subdatasets
  • Loading branch information
mih committed Sep 30, 2021
2 parents dfd9922 + 10caa71 commit d9129b5
Showing 1 changed file with 27 additions and 10 deletions.
37 changes: 27 additions & 10 deletions datalad_xnat/update.py
Expand Up @@ -97,6 +97,7 @@ def __call__(project=None,
jobs='auto',
dataset=None):


ds = require_dataset(
dataset, check_installed=True, purpose='update')

Expand Down Expand Up @@ -161,6 +162,7 @@ def __call__(project=None,
# go with a single big one
subjects = [None]
from datalad_xnat.parser import parse_xnat
from unittest.mock import patch
for sub in subjects:
try:
# all this tempfile madness is only needed because windows
Expand Down Expand Up @@ -189,16 +191,31 @@ def __call__(project=None,
# corresponds to the header field 'filename' in the csv table
filename = '{filename}'
filenameformat = f"{pathfmt}{filename}"
ds.addurls(
str(addurls_table_fname), '{url}', filenameformat,
ifexists=ifexists,
fast=True if reckless == 'fast'
else False,
save=True,
jobs=jobs,
cfg_proc=None if platform.credential_name == 'anonymous'
else 'xnat_dataset',
result_renderer='default')
# shoehorn essential info into the ENV to make it
# accessible to the config procedure
# TODO maybe alter the config procedure to pull this info
# from a superdataset, if it finds the dataset at hand
# unconfigured.
env_prefix = f'DATALAD_XNAT_{xnat_cfg_name.upper()}'
env = {
'DATALAD_XNAT_DEFAULT__NAME': xnat_cfg_name,
f'{env_prefix}_URL': platform.url,
}
if platform.credential_name != 'anonymous':
env[f'{env_prefix}_CREDENTIAL__NAME'] = \
platform.credential_name
with patch.dict('os.environ', env):
ds.addurls(
str(addurls_table_fname), '{url}', filenameformat,
ifexists=ifexists,
fast=True if reckless == 'fast'
else False,
save=True,
jobs=jobs,
cfg_proc=None
if platform.credential_name == 'anonymous'
else 'xnat_dataset',
result_renderer='default')
finally:
if addurls_table_fname.exists():
addurls_table_fname.unlink()
Expand Down

0 comments on commit d9129b5

Please sign in to comment.