Skip to content
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 handling of function from standard library #516

Merged
merged 1 commit into from
Jan 7, 2024

Conversation

gpetretto
Copy link
Contributor

Summary

I was trying to use a function from the standard library to create a simple example and I got an error:

import time
from jobflow import Job, SETTINGS

j = Job(time.sleep, (1,))
j.run(SETTINGS.JOB_STORE)

gives

TypeError: time.sleep() takes exactly one argument (2 given)

The reason is that sleep has a __self__ attribute and in Job it is then converted to a bound method. This seems to be shared by most (all?) the functions in the standard library.

To adress this I changed the check performed in Job.run() assuming that if the __self__ is a module, than the callable should not be converted to a method. I am not entirely sure if I may be missing some case where this is not true.

@utf
Copy link
Member

utf commented Jan 7, 2024

Thanks @gpetretto

@utf utf merged commit c60b8d0 into materialsproject:main Jan 7, 2024
7 checks passed
@utf utf added the fix Bug fix label Jan 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants