diff --git a/straxen/storage/mongo_storage.py b/straxen/storage/mongo_storage.py index d86563500..07024c975 100644 --- a/straxen/storage/mongo_storage.py +++ b/straxen/storage/mongo_storage.py @@ -260,8 +260,8 @@ def __init__(self, store_files_at=None, *args, **kwargs): # either specified by the user or we use these defaults: if store_files_at is None: store_files_at = ( - "/tmp/straxen_resource_cache/", "./resource_cache", + "/tmp/straxen_resource_cache", ) elif not isinstance(store_files_at, (tuple, str, list)): raise ValueError(f"{store_files_at} should be tuple of paths!") diff --git a/straxen/storage/rundb.py b/straxen/storage/rundb.py index 5dfca822c..9f1b269a6 100644 --- a/straxen/storage/rundb.py +++ b/straxen/storage/rundb.py @@ -26,7 +26,14 @@ class RunDB(strax.StorageFrontend): storage_type = strax.StorageType.LOCAL # Dict of alias used in rundb: regex on hostname - hosts = {"dali": r"^dali.*rcc.*|^midway2.*rcc.*|^midway.*rcc.*|fried.rice.edu"} + hosts = { + "dali": r"^dali.*rcc.*|fried.rice.edu", + "midway": r"^midway2.*rcc.*|^midway.*rcc.*", + } + userdisks = { + "UC_DALI_USERDISK": r"^dali.*rcc.*|fried.rice.edu", + "UC_MIDWAY_USERDISK": r"^midway2.*rcc.*|^midway.*rcc.*", + } provide_run_metadata = True progress_bar = False @@ -126,18 +133,20 @@ def __init__( if re.match(regex, self.hostname): self.available_query.append({"host": host_alias}) - # When querying for rucio, add that it should be dali-userdisk (when on dali) + # When querying for rucio, add that it should be sparsed by the hostname if self.rucio_path is not None and any( re.match(regex, self.hostname) for regex in self.hosts.values() ): - self.backends.append(RucioLocalBackend(self.rucio_path)) - self.available_query.append( - { - "host": "rucio-catalogue", - "location": "UC_DALI_USERDISK", - "status": "transferred", - } - ) + for host_alias, regex in self.userdisks.items(): + if re.match(regex, self.hostname): + self.backends.append(RucioLocalBackend(self.rucio_path)) + self.available_query.append( + { + "host": "rucio-catalogue", + "location": host_alias, + "status": "transferred", + } + ) def _data_query(self, key): """Return MongoDB query for data field matching key.""" diff --git a/straxen/test_utils.py b/straxen/test_utils.py index 4e0fc18e8..8026f3ac9 100644 --- a/straxen/test_utils.py +++ b/straxen/test_utils.py @@ -68,6 +68,11 @@ def _is_on_pytest(): return "PYTEST_CURRENT_TEST" in os_environ +@export +def mongo_uri_not_set(): + return "TEST_MONGO_URI" not in os.environ + + def _get_fake_daq_reader(): class DAQReader(straxen.DAQReader): """Dummy version of the DAQ reader to make sure that all the testing data produced here will diff --git a/tests/storage/test_database_frontends.py b/tests/storage/test_database_frontends.py index bede1e443..e425cde3b 100644 --- a/tests/storage/test_database_frontends.py +++ b/tests/storage/test_database_frontends.py @@ -8,11 +8,7 @@ import pymongo import datetime import socket -from straxen import RunDB - - -def mongo_uri_not_set(): - return "TEST_MONGO_URI" not in os.environ +from straxen import RunDB, mongo_uri_not_set @unittest.skipIf(mongo_uri_not_set(), "No access to test database") @@ -66,6 +62,7 @@ class RunDBTestLocal(RunDB): """Change class to mathc current host too.""" hosts = {"bla": f"{socket.getfqdn()}"} + userdisks = {"BLA_USERDISK": f"{socket.getfqdn()}"} cls.rundb_sf_with_current_host = RunDBTestLocal( readonly=False, @@ -199,7 +196,7 @@ def test_rucio_format(self): rd["data"] = [ { "host": "rucio-catalogue", - "location": "UC_DALI_USERDISK", + "location": "BLA_USERDISK", "status": "transferred", "did": did, "number": int(rucio_id), diff --git a/tests/storage/test_mongo_downloader.py b/tests/storage/test_mongo_downloader.py index a92d65860..7a314ebc5 100644 --- a/tests/storage/test_mongo_downloader.py +++ b/tests/storage/test_mongo_downloader.py @@ -2,10 +2,7 @@ import straxen import os import pymongo - - -def mongo_uri_not_set(): - return "TEST_MONGO_URI" not in os.environ +from straxen import mongo_uri_not_set @unittest.skipIf(mongo_uri_not_set(), "No access to test database")