diff --git a/CHANGELOG.md b/CHANGELOG.md index ea4821aeb..e2ab8fa7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ## [Development] +## [0.33.8 - 2024-04-30] + +### Added + +* Fix from_json when json object contains predicates. + ## [0.33.7 - 2024-04-06] * Fix refresh() for SSO diff --git a/graphistry/compute/ast.py b/graphistry/compute/ast.py index c1e7b4e04..d478c23f2 100644 --- a/graphistry/compute/ast.py +++ b/graphistry/compute/ast.py @@ -10,6 +10,8 @@ from graphistry.util import setup_logger from graphistry.utils.json import JSONVal, is_json_serializable from .predicates.ASTPredicate import ASTPredicate +from .predicates.from_json import from_json as predicates_from_json + from .predicates.is_in import ( is_in, IsIn ) @@ -100,7 +102,7 @@ def maybe_filter_dict_from_json(d: Dict, key: str) -> Optional[Dict]: return None if key in d and isinstance(d[key], dict): return { - k: ASTPredicate.from_json(v) if isinstance(v, dict) else v + k: predicates_from_json(v) if isinstance(v, dict) else v for k, v in d[key].items() } elif key in d and d[key] is not None: diff --git a/graphistry/tests/compute/test_chain.py b/graphistry/tests/compute/test_chain.py index c685edb84..ea3fb232e 100644 --- a/graphistry/tests/compute/test_chain.py +++ b/graphistry/tests/compute/test_chain.py @@ -44,6 +44,19 @@ def test_chain_serialization_multi(): o2 = d.to_json() assert o == o2 +def test_chain_serialization_pred(): + o = Chain([n(query='zzz', name='abc', filter_dict={'a': is_in(options=['a', 'b', 'c'])}), + e(edge_query='zzz', name='abc', edge_match={'b': is_in(options=['a', 'b', 'c'])})]).to_json() + d = Chain.from_json(o) + assert isinstance(d.chain[0], ASTNode) + assert d.chain[0].query == 'zzz' + assert d.chain[0]._name == 'abc' + assert isinstance(d.chain[1], ASTEdge) + assert d.chain[1].edge_query == 'zzz' + assert d.chain[1]._name == 'abc' + o2 = d.to_json() + assert o == o2 + def test_chain_simple_cudf_pd(): nodes_df = pd.DataFrame({'id': [0, 1, 2], 'label': ['a', 'b', 'c']}) edges_df = pd.DataFrame({'src': [0, 1, 2], 'dst': [1, 2, 0]})