-
Notifications
You must be signed in to change notification settings - Fork 189
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
Decide behavior when storing Data
sub classes within __main__
#3457
Comments
I don't think there's a way to make this work from interactive scripts, right? When it's just a script, in principle the script could be imported as a module - but that assumes it's properly segregated into the "script" and "module" parts with If we try to get the module name in that case with
you get the right file when running it with bare python, but Maybe the better option is to check that a class is importable when storing? |
I think the question should rather be exactly whether we allow even storing this. If we do, then we should add a fall-back in the loader, to just load a base |
In general, is there a fallback to If it's just about this specific case, I'd probably favor not allowing the store. |
We cannot fallback on |
Isn't the problem similar to what happens to a node when trying to open it in an AiiDA installation that does not have that particular plugin installed / if the class was renamed? What happens in that case? |
I think we should be as lenient as possible when loading (with possibly a warning), but can be more strict when storing. When you already have data that doesn't have a matching class it's better to have some access to it than not being able to load it at all, but creating such data should be strongly discouraged. |
The difference is that any node that was generated with a class that was valid at the time and had a proper entry point, will have a correct type string, e.g. will start with |
Since the current version allows creating such nodes, I think the warning + fallback would be the better choice. |
Consider the following:
This will store the node just fine, but its
node_type
will be__main__.SubData.
if performed in a script or interactive shell. Loading the node will fail though, without a fallback:will raise
The text was updated successfully, but these errors were encountered: