-
Notifications
You must be signed in to change notification settings - Fork 8
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
monkeypatching... #49
base: main
Are you sure you want to change the base?
Conversation
Thanks @ltalirz, I'll play around with this a bit next week. |
all tests but one already pass let's see whether we can avoid copy-pasting the function next
f006a71
to
d3d3bdd
Compare
replacing the copy of 'submit_calculation' with a call to the unpatched function
start working on monkeypatch of retrieve
@ltalirz I've thought a little bit about how / why the monkeypatching works. While I'm not 100% sure about it, I think it only works because whatever runs the calculation doesn't have a direct reference to the A related an possibly more important point is that starting a separate Python process means the monkeypatch is gone. As such, we would have to hook into the daemon startup in a more intrusive way to get |
Right, that would be a limitation. I personally always use
I think in many cases, one could avoid this by raising an appropriate exception - either at the submit stage (if a necessary code is missing) or at the parsing stage (e.g. by patching in some additional checks) |
I've used |
I was actually a bit puzzled why the tests passed, because the hash produced by Maybe there's also a flaw in our testing hidden somewhere in here. |
@ltalirz I think the next bigger thing to do here now is figuring out why the exceptions don't work as expected. I'm not totally convinced yet that it's not due to the exponential backoff mechanism. At the very least, when I simply try raising an error it does end up in the Side note: It would be useful if we implemented a |
That is a great suggestion, and perhaps quite straightforward to implement (?) Happy to review a PR for it :-)
Nothing fancy, I just hardcoded max_attempts to 1 here: |
Yep, I already have it implemented (well, the reverse option) in
Ah, I think the problem might then be that the process goes into |
By raising an exception derived directly from However, then the subsequent test runs into Maybe @sphuber knows how to cleanly put a calculation into excepted state from EDIT: maybe |
Note that we now added a configuration option for this so you can do
If you are talking about the Edit:
The standard behavior of If you want to raise an exception that is ignored by the EBM, you can derive it of |
We're not really bypassing the engine as such, instead we're monkeypatching the The purpose of raising an error though would be to give a clearer error message when this caching fails, and there isn't a fallback executable configured. So the ideal case would be that the exception bubbles up all the way to Raising |
Sorry for interleaving a separate discussion here; regarding
Generally I think we want to keep the information associated to the
Aside from the lookup of the code, are there other concerns to putting things in the extras? Note that now I'm also storing stuff in the calculation extras, to communicate between the |
I guess this is technically true, since anyone can change the |
Yeeah.. I feel we solve this particular problem when / if we get there. |
Finally coming back to the question of the exception handling. @ltalirz mentioned that he is sure that the observed undesired behavior of an exception being raised causing the tests to hang is not due to the EBM. However, @greschd seems to suggest that raising an exception that subclasses from |
I'll give that a go, thanks @sphuber! |
This PR illustrates how the
mock-code
executable can be monkey-patched into AiiDA's calculation submission (only the last commit)All but one tests pass - I suspect this is due to the hash having changed.
Besides general code improvements, there are a couple of open issues:
mock
to do this.calcnode.inputs.code
here, which is merely a convention, though