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
15 changes: 15 additions & 0 deletions q2cli/builtin/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1287,6 +1287,11 @@ def provenance_replay(
)
raise ValueError(msg)

try:
in_fp = q2cli.util.try_as_cache_input(in_fp)
except ValueError:
pass

replay_provenance(
usage_driver=usage_driver_type,
payload=in_fp,
Expand Down Expand Up @@ -1348,6 +1353,11 @@ def citations_replay(
from qiime2.core.archive.provenance_lib.parse import ProvDAG
from qiime2.core.archive.provenance_lib.replay import replay_citations

try:
in_fp = q2cli.util.try_as_cache_input(in_fp)
except ValueError:
pass

dag = ProvDAG(in_fp, verbose=verbose, recurse=recurse)
replay_citations(
dag,
Expand Down Expand Up @@ -1439,6 +1449,11 @@ def supplement_replay(
)
raise ValueError(msg)

try:
in_fp = q2cli.util.try_as_cache_input(in_fp)
except ValueError:
pass

replay_supplement(
usage_drivers=usage_driver_types,
payload=in_fp,
Expand Down
33 changes: 33 additions & 0 deletions q2cli/tests/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,17 @@ def setUp(self):
def tearDown(self):
shutil.rmtree(self.tempdir)

def test_replay_provenance_cache(self):
cache = Cache(os.path.join(self.tempdir, 'cache'))
int_seq1 = Artifact.import_data('IntSequence1', [1, 2, 3])
cache.save(int_seq1, 'int_seq1')
cache_fp = os.path.join(self.tempdir, 'cache:int_seq1')

self.runner.invoke(
tools,
['replay-provenance', 'in-fp', cache_fp, '--out-fp', self.tempdir]
)

def test_replay_provenance(self):
in_fp = os.path.join(self.tempdir, 'concated_ints.qza')
out_fp = os.path.join(self.tempdir, 'rendered.txt')
Expand Down Expand Up @@ -1188,6 +1199,17 @@ def test_replay_citations_no_deduplicate(self):
re.compile(r'framework\|rachis:.*?\|0.*' * 4, re.DOTALL)
self.assertRegex(file_contents, framework_citations)

def test_replay_citations_cache(self):
cache = Cache(os.path.join(self.tempdir, 'cache'))
int_seq1 = Artifact.import_data('IntSequence1', [1, 2, 3])
cache.save(int_seq1, 'int_seq1')
cache_fp = os.path.join(self.tempdir, 'cache:int_seq1')

self.runner.invoke(
tools,
['replay-citations', 'in-fp', cache_fp, '--out-fp', self.tempdir]
)

def test_replay_supplement(self):
in_fp = os.path.join(self.tempdir, 'concated_ints.qza')
out_fp = os.path.join(self.tempdir, 'supplement.zip')
Expand Down Expand Up @@ -1279,6 +1301,17 @@ def test_replay_supplement_zipfile(self):

self.assertEqual(os.listdir(unzipped_path), ['supplement'])

def test_replay_supplement_cache(self):
cache = Cache(os.path.join(self.tempdir, 'cache'))
int_seq1 = Artifact.import_data('IntSequence1', [1, 2, 3])
cache.save(int_seq1, 'int_seq1')
cache_fp = os.path.join(self.tempdir, 'cache:int_seq1')

self.runner.invoke(
tools,
['replay-supplement', 'in-fp', cache_fp, '--out-fp', self.tempdir]
)

# Leave me alone I know the checksums don't match
@pytest.mark.filterwarnings('ignore::UserWarning')
def test_replay_param_not_found(self):
Expand Down
Loading