Skip to content

Commit

Permalink
7.6/n: Set db_id on user-facing classes in fb-only save functions
Browse files Browse the repository at this point in the history
Summary: Applying `_set_db_ids` to fb-only functions

Reviewed By: ldworkin

Differential Revision: D24788807

fbshipit-source-id: cfa2b5d75bed8aa68ac4ebd316f53295b1d47e18
  • Loading branch information
lena-kashtelyan authored and facebook-github-bot committed Nov 12, 2020
1 parent 9bc0d13 commit e21e159
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ax/utils/common/equality.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ def object_attribute_dicts_equal(


def object_attribute_dicts_find_unequal_fields(
one_dict: Dict[str, Any], other_dict: Dict[str, Any], fast_return: bool = True
one_dict: Dict[str, Any],
other_dict: Dict[str, Any],
fast_return: bool = True,
skip_db_id_check: bool = False,
) -> Tuple[Dict[str, Tuple[Any, Any]], Dict[str, Tuple[Any, Any]]]:
"""Utility for finding out what attributes of two objects' attribute dicts
are unequal.
Expand Down Expand Up @@ -136,6 +139,11 @@ def object_attribute_dicts_find_unequal_fields(
if field == "_experiment":
# prevent infinite loop when checking equality of Trials
equal = one_val is other_val is None or (one_val._name == other_val._name)
elif field == "analysis_scheduler":
# prevent infinite loop when checking equality of analysis runs
equal = one_val is other_val is None or (one_val.db_id == other_val.db_id)
elif field == "_db_id":
equal = skip_db_id_check or one_val == other_val
elif field == "_model": # pragma: no cover (tested in modelbridge)
# TODO[T52643706]: replace with per-`ModelBridge` method like
# `equivalent_models`, to compare models more meaningfully.
Expand Down

0 comments on commit e21e159

Please sign in to comment.