From 351bcf2d4bc854fae6a1417e8099be8df8fa442f Mon Sep 17 00:00:00 2001 From: Krzysztof Godlewski Date: Thu, 19 Sep 2024 14:54:41 +0200 Subject: [PATCH] Ignore unsupported fields when deserializing `QueryFieldsExperimentResult` from proto --- src/neptune/api/models.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/neptune/api/models.py b/src/neptune/api/models.py index 77479346e..bff32d838 100644 --- a/src/neptune/api/models.py +++ b/src/neptune/api/models.py @@ -634,6 +634,18 @@ class QueryFieldsExperimentResult: object_key: str fields: List[Field] + # Any field the type of which is not in this set will not be + # returned to the user. Applies to protobuf calls only. + PROTO_SUPPORTED_FIELD_TYPES = { + FieldType.STRING.value, + FieldType.BOOL.value, + FieldType.INT.value, + FieldType.FLOAT.value, + FieldType.DATETIME.value, + FieldType.STRING_SET.value, + FieldType.FLOAT_SERIES.value, + } + @staticmethod def from_dict(data: Dict[str, Any]) -> QueryFieldsExperimentResult: return QueryFieldsExperimentResult( @@ -655,7 +667,11 @@ def from_proto(data: Any) -> QueryFieldsExperimentResult: return QueryFieldsExperimentResult( object_id=data.experimentId, object_key=data.experimentShortId, - fields=[Field.from_proto(field) for field in data.attributes], + fields=[ + Field.from_proto(field) + for field in data.attributes + if field.type in QueryFieldsExperimentResult.PROTO_SUPPORTED_FIELD_TYPES + ], )