From 6b26525b3a2ed83fe7b23be6879cce3d01c14937 Mon Sep 17 00:00:00 2001 From: Dacheng Xu Date: Tue, 24 Sep 2024 22:54:44 -0400 Subject: [PATCH] Following https://github.com/AxFoundation/strax/pull/893 (#1432) --- straxen/config/preprocessors.py | 10 +++++----- straxen/scripts/refresh_raw_records.py | 2 +- straxen/storage/rucio_local.py | 2 +- straxen/storage/rucio_remote.py | 2 +- tests/storage/test_rucio_local.py | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/straxen/config/preprocessors.py b/straxen/config/preprocessors.py index 42fa6aa33..c5d897eae 100644 --- a/straxen/config/preprocessors.py +++ b/straxen/config/preprocessors.py @@ -14,11 +14,11 @@ def sort_url_kwargs(url: str): if isinstance(url, str) and URLConfig.SCHEME_SEP in url: if url != URLConfig.format_url_kwargs(url) and WARN: warnings.warn( - "From straxen version 2.1.0 onward, URLConfig parameters" - "will be sorted alphabetically before being passed to the plugins," - " this will change the lineage hash for non-sorted URLs. To load" - " data processed with non-sorted URLs, you will need to use an" - " older version." + "From straxen version 2.1.0 onward, URLConfig parameters " + "will be sorted alphabetically before being passed to the plugins, " + "this will change the lineage hash for non-sorted URLs. To load " + "data processed with non-sorted URLs, you will need to use an " + "older version." ) WARN = False diff --git a/straxen/scripts/refresh_raw_records.py b/straxen/scripts/refresh_raw_records.py index f4abe52f1..1faacb198 100755 --- a/straxen/scripts/refresh_raw_records.py +++ b/straxen/scripts/refresh_raw_records.py @@ -65,7 +65,7 @@ def main(): ## folder = st.storage[0].find(st.key_for(run_id, "raw_records"), fuzzy_for="raw_records")[1] md = st.get_metadata(run_id, "raw_records") - metadata_fn = os.path.join(folder, strax.dirname_to_prefix(folder) + "-metadata.json") + metadata_fn = os.path.join(folder, strax.RUN_METADATA_PATTERN % strax.dirname_to_prefix(folder)) assert osp.exists(metadata_fn) dtype = np.dtype(literal_eval(md["dtype"])) record_length = strax.record_length_from_dtype(dtype) diff --git a/straxen/storage/rucio_local.py b/straxen/storage/rucio_local.py index d4b69f290..eda234c64 100644 --- a/straxen/storage/rucio_local.py +++ b/straxen/storage/rucio_local.py @@ -145,7 +145,7 @@ def __init__(self, rucio_dir, *args, **kwargs): def _get_metadata(self, did: str, **kwargs): scope, name = did.split(":") number, dtype, hsh = parse_rucio_did(did) - metadata_json = f"{dtype}-{hsh}-metadata.json" + metadata_json = strax.RUN_METADATA_PATTERN % f"{dtype}-{hsh}" metadata_did = f"{scope}:{metadata_json}" metadata_path = rucio_path(self.rucio_dir, metadata_did) diff --git a/straxen/storage/rucio_remote.py b/straxen/storage/rucio_remote.py index 5e687dacc..508f77ff4 100644 --- a/straxen/storage/rucio_remote.py +++ b/straxen/storage/rucio_remote.py @@ -123,7 +123,7 @@ def _get_metadata(self, dset_did, **kwargs): rse = admix.downloader.determine_rse(rses) self.dset_cache[dset_did] = rse - metadata_did = f"{dset_did}-metadata.json" + metadata_did = strax.RUN_METADATA_PATTERN % dset_did downloaded = admix.download(metadata_did, rse=rse, location=self.staging_dir) if len(downloaded) != 1: raise ValueError(f"{metadata_did} should be a single file. We found {len(downloaded)}.") diff --git a/tests/storage/test_rucio_local.py b/tests/storage/test_rucio_local.py index 4ab3bd4c1..08508375a 100644 --- a/tests/storage/test_rucio_local.py +++ b/tests/storage/test_rucio_local.py @@ -88,7 +88,7 @@ def write_test_data(self): @staticmethod def write_md(rucio_path, did, content: dict): - md_did = f"{did}-metadata.json" + md_did = strax.RUN_METADATA_PATTERN % did md_path = straxen.storage.rucio_local.rucio_path(rucio_path, md_did) os.makedirs(os.path.split(md_path)[0], exist_ok=True) with open(md_path, mode="w") as f: