diff --git a/q2cli/builtin/tools.py b/q2cli/builtin/tools.py index 88b2d396..4c58caad 100644 --- a/q2cli/builtin/tools.py +++ b/q2cli/builtin/tools.py @@ -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, @@ -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, @@ -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, diff --git a/q2cli/tests/test_tools.py b/q2cli/tests/test_tools.py index 2447caff..1d6813b1 100644 --- a/q2cli/tests/test_tools.py +++ b/q2cli/tests/test_tools.py @@ -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') @@ -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') @@ -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):