-
Notifications
You must be signed in to change notification settings - Fork 882
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
Fix timeout in command_line.enumlib_caller.EnumlibAdaptor
#4276
Fix timeout in command_line.enumlib_caller.EnumlibAdaptor
#4276
Conversation
b980d67
to
6947ffc
Compare
with pytest.raises(TimeoutError, match="Enumeration took too long"): | ||
adaptor._run_multienum() |
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.
The original test command is incorrect, a bare _run_multienum
doesn't generate the necessary input files, and _gen_input_file
is needed (therefore Fortran runtime error: Cannot open file 'struct_enum.in': No such file or directory
), so perhaps just use run
instead.
After fixing this, the run time on my local Apple M4 machine is around 0.04 s
Hi @fraricci sorry for the late response, can you help me test if this patch works? I don't have a "slow enough" enumlib job to test with (the unit test job last only 0.04 s and I'm not sure if it's really validating the behaviour), thanks a lot! |
Hey @DanielYang59, I just saw your fix here. Sure I can test it on my structure if still needed. |
Sure, please have a try and let me know whether the fix works for you |
I tested and still it does not work. Also, a version that uses
I think we need to kill the process inside the except. |
Hi thanks for testing. I cannot really say for sure because I haven't really used In this case is it possible to share the structure and code for me to recreate this? |
Yeah, I think enum.x is not responding as other commands do. The code is yours with some print lines as in the example above. Let me know what you find, thanks! |
I guess I might be missing something (as I didn't share any code before). I tried the following script and seem to get another error (looks like the from pymatgen.core import Structure
from pymatgen.command_line.enumlib_caller import EnumlibAdaptor
struct = Structure.from_file("./POSCAR_mp-1218641.txt")
adaptor = EnumlibAdaptor(struct, enum_precision_parameter=0.01, timeout=5)
# Expect TimeoutError
adaptor.run()
Can you share a code snippet for me to recreate this? Thanks! |
I see, calling the EnumlibAdapter on that structure does not work.
Note: you need the other fix to get the timout arg passed correctly to the EnumlibAdapter. Let me know how that goes. |
Great! Really appreciate the code snippet! I just had a look but I don't think that code snippet is enough to recreate the issue. In my case, the total runtime of the entire script (at around 150 seconds) is indeed longer than the I guess we'd be much better off to have a code snnipet that could isolate this issue (the above code is a super high level wrapper and I also did a quick line profiling of the script:
I didn't go further than this as it's already unrelated to |
Thanks for pointing out that the bottleneck might be not the enumeration but the "duplicate_checker" step.
This should take enough time and reveals that the current implementation is actually working, but still missing the process.terminate()/kill() in the exception (as mentioned above). Let me know what you find and we can close this I think. |
Beautiful! I could now recreate this issue (it's super helpful)! Looks like I tested and seem to work on my side, can you have a try? |
@fraricci Can I have your permission to include the |
Good news, glad it helped out testing correctly this issue. If you can also change the error message as I mentioned above, that could be great. Thanks! |
Great to know. You could directly checkout my branch (no need to manually apply the change)
Happy to change, but I'm not seeing anything related to this? |
a6e7c4f
to
a70c8bf
Compare
It was just easier to add one line than go through updating branch ;-) I mentioned this in a message above:
|
Done! Super weird, I still couldn't find that message for some reason |
It's a review message and I see that it is "pending". Maybe that's why you can't see it. Anyway, thanks. It's good to go. |
That explains, you have to submit the review message otherwise people cannot see it: https://github.com/orgs/community/discussions/10369
No problem at all. Can never be done without your help :) |
Thanks all for the great bug fix! |
No problem at all! |
Summary
command_line.enumlib_caller.EnumlibAdaptor
, to fix Timeout in MagneticStructureEnumerator (and EnumlibAdaptor) does not work #4185Fortran runtime error: Cannot open file 'struct_enum.in': No such file or directory
)