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
XENON RunDB Frontend #100
XENON RunDB Frontend #100
Conversation
I just realized: this PR also includes a cleanup and fix of the S3 interface. |
super().__init__(*args, **kwargs) | ||
|
||
self.client = pymongo.MongoClient(mongo_url) | ||
self.collection = self.client['xenon1t']['runs'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is one use.
strax/xenon/rundb.py
Outdated
if fuzzy_for or fuzzy_for_options: | ||
raise NotImplementedError("Can't do fuzzy with S3") | ||
|
||
query = {'name': key.run_id, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is another.
To understand this correctly, strax only queries for the location of the data of a certain type? |
At present, yes. Writing to the RunDB will be more centralized I'm guessing (cax/snax) since not everybody needs to write. This will be more complicated and I can link there (just factored runDB calls into one place to make easier to replace). The real reason it doesn't write is because writing to the RunDB happens in multiple threads and we couldn't figure out how to do it just once (yet). @briedel |
@briedel We will probably add some more rundb calls later for fetching of run-level metadata and possibly some configuration. RunDB write support should come soon, but not in this first concept:
Even if we only use snax for writing, it's still useful to have write support in the strax frontend, to simplify snax's life. |
PR good? |
|
||
# Create bucket (does nothing if exists) | ||
self.s3.create_bucket(Bucket=BUCKET_NAME) | ||
# self.s3.create_bucket(Bucket=BUCKET_NAME) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this accidentally commented out or do we no longer need it?
try: | ||
self.backends[0].get_metadata(key) | ||
except ClientError as ex: | ||
if ex.response['Error']['Code'] == 'NoSuchKey': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you catch this in get_metadata and raise DataNotAvailable there? This would fix #90. (Then here, you'd catch DataNotAvailable again if you're writing.)
The S3 frontend is unusual in that _find
relies on get_metadata
rather than the other way around. But the context relies on DataNotAvailable being raised if get_metadata fails, so it can try other storage frontends (https://github.com/AxFoundation/strax/blob/master/strax/context.py#L632).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually it turns out #90 has already been fixed, so never mind.
class RunDB(strax.StorageFrontend): | ||
"""Frontend that searches RunDB MongoDB for data. | ||
|
||
Loads appropriate backends ranging from Files to S3. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add the caveats about writing you wrote in the PR here. If I remember correctly, writing is supported, but it doesn't get registered back in the rundb.
Also perhaps worth noting the chosen write backend is files if you're on dali and S3 otherwise (right?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I left a few comments that might be useful to look at (one would fix #90 I think), but feel free to merge.
(This is XENON-specific, still need to do #48)
This addresses Issue #73. There is a frontend that looks for data in a run database. Currently, no default is given, so the MongoURL has to be fed in. For example:
The way it works is by searching the RunDB for data of interest (this is the only RunDB call!). If a run document exists, then it tries to determine if it knows how to read it. S3 can be read anywhere. A fuzzy hacky match is used (like in hax) to determine if you're running on
dali
, where other XENON data is. At the moment, this interface cannot write RunDB aware. This is reserved for snax.This relies on a RunDB mirror hosted through MongoDB Atlas on Google Cloud Platform. Which data is available can also be seen here.