-
Notifications
You must be signed in to change notification settings - Fork 79
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
ENH: add global meta data #873
base: main
Are you sure you want to change the base?
Conversation
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 looks like a good start to me.
Generator.rng = default_rng(seed) | ||
global_meta_data.add_to_meta_data("rng", Generator.rng) |
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.
Is using this method instead of just doing global_meta_data[key] = value
required, or some convention I haven't come across before?
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.
I thought we may want to add some form of check/validation when adding values, so this would make it easier in future. Happy to revert to something simpler though
@@ -11,7 +11,11 @@ class Generator: | |||
|
|||
|
|||
def seed(seed): | |||
from .meta_data import global_meta_data |
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.
We don't necessarily have to hide these imports, the meta data will be initialized at import time anyway, 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.
I was running into circular imports but that may have been an old thing, I'll have a look
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.
Yeah, if I make this a top-level import, then I hit circular import issues. I think this is because everything is imported in the __init__.py
files in bilby
, bilby.core
and bilby.core.utils
. We could make an exception for meta_data
file.
The tests are going to fail until #867 is merged, since it adds support for properly saving the |
Based on the discussion in #867, I've made a start on a possible implementation of a global meta data object.
For now, it's just a singleton dictionary that, by default, tracks the
rng
. Things like thecosmology
can then be added when they're set.I still need to test this properly, but hopefully it gives us something to discuss.