Skip to content

Commit

Permalink
Merge pull request #4552 from yarikoptic/bf-no-key
Browse files Browse the repository at this point in the history
  • Loading branch information
kyleam committed May 20, 2020
2 parents bce4caf + 32e6cbf commit e8dfe59
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 28 deletions.
18 changes: 6 additions & 12 deletions datalad/customremotes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

from ..ui import ui
from ..support.protocol import ProtocolInterface
from ..support.external_versions import external_versions
from ..support.cache import DictCache
from ..cmdline.helpers import get_repo_instance
from ..dochelpers import exc_str
Expand Down Expand Up @@ -252,8 +251,6 @@ def __init__(self, path=None, cost=None, fin=None, fout=None): # , availability
# Delay introspection until the first instance gets born
# could in principle be done once in the metaclass I guess
self.__class__._introspect_req_signatures()
self._annex_supports_info = \
external_versions['cmd:annex'] >= '6.20180206'

@classmethod
def _introspect_req_signatures(cls):
Expand Down Expand Up @@ -386,8 +383,7 @@ def error(self, msg, annex_err="ERROR"):

def info(self, msg):
lgr.info(msg)
if self._annex_supports_info:
self.send('INFO', msg)
self.send('INFO', msg)

def progress(self, bytes):
bytes = int(bytes)
Expand Down Expand Up @@ -669,7 +665,6 @@ def generate_uuids():

def init_datalad_remote(repo, remote, encryption=None, autoenable=False, opts=[]):
"""Initialize datalad special remote"""
from datalad.support.external_versions import external_versions
from datalad.consts import DATALAD_SPECIAL_REMOTES_UUIDS
lgr.info("Initiating special remote %s" % remote)
remote_opts = [
Expand All @@ -678,12 +673,11 @@ def init_datalad_remote(repo, remote, encryption=None, autoenable=False, opts=[]
'autoenable=%s' % str(bool(autoenable)).lower(),
'externaltype=%s' % remote
]
if external_versions['cmd:annex'] >= '6.20170208':
# use unique uuid for our remotes
# This should help with merges of disconnected repos etc
# ATM only datalad/datalad-archives is expected,
# so on purpose getitem
remote_opts.append('uuid=%s' % DATALAD_SPECIAL_REMOTES_UUIDS[remote])
# use unique uuid for our remotes
# This should help with merges of disconnected repos etc
# ATM only datalad/datalad-archives is expected,
# so on purpose getitem
remote_opts.append('uuid=%s' % DATALAD_SPECIAL_REMOTES_UUIDS[remote])
return repo.init_remote(remote, remote_opts + opts)


Expand Down
26 changes: 22 additions & 4 deletions datalad/customremotes/tests/test_datalad.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from ...support.annexrepo import AnnexRepo
from ...consts import DATALAD_SPECIAL_REMOTE
from ...tests.utils import *
from ...support.external_versions import external_versions

from . import _get_custom_runner
from ...support.exceptions import CommandError
Expand All @@ -34,10 +35,27 @@ def check_basic_scenario(url, d):
with swallow_outputs() as cmo:
annex.add_urls([url])
annex.commit("committing")
whereis1 = annex.whereis('3versions_allversioned.txt', output='full')
eq_(len(whereis1), 2) # here and datalad
annex.drop('3versions_allversioned.txt')
whereis2 = annex.whereis('3versions_allversioned.txt', output='full')

# git-annex got a fix where it stopped replacing - in the middle of the filename
# Let's cater to the developers who might have some intermediate version and not
# easy to compare -- we will just check that only one file there is an that it
# matches what we expect when outside of the development versions range:
filenames = glob.glob(op.join(d, '3versions[-_]allversioned.txt'))
assert_equal(len(filenames), 1)
filename = op.basename(filenames[0])
if external_versions['cmd:annex'] < '8.20200501':
assert_in('_', filename)
# Date after the fix in 8.20200501-53-gcabbc91b1
elif external_versions['cmd:annex'] >= '8.20200512':
assert_in('-', filename)
else:
pass # either of those is ok

whereis1 = annex.whereis(filename, output='full')
eq_(len(whereis1), 2) # here and datalad
annex.drop(filename)

whereis2 = annex.whereis(filename, output='full')
eq_(len(whereis2), 1) # datalad

# if we provide some bogus address which we can't access, we shouldn't pollute output
Expand Down
6 changes: 0 additions & 6 deletions datalad/distribution/tests/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -880,12 +880,6 @@ def check_datasets_datalad_org(suffix, tdir):
# Windows we get two records due to a duplicate attempt (as res[1]) to get it
# again, which is reported as "notneeded". For the purpose of this test
# it doesn't make a difference.
# git-annex version is not "real" - but that is about when fix was introduced
from datalad import cfg
if on_windows \
and cfg.obtain("datalad.repo.version") < 6 \
and external_versions['cmd:annex'] <= '7.20181203':
raise SkipTest("Known to fail, needs fixed git-annex")
assert_result_count(
ds.get(op.join('001-anat-scout_ses-{date}', '000001.dcm')),
1,
Expand Down
7 changes: 2 additions & 5 deletions datalad/interface/tests/test_add_archive_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
from ...utils import on_windows
from datalad.log import lgr
from ...api import add_archive_content, clean
from datalad.support.external_versions import external_versions
from datalad.consts import DATALAD_SPECIAL_REMOTES_UUIDS
from datalad.consts import ARCHIVES_SPECIAL_REMOTE

Expand Down Expand Up @@ -99,10 +98,8 @@ def test_add_archive_dirs(path_orig, url, repo_path):
use_current_dir=False,
exclude='.*__MACOSX.*') # some junk penetrates

if external_versions['cmd:annex'] >= '6.20170208':
# should have fixed remotes
eq_(repo.get_description(uuid=DATALAD_SPECIAL_REMOTES_UUIDS[ARCHIVES_SPECIAL_REMOTE]),
'[%s]' % ARCHIVES_SPECIAL_REMOTE)
eq_(repo.get_description(uuid=DATALAD_SPECIAL_REMOTES_UUIDS[ARCHIVES_SPECIAL_REMOTE]),
'[%s]' % ARCHIVES_SPECIAL_REMOTE)

all_files = sorted(find_files('.'))
target_files = {
Expand Down
2 changes: 1 addition & 1 deletion datalad/support/annexrepo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2385,7 +2385,7 @@ def whereis(self, files, output='uuids', key=False, options=None, batch=False):
j['key' if (key or '--all' in options) else 'file']
: self._whereis_json_to_dict(j)
for j in json_objects
if not j.get('key').endswith('.this-is-a-test-key')
if not j.get('key', '').endswith('.this-is-a-test-key')
}

# TODO:
Expand Down

0 comments on commit e8dfe59

Please sign in to comment.