Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to the RunDB frontend for rucio #164

Merged
merged 11 commits into from
Aug 17, 2020
3 changes: 2 additions & 1 deletion straxen/contexts.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ def xenonnt_online(output_folder='./strax_data',
straxen.RunDB(
readonly=not we_are_the_daq,
runid_field='number',
new_data_path=output_folder),
new_data_path=output_folder,
rucio_path='/dali/lgrandi/rucio/'),
],
config=straxen.contexts.xnt_common_config,
**context_options)
Expand Down
21 changes: 20 additions & 1 deletion straxen/rundb.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def __init__(self,
local_only=False,
new_data_path=None,
reader_ini_name_is_mode=False,
rucio_path=None,
*args, **kwargs):
"""
:param mongo_url: URL to Mongo runs database (including auth)
Expand All @@ -66,6 +67,7 @@ def __init__(self,
self.new_data_path = new_data_path
self.reader_ini_name_is_mode = reader_ini_name_is_mode
self.minimum_run_number = minimum_run_number
self.rucio_path = rucio_path
if self.new_data_path is None:
self.readonly = True
self.runid_field = runid_field
Expand Down Expand Up @@ -108,6 +110,8 @@ def __init__(self,
strax.S3Backend(**s3_kwargs),
strax.FileSytemBackend(),
]
if self.rucio_path is not None:
self.backends.append(strax.rucio(self.rucio_path))

# Construct mongo query for runs with available data.
# This depends on the machine you're running on.
Expand Down Expand Up @@ -139,9 +143,24 @@ def _find(self, key: strax.DataKey,
run_query = {'name': str(key.run_id)}
else:
run_query = {'number': int(key.run_id)}

# Check that we are in rucio backend
if self.rucio_path is not None:
dq = {
'data': {
'$elemMatch': {
'type': key.data_type,
'protocol': 'rucio'}}}
doc = self.collection.find_one({**run_query, **dq},
projection=dq)
if doc is not None:
datum = doc['data'][0]
return datum['protocol'], str(key.run_id) + '-' + datum['did'].split(':')[1]

dq = self._data_query(key)
doc = self.collection.find_one({**run_query, **dq},
projection=dq)
projection=dq)

if doc is None:
# Data was not found
if not write:
Expand Down