Skip to content

Commit

Permalink
handle boolean attribute in runs_table
Browse files Browse the repository at this point in the history
  • Loading branch information
pkasprzyk authored May 10, 2021
1 parent 3ffed36 commit 66ae063
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions neptune/new/runs_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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
Expand All @@ -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]):
Expand Down Expand Up @@ -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
Expand All @@ -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()
Expand Down

0 comments on commit 66ae063

Please sign in to comment.