Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ TemplateFlow 2.0 file names: the client reads the v2 skeleton and resolves old n
* FIX: ``get()`` skipped files when DataLad fetched several at once, and failed for
files without a stub in the home.
* FIX: Network errors other than connection errors no longer break skeleton updates.
* FIX: DataLad homes update from ``origin`` (GitHub) only: a template's GIN remote
refusing a fetch no longer makes ``update()`` fail.
* FIX: In DataLad mode, ``templateflow wipe`` no longer asks for confirmation, nor
reports the home as wiped out: it deletes nothing there.
* MAINT: A compatibility matrix (``tests/compat``, workflow *Compatibility*) runs the
released clients and this one against an Archive before and after a renames table,
in S3 and DataLad homes. It replays a proposed table before it is merged.
Expand Down
10 changes: 7 additions & 3 deletions templateflow/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ def config():
@main.command()
def wipe():
"""Wipe out a local S3 (direct-download) TemplateFlow Archive."""
from templateflow.conf import wipe as _wipe

if CONFIG.use_datalad:
_wipe() # DataLad homes are never wiped out: this only says so
return

click.echo(f'This will wipe out all data downloaded into {CONFIG.root}.')

if click.confirm('Do you want to continue?'):
Expand All @@ -112,9 +118,7 @@ def wipe():
show_default=False,
)
if value.strip() == str(CONFIG.root):
from templateflow.conf import wipe

wipe()
_wipe()
click.echo(f'{CONFIG.root} was wiped out.')
return
click.echo(f'Aborted! {CONFIG.root} WAS NOT wiped out.')
Expand Down
34 changes: 34 additions & 0 deletions templateflow/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,37 @@ def test_update_options(runner):
result = runner.invoke(cli.main, ['update', '--help'])
assert result.exit_code == 0
assert '--migrate' in result.stdout


@pytest.mark.parametrize(
('use_datalad', 'answers', 'wiped'),
[
(False, ['y', '{root}'], True),
(False, ['y', 'elsewhere'], False),
(False, ['n'], False),
(True, ['y', '{root}'], False),
],
)
def test_wipe(runner, monkeypatch, tmp_path, use_datalad, answers, wiped):
from types import SimpleNamespace

import templateflow.conf
from templateflow.conf.cache import DataladManager, S3Manager

root = tmp_path / 'templateflow'
(root / 'tpl-Test').mkdir(parents=True)
manager = DataladManager('origin') if use_datalad else S3Manager('s3')
monkeypatch.setattr(cli, 'CONFIG', SimpleNamespace(root=root, use_datalad=use_datalad))
monkeypatch.setattr(templateflow.conf, 'wipe', lambda: manager.wipe(root))

answers = ''.join(f'{answer}\n' for answer in answers).format(root=root)
result = runner.invoke(cli.main, ['wipe'], input=answers)

assert result.exit_code == 0
assert root.exists() is not wiped
assert result.output.endswith(f'{root} was wiped out.\n') is wiped
if use_datalad:
# No prompts, and no claim that anything was deleted
assert (
result.output == 'TemplateFlow is configured in DataLad mode, wipe() has no effect\n'
)
Loading