Skip to content

Unsupported type#

Error

NeptuneUnsupportedType: You're attempting to log a type that is not directly supported by Neptune (<type_of_the_object>).

Issue#

You're attempting to log a value or object of a type that is not yet directly supported by Neptune.

In 0.x versions of Neptune, unsupported types are implicitly cast to string without raising any warnings or exceptions. To avoid situations where your metadata is not logged as you expect, as of version 1.0, you need to explicitly log your value as a supported type. Otherwise, the unsupported value is skipped and Neptune prints a warning.

Workarounds#

In order to log your value or object to Neptune, you need to convert it to a supported type – such as a string or float.

Converting to string#

To convert your value or object, use some string representation method, such as str():

Does not work

>>> run["tuple"] = ("hi", 1)
<error>
>>> # tuple isn't supported

Works

>>> run["tuple"] = str(("hi", 1))
>>> run["tuple"]
<String field at "tuple">

Using stringify_unsupported()#

For more complex structures, you can use the utility function stringify_unsupported() to convert values of unsupported types to strings.

Does not work

>>> run["complex_dict"] = {"tuple": ("hi", 1), "metric": 0.87}
<warning>
>>> # Doesn't work because the tuple isn't a supported type

Works

>>> from neptune.utils import stringify_unsupported
>>> run["complex_dict"] = stringify_unsupported({"tuple": ("hi", 1), "metric": 0.87})
>>> run["complex_dict/tuple"]
<String field at "complex_dict/tuple">

Working around None, Inf or NaN#

Sometimes your metric may not be calculated correctly, which might result in the value None. Neptune will skip unsupported values when creating a series with append() or extend().

You can also

  • convert this value to for example 0 so that it can be logged to Neptune
  • add a check to filter out problematic values from your series:

    values = [...]
    for v in values:
        if not math.isinf(v) and not math.isnan(v):
            run["metric"].append(v)
    

Logging figures or charts#

The object type you're trying to log may not be directly supported by Neptune.

Try the following:

  • Convert the object to a supported format, such as a Matplotlib figure.
  • Upload the object as HTML:

    from neptune.types import File
    
    obj = ...  # Your chart or figure object
    run["visualization"].upload(File.as_html(obj))
    

Getting help