Skip to content

Commit 2713e25

Browse files
committed
RF: use datalad 0.12 series, stop bothering with thin mode or custom annex version
Leave decision on which version of annex repo to global configuration. Any recent git-annex (but not the one from neurodebian) would immediately use version 7 anyways. "thin" AFAIK does not really do what I thought it would do (no symlinks), so not worth bothering with it.
1 parent 4c13d68 commit 2713e25

File tree

2 files changed

+15
-23
lines changed

2 files changed

+15
-23
lines changed

heudiconv/external/dlad.py

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
lgr = logging.getLogger(__name__)
1212

13-
MIN_VERSION = '0.7'
13+
MIN_VERSION = '0.12.2'
1414

1515

1616
def prepare_datalad(studydir, outdir, sid, session, seqinfo, dicoms, bids):
@@ -34,36 +34,33 @@ def prepare_datalad(studydir, outdir, sid, session, seqinfo, dicoms, bids):
3434
def add_to_datalad(topdir, studydir, msg, bids):
3535
"""Do all necessary preparations (if were not done before) and save
3636
"""
37-
from datalad.api import create
37+
import datalad.api as dl
3838
from datalad.api import Dataset
3939
from datalad.support.annexrepo import AnnexRepo
4040
from datalad.support.external_versions import external_versions
4141
assert external_versions['datalad'] >= MIN_VERSION, (
42-
"Need datalad >= {}".format(MIN_VERSION)) # add to reqs
42+
"Need datalad >= {}".format(MIN_VERSION)) # add to reqs
4343

44-
create_kwargs = {}
45-
if external_versions['datalad'] >= '0.10':
46-
create_kwargs['fake_dates'] = True # fake dates by default
4744

4845
studyrelpath = op.relpath(studydir, topdir)
4946
assert not studyrelpath.startswith(op.pardir) # so we are under
5047
# now we need to test and initiate a DataLad dataset all along the path
5148
curdir_ = topdir
5249
superds = None
53-
subdirs = [''] + studyrelpath.split(op.sep)
50+
subdirs = [''] + [d for d in studyrelpath.split(op.sep) if d != os.curdir]
5451
for isubdir, subdir in enumerate(subdirs):
5552
curdir_ = op.join(curdir_, subdir)
5653
ds = Dataset(curdir_)
5754
if not ds.is_installed():
5855
lgr.info("Initiating %s", ds)
5956
# would require annex > 20161018 for correct operation on annex v6
6057
# need to add .gitattributes first anyways
61-
ds_ = create(curdir_, dataset=superds,
58+
ds_ = dl.create(curdir_, dataset=superds,
6259
force=True,
63-
no_annex=True,
60+
# initiate annex only at the bottom repository
61+
no_annex=isubdir<(len(subdirs)-1),
62+
fake_dates=True,
6463
# shared_access='all',
65-
annex_version=6,
66-
**create_kwargs
6764
)
6865
assert ds == ds_
6966
assert ds.is_installed()
@@ -93,17 +90,13 @@ def add_to_datalad(topdir, studydir, msg, bids):
9390
with open(gitattributes_path, 'wb') as f:
9491
f.write('\n'.join(known_attrs).encode('utf-8'))
9592

96-
# so for mortals it just looks like a regular directory!
97-
if not ds.config.get('annex.thin'):
98-
ds.config.add('annex.thin', 'true', where='local')
99-
# initialize annex there if not yet initialized
100-
AnnexRepo(ds.path, init=True)
93+
10194
# ds might have memories of having ds.repo GitRepo
102-
superds = None
103-
del ds
104-
ds = Dataset(studydir)
95+
superds = Dataset(topdir)
96+
assert op.realpath(ds.path) == op.realpath(studydir)
97+
assert isinstance(ds.repo, AnnexRepo)
10598
# Add doesn't have all the options of save such as msg and supers
106-
ds.add('.gitattributes', to_git=True, save=False)
99+
ds.save(path=['.gitattributes'], message="Custom .gitattributes", to_git=True)
107100
dsh = dsh_path = None
108101
if op.lexists(op.join(ds.path, '.heudiconv')):
109102
dsh_path = op.join(ds.path, '.heudiconv')
@@ -120,7 +113,6 @@ def add_to_datalad(topdir, studydir, msg, bids):
120113
else:
121114
dsh = ds.create(path='.heudiconv',
122115
force=True,
123-
**create_kwargs
124116
# shared_access='all'
125117
)
126118
# Since .heudiconv could contain sensitive information
@@ -146,7 +138,7 @@ def add_to_datalad(topdir, studydir, msg, bids):
146138
mark_sensitive(ds, '*/*/anat') # within ses/subj
147139
if dsh_path:
148140
mark_sensitive(ds, '.heudiconv') # entire .heudiconv!
149-
ds.save(message=msg, recursive=True, super_datasets=True)
141+
superds.save(path=ds.path, message=msg, recursive=True)
150142

151143
assert not ds.repo.dirty
152144
# TODO: they are still appearing as native annex symlinked beasts

heudiconv/info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
EXTRA_REQUIRES = {
4444
'tests': TESTS_REQUIRES,
4545
'extras': [], # Requires patched version ATM ['dcmstack'],
46-
'datalad': ['datalad']
46+
'datalad': ['datalad >=0.12.2']
4747
}
4848

4949
# Flatten the lists

0 commit comments

Comments
 (0)