Skip to content

Type does not support attribute#

Error

TypeDoesNotSupportAttributeException: <object type> has no attribute <attribute>

Issue: You're trying to fetch or log metadata in a way that is not supported.

This exception is raised if you're operating on an existing field, which is already of a certain type, and the field doesn't support the operation you're using.

This situation can arise if:

  • You're logging a value to an existing field that is of a different type, or you're using a different logging method.
  • You're attempting to fetch metadata from a field, but the field type does not support the operation.
  • You're using the same code to log metadata to an existing field, but you've upgraded to a newer version of the client library. In this case, you might have been logging some type that was implicitly cast to String in versions 0.x of the Neptune client library.

    Learn more about this mechanism and what has changed in the neptune 1.0 upgrade guide.

Example

If you've logged a file with the upload() method, which creates a File field, you can't use the fetch_hash() method on the field.

>>> run["file"].upload("my_file.csv")
>>> run["file"].fetch_hash()
...
----TypeDoesNotSupportAttributeException---------------------------------------- 

<class 'neptune.attributes.atoms.file.File'> has no attribute fetch_hash.

In this case, only the Artifact field (created with track_files()) supports the fetch_hash() method.

Also note that in versions older than 0.16.14, you can only use log() to log values as a series. As of 0.16.14, append() and extend() are available as replacements.

Solution#

Check whether your operation is supported for the field type you're interacting with.

You can browse how field types are created and what methods you can use for them in the Field types reference.

You can find out the type of a given field by accessing the values returned by the get_structure() method:

Getting the type of a regular field
>>> type(run.get_structure()["f1_score"]).__name__
'Float'
Getting the type of a nested field
>>> type(run.get_structure()["sys"]["state"]).__name__
'RunState'

Tip

To help locate the problem in your code, try initializing Neptune in synchronous mode:

import neptune

run = neptune.init_run(mode="sync")

Related

Getting help