From 417d3fa4df815fa18fe6040949984e0cde39a124 Mon Sep 17 00:00:00 2001 From: "C. Titus Brown" Date: Sat, 9 Mar 2024 10:50:10 -0800 Subject: [PATCH 01/10] try setting up --v4 and --v5 behavior --- src/sourmash/cli/sig/check.py | 14 ++++++++++++++ src/sourmash/sig/__main__.py | 5 +++++ tests/conftest.py | 5 +++++ tests/sourmash_tst_utils.py | 17 ++++++++++++++++- tests/test_cmd_signature.py | 3 ++- 5 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/sourmash/cli/sig/check.py b/src/sourmash/cli/sig/check.py index 93335d4308..c27f1d1973 100644 --- a/src/sourmash/cli/sig/check.py +++ b/src/sourmash/cli/sig/check.py @@ -72,6 +72,7 @@ def subparser(subparsers): "--use-absolute-paths", help="convert all locations to absolute paths", action="store_true", + default=None, ) subparser.add_argument( "--no-abspath", @@ -97,6 +98,19 @@ def subparser(subparsers): add_pattern_args(subparser) add_picklist_args(subparser) + subparser.add_argument( + "--v4", + dest="cli_version", + action='store_const', + const="v4", + default="v4" + ) + subparser.add_argument( + "--v5", + dest="cli_version", + action='store_const', + const="v5" + ) def main(args): import sourmash diff --git a/src/sourmash/sig/__main__.py b/src/sourmash/sig/__main__.py index 94e1928175..a444581be7 100644 --- a/src/sourmash/sig/__main__.py +++ b/src/sourmash/sig/__main__.py @@ -1413,6 +1413,11 @@ def check(args): """ from sourmash.picklist import PickStyle + print(args.cli_version) + if args.cli_version == "v5": + if args.abspath is None: # not set by user + args.relpath = True + set_quiet(args.quiet, args.debug) moltype = sourmash_args.calculate_moltype(args) picklist = sourmash_args.load_picklist(args) diff --git a/tests/conftest.py b/tests/conftest.py index 4274382e74..f737c7b013 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -13,6 +13,11 @@ sys.stdout = sys.stderr +@pytest.fixture(params=["v4", "v5"]) +def cli_v4_and_v5(request): + return request.param + + @pytest.fixture def runtmp(): with TempDirectory() as location: diff --git a/tests/sourmash_tst_utils.py b/tests/sourmash_tst_utils.py index a2a35cb2e6..1f6484ade5 100644 --- a/tests/sourmash_tst_utils.py +++ b/tests/sourmash_tst_utils.py @@ -189,10 +189,25 @@ def run_sourmash(self, *args, **kwargs): if "in_directory" not in kwargs: kwargs["in_directory"] = self.location + version_arg = None + if "version" in kwargs: + ver = kwargs["version"] + assert ver in ('v4', 'v5', 'default'), ver + if ver == 'v4': + version_arg = '--v4' + elif ver == 'v5': + version_arg = '--v5' + elif ver == 'default': + pass + cmdlist = ["sourmash"] cmdlist.extend(str(x) for x in args) + if version_arg is not None: + print(f'setting CLI version arg to: {version_arg}') + cmdlist.append(version_arg) + self.last_command = " ".join(cmdlist) - self.last_result = runscript("sourmash", args, **kwargs) + self.last_result = runscript("sourmash", cmdlist[1:], **kwargs) if self.last_result.status: raise SourmashCommandFailed(self.last_result.err) diff --git a/tests/test_cmd_signature.py b/tests/test_cmd_signature.py index 9f14b6df58..376888f034 100644 --- a/tests/test_cmd_signature.py +++ b/tests/test_cmd_signature.py @@ -5649,7 +5649,7 @@ def test_sig_check_5_abspath(runtmp): assert os.path.basename(k) in sigfiles # converts back to basic -def test_sig_check_5_no_abspath(runtmp): +def test_sig_check_5_no_abspath(runtmp, cli_v4_and_v5): # check path rewriting for default (--no-relpath --no-abspath) # this behavior will change in v5; specify `--no-abspath` then? sigfiles = glob.glob(utils.get_test_data("gather/GCF*.sig")) @@ -5670,6 +5670,7 @@ def test_sig_check_5_no_abspath(runtmp): "-m", "mf.csv", # "--no-abspath" # => default behavior + version=cli_v4_and_v5 ) out_mf = runtmp.output("mf.csv") From 9a2acd9910d8b789229ad200ccb0c7fb8f42bde5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 9 Mar 2024 19:22:00 +0000 Subject: [PATCH 02/10] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/sourmash/cli/sig/check.py | 14 +++----------- src/sourmash/sig/__main__.py | 2 +- tests/sourmash_tst_utils.py | 14 +++++++------- tests/test_cmd_signature.py | 2 +- 4 files changed, 12 insertions(+), 20 deletions(-) diff --git a/src/sourmash/cli/sig/check.py b/src/sourmash/cli/sig/check.py index c27f1d1973..91d92c2932 100644 --- a/src/sourmash/cli/sig/check.py +++ b/src/sourmash/cli/sig/check.py @@ -99,18 +99,10 @@ def subparser(subparsers): add_picklist_args(subparser) subparser.add_argument( - "--v4", - dest="cli_version", - action='store_const', - const="v4", - default="v4" - ) - subparser.add_argument( - "--v5", - dest="cli_version", - action='store_const', - const="v5" + "--v4", dest="cli_version", action="store_const", const="v4", default="v4" ) + subparser.add_argument("--v5", dest="cli_version", action="store_const", const="v5") + def main(args): import sourmash diff --git a/src/sourmash/sig/__main__.py b/src/sourmash/sig/__main__.py index a444581be7..fe2bb55223 100644 --- a/src/sourmash/sig/__main__.py +++ b/src/sourmash/sig/__main__.py @@ -1415,7 +1415,7 @@ def check(args): print(args.cli_version) if args.cli_version == "v5": - if args.abspath is None: # not set by user + if args.abspath is None: # not set by user args.relpath = True set_quiet(args.quiet, args.debug) diff --git a/tests/sourmash_tst_utils.py b/tests/sourmash_tst_utils.py index 1f6484ade5..b3b26fcbe9 100644 --- a/tests/sourmash_tst_utils.py +++ b/tests/sourmash_tst_utils.py @@ -192,18 +192,18 @@ def run_sourmash(self, *args, **kwargs): version_arg = None if "version" in kwargs: ver = kwargs["version"] - assert ver in ('v4', 'v5', 'default'), ver - if ver == 'v4': - version_arg = '--v4' - elif ver == 'v5': - version_arg = '--v5' - elif ver == 'default': + assert ver in ("v4", "v5", "default"), ver + if ver == "v4": + version_arg = "--v4" + elif ver == "v5": + version_arg = "--v5" + elif ver == "default": pass cmdlist = ["sourmash"] cmdlist.extend(str(x) for x in args) if version_arg is not None: - print(f'setting CLI version arg to: {version_arg}') + print(f"setting CLI version arg to: {version_arg}") cmdlist.append(version_arg) self.last_command = " ".join(cmdlist) diff --git a/tests/test_cmd_signature.py b/tests/test_cmd_signature.py index 376888f034..576861bdc5 100644 --- a/tests/test_cmd_signature.py +++ b/tests/test_cmd_signature.py @@ -5670,7 +5670,7 @@ def test_sig_check_5_no_abspath(runtmp, cli_v4_and_v5): "-m", "mf.csv", # "--no-abspath" # => default behavior - version=cli_v4_and_v5 + version=cli_v4_and_v5, ) out_mf = runtmp.output("mf.csv") From cae3bbffa323baf6e3242b8f0fb03c3706f4e463 Mon Sep 17 00:00:00 2001 From: "C. Titus Brown" Date: Sun, 10 Mar 2024 08:41:31 -0700 Subject: [PATCH 03/10] add some more fixtures --- tests/conftest.py | 13 ++++++++++++- tests/sourmash_tst_utils.py | 4 ++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index f737c7b013..8a673ca645 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -13,10 +13,21 @@ sys.stdout = sys.stderr -@pytest.fixture(params=["v4", "v5"]) +# behavior is default behavior, present in both sourmash v4 and sourmash v5. +@pytest.fixture(params=["v4", "v5", "(default)"]) def cli_v4_and_v5(request): return request.param +# behavior is default behavior in v4, and maybe will be invoked by --v4 in v5. +@pytest.fixture(params=["v4", "(default)"]) +def cli_v4_only(request): + return request.param + +# behavior is available with --v5 and will be default in sourmash v5. +@pytest.fixture(params=["v5"]) +def cli_v5_only(request): + return request.param + @pytest.fixture def runtmp(): diff --git a/tests/sourmash_tst_utils.py b/tests/sourmash_tst_utils.py index b3b26fcbe9..bf6702fd58 100644 --- a/tests/sourmash_tst_utils.py +++ b/tests/sourmash_tst_utils.py @@ -192,12 +192,12 @@ def run_sourmash(self, *args, **kwargs): version_arg = None if "version" in kwargs: ver = kwargs["version"] - assert ver in ("v4", "v5", "default"), ver + assert ver in ("v4", "v5", "(default)"), ver if ver == "v4": version_arg = "--v4" elif ver == "v5": version_arg = "--v5" - elif ver == "default": + elif ver == "(default)": pass cmdlist = ["sourmash"] From 52fb3b5b3444f3d237c84fa4c95e8cdcd94cf48f Mon Sep 17 00:00:00 2001 From: "C. Titus Brown" Date: Sun, 10 Mar 2024 10:07:37 -0700 Subject: [PATCH 04/10] path rewriting default --- tests/test_cmd_signature.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_cmd_signature.py b/tests/test_cmd_signature.py index 576861bdc5..d89a00beee 100644 --- a/tests/test_cmd_signature.py +++ b/tests/test_cmd_signature.py @@ -5649,7 +5649,7 @@ def test_sig_check_5_abspath(runtmp): assert os.path.basename(k) in sigfiles # converts back to basic -def test_sig_check_5_no_abspath(runtmp, cli_v4_and_v5): +def test_sig_check_5_no_abspath(runtmp, cli_v4_only): # check path rewriting for default (--no-relpath --no-abspath) # this behavior will change in v5; specify `--no-abspath` then? sigfiles = glob.glob(utils.get_test_data("gather/GCF*.sig")) @@ -5670,7 +5670,7 @@ def test_sig_check_5_no_abspath(runtmp, cli_v4_and_v5): "-m", "mf.csv", # "--no-abspath" # => default behavior - version=cli_v4_and_v5, + version=cli_v4_only, ) out_mf = runtmp.output("mf.csv") From e076dcf3ac726b70b067bfcdca19420c6e9d1d4f Mon Sep 17 00:00:00 2001 From: "C. Titus Brown" Date: Sun, 10 Mar 2024 10:10:50 -0700 Subject: [PATCH 05/10] add new test for sig check --relpath being default behavior in v5 --- tests/test_cmd_signature.py | 43 ++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/tests/test_cmd_signature.py b/tests/test_cmd_signature.py index d89a00beee..ca6a2f5418 100644 --- a/tests/test_cmd_signature.py +++ b/tests/test_cmd_signature.py @@ -5574,7 +5574,7 @@ def test_sig_check_5_relpath(runtmp): def test_sig_check_5_relpath_subdir(runtmp): # check path rewriting when both sigs and mf are in different subdirs. - # this will be the default behavior in v5 => can remove --relpath then. + # use explicit --relpath (which will become default in v5) sigfiles = glob.glob(utils.get_test_data("gather/GCF*.sig")) picklist = utils.get_test_data("gather/salmonella-picklist.csv") @@ -5613,6 +5613,47 @@ def test_sig_check_5_relpath_subdir(runtmp): assert set(locations).issubset(expected_names), (locations, expected_names) +def test_sig_check_5_relpath_subdir_default(runtmp, cli_v5_only): + # check path rewriting when both sigs and mf are in different subdirs. + # default in v5 is --relpath. + sigfiles = glob.glob(utils.get_test_data("gather/GCF*.sig")) + picklist = utils.get_test_data("gather/salmonella-picklist.csv") + + os.mkdir(runtmp.output("sigs_dir")) + new_names = [] + for f in sigfiles: + basename = os.path.basename(f) + filename = os.path.join("sigs_dir", basename) + + shutil.copyfile(f, runtmp.output(filename)) + new_names.append(filename) + + runtmp.sourmash( + "sig", + "check", + *new_names, + "--picklist", + f"{picklist}::manifest", + "-m", + "mf.csv", + version=cli_v5_only, + ) + + out_mf = runtmp.output("mf.csv") + assert os.path.exists(out_mf) + + # all should match. + with open(out_mf, newline="") as fp: + mf = CollectionManifest.load_from_csv(fp) + assert len(mf) == 24 + + locations = [row["internal_location"] for row in mf.rows] + print("XXX", locations) + print("YYY", new_names) + expected_names = ["./" + f for f in new_names] + assert set(locations).issubset(expected_names), (locations, expected_names) + + def test_sig_check_5_abspath(runtmp): # check path rewriting with `--abspath` => absolute paths. sigfiles = glob.glob(utils.get_test_data("gather/GCF*.sig")) From 03280c57818fa59eb74f4b299ed4d786b3cdb42a Mon Sep 17 00:00:00 2001 From: "C. Titus Brown" Date: Sun, 10 Mar 2024 10:17:21 -0700 Subject: [PATCH 06/10] update comments etc --- tests/test_cmd_signature.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/test_cmd_signature.py b/tests/test_cmd_signature.py index ca6a2f5418..3ac9453829 100644 --- a/tests/test_cmd_signature.py +++ b/tests/test_cmd_signature.py @@ -5533,7 +5533,7 @@ def test_sig_check_4_manifest_subdir_subdir(runtmp, abspath_or_relpath): def test_sig_check_5_relpath(runtmp): # check path rewriting when sketches are in a subdir. - # this will be the default behavior in v5 => remove --relpath. + # this will be the default behavior in v5. sigfiles = glob.glob(utils.get_test_data("gather/GCF*.sig")) picklist = utils.get_test_data("gather/salmonella-picklist.csv") @@ -5572,7 +5572,7 @@ def test_sig_check_5_relpath(runtmp): assert set(locations).issubset(expected_names), (locations, expected_names) -def test_sig_check_5_relpath_subdir(runtmp): +def test_sig_check_5_relpath_subdir(runtmp, cli_v4_and_v5): # check path rewriting when both sigs and mf are in different subdirs. # use explicit --relpath (which will become default in v5) sigfiles = glob.glob(utils.get_test_data("gather/GCF*.sig")) @@ -5596,6 +5596,7 @@ def test_sig_check_5_relpath_subdir(runtmp): "-m", "mf.csv", "--relpath", + version=cli_v4_and_v5 ) out_mf = runtmp.output("mf.csv") @@ -5613,7 +5614,7 @@ def test_sig_check_5_relpath_subdir(runtmp): assert set(locations).issubset(expected_names), (locations, expected_names) -def test_sig_check_5_relpath_subdir_default(runtmp, cli_v5_only): +def test_sig_check_5_relpath_subdir_default_v5(runtmp, cli_v5_only): # check path rewriting when both sigs and mf are in different subdirs. # default in v5 is --relpath. sigfiles = glob.glob(utils.get_test_data("gather/GCF*.sig")) @@ -5654,7 +5655,7 @@ def test_sig_check_5_relpath_subdir_default(runtmp, cli_v5_only): assert set(locations).issubset(expected_names), (locations, expected_names) -def test_sig_check_5_abspath(runtmp): +def test_sig_check_5_abspath(runtmp, cli_v4_and_v5): # check path rewriting with `--abspath` => absolute paths. sigfiles = glob.glob(utils.get_test_data("gather/GCF*.sig")) picklist = utils.get_test_data("gather/salmonella-picklist.csv") @@ -5674,6 +5675,7 @@ def test_sig_check_5_abspath(runtmp): "-m", "mf.csv", "--abspath", + version=cli_v4_and_v5 ) out_mf = runtmp.output("mf.csv") From 15c091ce1a6829d233b6ed1fb95a422dcc6bf9e8 Mon Sep 17 00:00:00 2001 From: "C. Titus Brown" Date: Sun, 10 Mar 2024 10:21:53 -0700 Subject: [PATCH 07/10] begin adding v4/v5 --relpath checks to sig collect too --- src/sourmash/cli/sig/collect.py | 6 ++++++ src/sourmash/sig/__main__.py | 6 ++++-- tests/test_cmd_signature_collect.py | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/sourmash/cli/sig/collect.py b/src/sourmash/cli/sig/collect.py index 73077fe9fb..3921f593d7 100644 --- a/src/sourmash/cli/sig/collect.py +++ b/src/sourmash/cli/sig/collect.py @@ -58,6 +58,7 @@ def subparser(subparsers): "--use-absolute-paths", help="convert all locations to absolute paths", action="store_true", +# default=None, ) subparser.add_argument( "--no-abspath", @@ -81,6 +82,11 @@ def subparser(subparsers): add_ksize_arg(subparser) add_moltype_args(subparser) + subparser.add_argument( + "--v4", dest="cli_version", action="store_const", const="v4", default="v4" + ) + subparser.add_argument("--v5", dest="cli_version", action="store_const", const="v5") + def main(args): import sourmash diff --git a/src/sourmash/sig/__main__.py b/src/sourmash/sig/__main__.py index fe2bb55223..aede904a04 100644 --- a/src/sourmash/sig/__main__.py +++ b/src/sourmash/sig/__main__.py @@ -1413,7 +1413,6 @@ def check(args): """ from sourmash.picklist import PickStyle - print(args.cli_version) if args.cli_version == "v5": if args.abspath is None: # not set by user args.relpath = True @@ -1556,9 +1555,12 @@ def check(args): def collect(args): "Collect signature metadata across many locations, save to manifest" # TODO: - # test what happens with directories :) set_quiet(False, args.debug) + if args.cli_version == "v5": + if args.abspath is None: # not set by user + args.relpath = True + if os.path.exists(args.output): if args.merge_previous: pass diff --git a/tests/test_cmd_signature_collect.py b/tests/test_cmd_signature_collect.py index 917286e881..4855623e78 100644 --- a/tests/test_cmd_signature_collect.py +++ b/tests/test_cmd_signature_collect.py @@ -472,7 +472,7 @@ def test_sig_collect_4_multiple_no_abspath(runtmp, manifest_db_format): def test_sig_collect_4_multiple_subdir_subdir_no_abspath(runtmp, manifest_db_format): # collect a manifest from sig files, no abspath; use a subdir for sketches - # this should work with default behavior. + # this should work with default behavior. @CTB sig43 = utils.get_test_data("47.fa.sig") sig63 = utils.get_test_data("63.fa.sig") From 27201fcc71001092c77c74660893b89b00ebeb55 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 10 Mar 2024 17:23:07 +0000 Subject: [PATCH 08/10] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/sourmash/cli/sig/collect.py | 2 +- tests/conftest.py | 2 ++ tests/test_cmd_signature.py | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/sourmash/cli/sig/collect.py b/src/sourmash/cli/sig/collect.py index 3921f593d7..8006aae106 100644 --- a/src/sourmash/cli/sig/collect.py +++ b/src/sourmash/cli/sig/collect.py @@ -58,7 +58,7 @@ def subparser(subparsers): "--use-absolute-paths", help="convert all locations to absolute paths", action="store_true", -# default=None, + # default=None, ) subparser.add_argument( "--no-abspath", diff --git a/tests/conftest.py b/tests/conftest.py index 8a673ca645..347b0a640b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -18,11 +18,13 @@ def cli_v4_and_v5(request): return request.param + # behavior is default behavior in v4, and maybe will be invoked by --v4 in v5. @pytest.fixture(params=["v4", "(default)"]) def cli_v4_only(request): return request.param + # behavior is available with --v5 and will be default in sourmash v5. @pytest.fixture(params=["v5"]) def cli_v5_only(request): diff --git a/tests/test_cmd_signature.py b/tests/test_cmd_signature.py index 3ac9453829..6809c8ff25 100644 --- a/tests/test_cmd_signature.py +++ b/tests/test_cmd_signature.py @@ -5596,7 +5596,7 @@ def test_sig_check_5_relpath_subdir(runtmp, cli_v4_and_v5): "-m", "mf.csv", "--relpath", - version=cli_v4_and_v5 + version=cli_v4_and_v5, ) out_mf = runtmp.output("mf.csv") @@ -5675,7 +5675,7 @@ def test_sig_check_5_abspath(runtmp, cli_v4_and_v5): "-m", "mf.csv", "--abspath", - version=cli_v4_and_v5 + version=cli_v4_and_v5, ) out_mf = runtmp.output("mf.csv") From 3106d3bfa844da8b9ab6b8f0d14950e126dd4e80 Mon Sep 17 00:00:00 2001 From: "C. Titus Brown" Date: Sun, 10 Mar 2024 10:52:27 -0700 Subject: [PATCH 09/10] add test for default v5 behavior of sig collect --- src/sourmash/cli/sig/collect.py | 2 +- tests/test_cmd_signature_collect.py | 49 +++++++++++++++++++++++++++-- 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/src/sourmash/cli/sig/collect.py b/src/sourmash/cli/sig/collect.py index 8006aae106..841532e169 100644 --- a/src/sourmash/cli/sig/collect.py +++ b/src/sourmash/cli/sig/collect.py @@ -58,7 +58,7 @@ def subparser(subparsers): "--use-absolute-paths", help="convert all locations to absolute paths", action="store_true", - # default=None, + default=None, ) subparser.add_argument( "--no-abspath", diff --git a/tests/test_cmd_signature_collect.py b/tests/test_cmd_signature_collect.py index 4855623e78..047c40a542 100644 --- a/tests/test_cmd_signature_collect.py +++ b/tests/test_cmd_signature_collect.py @@ -470,9 +470,9 @@ def test_sig_collect_4_multiple_no_abspath(runtmp, manifest_db_format): runtmp.sourmash("sig", "cat", f"mf.{ext}") -def test_sig_collect_4_multiple_subdir_subdir_no_abspath(runtmp, manifest_db_format): +def test_sig_collect_4_multiple_subdir_subdir_relpath(runtmp, manifest_db_format): # collect a manifest from sig files, no abspath; use a subdir for sketches - # this should work with default behavior. @CTB + # fails with default v4 behavior; see #3008. sig43 = utils.get_test_data("47.fa.sig") sig63 = utils.get_test_data("63.fa.sig") @@ -515,6 +515,51 @@ def test_sig_collect_4_multiple_subdir_subdir_no_abspath(runtmp, manifest_db_for runtmp.sourmash("sig", "cat", f"mf_dir/mf.{ext}") +def test_sig_collect_4_multiple_subdir_subdir_default_is_relpath(runtmp, manifest_db_format, cli_v5_only): + # collect a manifest from sig files, no abspath; use a subdir for sketches + # --relpath is used by default on v5. + sig43 = utils.get_test_data("47.fa.sig") + sig63 = utils.get_test_data("63.fa.sig") + + # copy files to tmp, where they will not have full paths + os.mkdir(runtmp.output("sigs_dir")) + shutil.copyfile(sig43, runtmp.output("sigs_dir/47.fa.sig")) + shutil.copyfile(sig63, runtmp.output("sigs_dir/63.fa.sig")) + + # put manifest in subdir too. + os.mkdir(runtmp.output("mf_dir")) + + ext = "sqlmf" if manifest_db_format == "sql" else "csv" + + runtmp.sourmash( + "sig", + "collect", + "sigs_dir/47.fa.sig", + "sigs_dir/63.fa.sig", + "-o", + f"mf_dir/mf.{ext}", + "-F", + manifest_db_format, + version=cli_v5_only, + ) + + manifest_fn = runtmp.output(f"mf_dir/mf.{ext}") + manifest = BaseCollectionManifest.load_from_filename(manifest_fn) + + assert len(manifest) == 2 + md5_list = [row["md5"] for row in manifest.rows] + assert "09a08691ce52952152f0e866a59f6261" in md5_list + assert "38729c6374925585db28916b82a6f513" in md5_list + + locations = set([row["internal_location"] for row in manifest.rows]) + print(locations) + assert len(locations) == 2, locations + assert "../sigs_dir/47.fa.sig" in locations + assert "../sigs_dir/63.fa.sig" in locations + + runtmp.sourmash("sig", "cat", f"mf_dir/mf.{ext}") + + def test_sig_collect_4_multiple_cwd_subdir_no_abspath(runtmp, manifest_db_format): # collect a manifest from sig files, no abspath; use a subdir for sketches # this should work with default behavior. From 18f5cad99aec0c58f137ff6da3ff175933118a00 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 10 Mar 2024 18:06:45 +0000 Subject: [PATCH 10/10] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_cmd_signature_collect.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_cmd_signature_collect.py b/tests/test_cmd_signature_collect.py index 047c40a542..b2c2523410 100644 --- a/tests/test_cmd_signature_collect.py +++ b/tests/test_cmd_signature_collect.py @@ -515,7 +515,9 @@ def test_sig_collect_4_multiple_subdir_subdir_relpath(runtmp, manifest_db_format runtmp.sourmash("sig", "cat", f"mf_dir/mf.{ext}") -def test_sig_collect_4_multiple_subdir_subdir_default_is_relpath(runtmp, manifest_db_format, cli_v5_only): +def test_sig_collect_4_multiple_subdir_subdir_default_is_relpath( + runtmp, manifest_db_format, cli_v5_only +): # collect a manifest from sig files, no abspath; use a subdir for sketches # --relpath is used by default on v5. sig43 = utils.get_test_data("47.fa.sig")