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

Allow bson objects as job inputs, e.g. datetime.datetimes #375

Merged
merged 1 commit into from
Jul 21, 2023

Conversation

mcgalcode
Copy link
Contributor

@mcgalcode mcgalcode commented Jul 21, 2023

Summary

Adds the allow_bson=True kwarg to the jsanitize invocation in contains_job_or_flow utility function, and a corresponding test case. I recently tried to pass an object containing a datetime.datetime in it as an input to a job (specifically, the object was an emmet TaskDoc. This object was the output of another job (and I had retrieved it from the jobstore).

I noticed that every other invocation of jsanitize in the codebase uses allow_bson=True, with the exception of the one in Job::as_dict, so I concluded that this might be a bug. Please feel free to close if this behavior is intentional! However, I think it's useful to allow things like datetimes as inputs (at least to allow the use of TaskDocs as input parameters).

Checklist

Work-in-progress pull requests are encouraged, but please put [WIP] in the pull request
title.

Before a pull request can be merged, the following items must be checked:

  • Code is in the standard Python style.
    The easiest way to handle this is to run the following in the correct sequence on
    your local machine. Start with running black on your new code. This will
    automatically reformat your code to PEP8 conventions and removes most issues. Then run
    pycodestyle, followed by flake8.
  • Docstrings have been added in theNumpy docstring format.
    Run pydocstyle on your code.
  • Type annotations are highly encouraged. Run mypy to
    type check your code.
  • Tests have been added for any new functionality or bug fixes.
  • All linting and tests pass.

Note that the CI system will run all the above checks. But it will be much more
efficient if you already fix most errors prior to submitting the PR. It is highly
recommended that you use the pre-commit hook provided in the repository. Simply
cp pre-commit .git/hooks and a check will be run prior to allowing commits.

@codecov
Copy link

codecov bot commented Jul 21, 2023

Codecov Report

Merging #375 (d3fa86f) into main (084c4a0) will not change coverage.
The diff coverage is 100.00%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #375   +/-   ##
=======================================
  Coverage   99.86%   99.86%           
=======================================
  Files          19       19           
  Lines        1439     1439           
  Branches      364      364           
=======================================
  Hits         1437     1437           
  Misses          1        1           
  Partials        1        1           
Impacted Files Coverage Δ
src/jobflow/utils/find.py 100.00% <100.00%> (ø)

Copy link
Member

@janosh janosh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mcgalcode for the fix! And extra credits for the test! 🙏 😄

@janosh janosh merged commit 649b157 into materialsproject:main Jul 21, 2023
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants