From 66ae0630e8a399111ab9fbbfa175ffa5dba1683e Mon Sep 17 00:00:00 2001 From: Piotr Kasprzyk <14312755+pkasprzyk@users.noreply.github.com> Date: Mon, 10 May 2021 17:34:21 +0200 Subject: [PATCH] handle boolean attribute in runs_table --- neptune/new/runs_table.py | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/neptune/new/runs_table.py b/neptune/new/runs_table.py index ed0800a4a..5ac5e88cd 100644 --- a/neptune/new/runs_table.py +++ b/neptune/new/runs_table.py @@ -13,15 +13,18 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import logging import uuid from datetime import datetime from typing import List, Dict, Optional, Union -from neptune.new.exceptions import MetadataInconsistency, InternalClientError +from neptune.new.exceptions import MetadataInconsistency from neptune.new.internal.backends.api_model import LeaderboardEntry, AttributeWithProperties, AttributeType from neptune.new.internal.backends.hosted_neptune_backend import HostedNeptuneBackend from neptune.new.internal.utils.paths import join_paths, parse_path +logger = logging.getLogger(__name__) + class RunsTableEntry: @@ -45,7 +48,10 @@ def get_attribute_value(self, path: str): _type = attr.type if _type == AttributeType.RUN_STATE: return attr.properties.value - if _type == AttributeType.FLOAT or _type == AttributeType.STRING or _type == AttributeType.DATETIME: + if _type in ( + AttributeType.FLOAT, AttributeType.INT, AttributeType.BOOL, + AttributeType.STRING, AttributeType.DATETIME, + ): return attr.properties.value if _type == AttributeType.FLOAT_SERIES or _type == AttributeType.STRING_SERIES: return attr.properties.last @@ -61,7 +67,11 @@ def get_attribute_value(self, path: str): return attr.properties.commit.commitId if _type == AttributeType.NOTEBOOK_REF: return attr.properties.notebookName - raise InternalClientError("Unsupported attribute type {}".format(_type)) + logger.error( + "Attribute type %s not supported in this version, yielding None. Recommended client upgrade.", + _type + ) + return None raise ValueError("Could not find {} attribute".format(path)) def download_file_attribute(self, path: str, destination: Optional[str]): @@ -124,7 +134,10 @@ def make_attribute_value(attribute: AttributeWithProperties) -> Optional[Union[s _properties = attribute.properties if _type == AttributeType.RUN_STATE: return _properties.value - if _type == AttributeType.FLOAT or _type == AttributeType.STRING or _type == AttributeType.DATETIME: + if _type in ( + AttributeType.FLOAT, AttributeType.INT, AttributeType.BOOL, + AttributeType.STRING, AttributeType.DATETIME, + ): return _properties.value if _type == AttributeType.FLOAT_SERIES or _type == AttributeType.STRING_SERIES: return _properties.last @@ -138,7 +151,11 @@ def make_attribute_value(attribute: AttributeWithProperties) -> Optional[Union[s return _properties.commit.commitId if _type == AttributeType.NOTEBOOK_REF: return _properties.notebookName - raise InternalClientError("Unsupported attribute type {}".format(_type)) + logger.error( + "Attribute type %s not supported in this version, yielding None. Recommended client upgrade.", + _type + ) + return None def make_row(entry: LeaderboardEntry) -> Dict[str, Optional[Union[str, float, datetime]]]: row: Dict[str, Union[str, float, datetime]] = dict()