Skip to content

Commit

Permalink
Serialise as Boolean if operator is defined
Browse files Browse the repository at this point in the history
  • Loading branch information
Elias Benussi committed Jun 3, 2019
1 parent 2d4050c commit 3a605a9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion faculty/clients/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,9 @@ def _deserialize(self, value, attr, data, **kwargs):
return value

def _serialize(self, value, attr, obj, **kwargs):
if obj.by in {SingleFilterBy.PROJECT_ID, SingleFilterBy.RUN_ID}:
if obj.operator == SingleFilterOperator.DEFINED:
field = fields.Boolean()
elif obj.by in {SingleFilterBy.PROJECT_ID, SingleFilterBy.RUN_ID}:
field = fields.UUID()
elif obj.by == SingleFilterBy.EXPERIMENT_ID:
field = fields.Integer()
Expand Down
11 changes: 11 additions & 0 deletions tests/clients/test_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,16 @@ def test_experiment_run_data_schema_multiple():
"value": DELETED_AT_STRING_PYTHON,
}

DELETED_FILTER = SingleFilter(
SingleFilterBy.DELETED_AT, None, SingleFilterOperator.DEFINED, True
)
DELETED_FILTER_BODY = {
"by": "deletedAt",
"key": None,
"operator": "defined",
"value": True,
}

TAG_FILTER = SingleFilter(
SingleFilterBy.TAG, "tag_key", SingleFilterOperator.EQUAL_TO, "tag_value"
)
Expand Down Expand Up @@ -488,6 +498,7 @@ def test_experiment_run_data_schema_multiple():
[EXPERIMENT_ID_FILTER, EXPERIMENT_ID_FILTER_BODY],
[RUN_ID_FILTER, RUN_ID_FILTER_BODY],
[DELETED_AT_FILTER, DELETED_AT_FILTER_BODY],
[DELETED_FILTER, DELETED_FILTER_BODY],
[TAG_FILTER, TAG_FILTER_BODY],
[PARAM_NUM_FILTER, PARAM_NUM_FILTER_BODY],
[PARAM_TEXT_FILTER, PARAM_TEXT_FILTER_BODY],
Expand Down

0 comments on commit 3a605a9

Please sign in to comment.