Commit e03de1a2 authored by Samuel GAIST's avatar Samuel GAIST

[cache] Add remove command to cache

This allows to clear the content of a specific block.

This allows to experiment re-runs to take advantage of the
cache up to the block that was cleaned.
parent ce9f5391
Pipeline #38056 passed with stage
in 4 minutes and 22 seconds
......@@ -212,3 +212,30 @@ def view(ctx, paths):
.replace(')BEAT_LIST_SIZE"', ")")
) + json_data)
@click.option("--no-inputs", is_flag=True, default=False)
@click.argument("paths", nargs=-1, required=True)
def remove(ctx, paths, no_inputs):
"""Remove content of the cache entries passed in parameters
To remove an entry:
$ %(prog)s cache remove 7f/d8/8d/a11178ac27075feaba8131fe878d6e3...
config = ctx.meta["config"]
for path in paths:
fullpath = os.path.join(config.cache, path[: path.rfind("/")])
file_list = [os.path.join(fullpath, file_) for file_ in os.listdir(fullpath)]
if file_list:
click.echo("About to delete:\n{}".format("\n".join(file_list)))
if no_inputs or click.confirm("Do you confirm the deletion ?"):
for file_ in file_list:
click.echo("Nothing to delete")
......@@ -55,13 +55,15 @@ def call(*args, **kwargs):
use_prefix = kwargs.get("prefix", prefix)
arguments = ["--prefix", use_prefix, "--cache", tmp_prefix] + list(args)
verbose = kwargs.get("verbose", False)
if not verbose:
arguments.insert(0, "--test-mode")
runner = CliRunner()
with runner.isolated_filesystem():
result = runner.invoke(
["--test-mode", "--prefix", use_prefix, "--cache", tmp_prefix] + list(args),
result = runner.invoke(main_cli.main, arguments, catch_exceptions=False)
return result.exit_code, result.output
......@@ -97,6 +99,19 @@ def test_cache_view():, 0, out)
def test_cache_remove():, 0)
ex_code, out = call("cache", "info", verbose=True), 0, out)
entry = out.split("\n")[0]
entry = entry[6:]
ex_code, out = call("cache", "remove", "--no-inputs", entry), 0, out)"About to delete:"))"Done\n"))
def test_cache_clear():, 0)
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment