Skip to content

Commit

Permalink
Merge branch 'main' into flow-job-magic-methods
Browse files Browse the repository at this point in the history
  • Loading branch information
janosh committed Jul 29, 2023
2 parents 2a1d7f5 + befebb7 commit aadb604
Showing 6 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: jobflow Support Forum
url: https://matsci.org/c/fireworks
url: https://matsci.org/jobflow
about: Please ask and answer questions here.
9 changes: 8 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -38,11 +38,16 @@ dependencies = [
docs = [
"autodoc_pydantic==1.9.0",
"furo==2023.5.20",
"furo==2023.5.20",
"ipython==8.14.0",
"ipython==8.14.0",
"myst_parser==2.0.0",
"myst_parser==2.0.0",
"nbsphinx==0.9.2",
"nbsphinx==0.9.2",
"sphinx-copybutton==0.5.2",
"sphinx==6.2.0",
"sphinx==7.1.0",
]
dev = ["pre-commit>=2.12.1"]
tests = ["pytest-cov==4.1.0", "pytest==7.4.0"]
@@ -51,10 +56,12 @@ fireworks = ["FireWorks"]
strict = [
"FireWorks==2.0.3",
"PyYAML==6.0",
"PyYAML==6.0.1",
"maggma==0.51.18",
"maggma==0.51.24",
"matplotlib==3.7.2",
"monty==2023.5.8",
"moto==4.1.12",
"moto==4.1.13",
"networkx==3.1",
"pydantic==1.10.9",
"pydash==7.0.5",
2 changes: 1 addition & 1 deletion src/jobflow/core/job.py
Original file line number Diff line number Diff line change
@@ -1120,7 +1120,7 @@ def as_dict(self) -> dict:

# fireworks can't serialize functions and classes, so explicitly serialize to
# the job recursively using monty to avoid issues
return jsanitize(d, strict=True, enum_values=True)
return jsanitize(d, strict=True, enum_values=True, allow_bson=True)

def __setattr__(self, key, value):
"""Handle setting attributes. Implements a special case for job name."""
2 changes: 1 addition & 1 deletion src/jobflow/utils/find.py
Original file line number Diff line number Diff line change
@@ -213,7 +213,7 @@ def contains_flow_or_job(obj: Any) -> bool:
# argument is a primitive, we won't find an flow or job here
return False

obj = jsanitize(obj, strict=True)
obj = jsanitize(obj, strict=True, allow_bson=True)

# recursively find any reference classes
locations = find_key_value(obj, "@class", "Flow")
5 changes: 4 additions & 1 deletion tests/core/test_job.py
Original file line number Diff line number Diff line change
@@ -558,12 +558,15 @@ class MySchema(BaseModel):

def test_serialization():
import json
from datetime import datetime

from monty.json import MontyDecoder, MontyEncoder

from jobflow import Job

test_job = Job(function=add, function_args=(1,), function_kwargs={"b": 2})
test_job = Job(
function=add, function_args=(1, datetime.now()), function_kwargs={"b": 2}
)

uuid = test_job.uuid

3 changes: 3 additions & 0 deletions tests/utils/test_find.py
Original file line number Diff line number Diff line change
@@ -54,6 +54,8 @@ def test_update_in_dictionary():


def test_contains_job_or_flow():
from datetime import datetime

from jobflow import Flow, Job
from jobflow.utils import contains_flow_or_job

@@ -74,3 +76,4 @@ def test_contains_job_or_flow():
assert contains_flow_or_job([[job]]) is True
assert contains_flow_or_job({"a": job}) is True
assert contains_flow_or_job({"a": [job]}) is True
assert contains_flow_or_job({"a": [job], "b": datetime.now()}) is True

0 comments on commit aadb604

Please sign in to comment.