Skip to content

AttributeError: 'NoneType' object has no attribute 'info' when reset (R) is used multiple times. #16

Description

@jnzhao3

Error Message

When logging demonstrations with the --log_dir flag,

Traceback (most recent call last):
  File "/home/moma/distill_rl2g/utils/teleop.py", line 298, in <module>
    logger.close()
  File "/home/moma/oxe_envlogger/oxe_envlogger/rlds_logger.py", line 166, in close
    self.writer._write_and_reset_episode()
  File "/home/moma/anaconda3/envs/serl/lib/python3.10/site-packages/envlogger/backends/tfds_backend_writer.py", line 105, in _write_and_reset_episode
    self._sequential_writer.add_examples(
  File "/home/moma/anaconda3/envs/serl/lib/python3.10/site-packages/tensorflow_datasets/core/sequential_writer.py", line 336, in add_examples
    serialized_example = _serialize_example(
  File "/home/moma/anaconda3/envs/serl/lib/python3.10/site-packages/tensorflow_datasets/core/sequential_writer.py", line 44, in _serialize_example
    py_utils.reraise(
  File "/home/moma/anaconda3/envs/serl/lib/python3.10/site-packages/tensorflow_datasets/core/sequential_writer.py", line 42, in _serialize_example
    encoded_example = features.encode_example(example)
  File "/home/moma/anaconda3/envs/serl/lib/python3.10/site-packages/tensorflow_datasets/core/features/features_dict.py", line 243, in encode_example
    utils.reraise(
  File "/home/moma/anaconda3/envs/serl/lib/python3.10/site-packages/tensorflow_datasets/core/features/features_dict.py", line 241, in encode_example
    example[k] = feature.encode_example(example_value)
  File "/home/moma/anaconda3/envs/serl/lib/python3.10/site-packages/tensorflow_datasets/core/features/dataset_feature.py", line 143, in encode_example
    ds_elements = [
  File "/home/moma/anaconda3/envs/serl/lib/python3.10/site-packages/tensorflow_datasets/core/features/dataset_feature.py", line 144, in <listcomp>
    self.feature.encode_example(example) for example in dict_list
  File "/home/moma/anaconda3/envs/serl/lib/python3.10/site-packages/tensorflow_datasets/core/features/features_dict.py", line 243, in encode_example
    utils.reraise(
  File "/home/moma/anaconda3/envs/serl/lib/python3.10/site-packages/tensorflow_datasets/core/features/features_dict.py", line 241, in encode_example
    example[k] = feature.encode_example(example_value)
  File "/home/moma/anaconda3/envs/serl/lib/python3.10/site-packages/tensorflow_datasets/core/features/tensor_feature.py", line 234, in encode_example
    raise ValueError(
ValueError: Failed to encode example:
In <Dataset> with name "steps":
In <Tensor> with name "discount":
Dtype object do not match <class 'numpy.float32'>
{'steps': [{'action': array([0., 0., 0., 0., 0., 0., 0.], dtype=float32), 'discount': array(0, dtype=object), 'is_first': True, 'is_last': False, 'is_terminal': False, 'observation': {'image_primary': array([[[ 25,  29,  18],
        [ 24,  28,  17],
        [ 28,  30,  18],
        ...,
        [136, 140, 135],
        [136, 140, 135],
        [136, 140, 135]],

       [[ 24,  28,  17],
        [ 24,  28,  17],
        [ 26,  28,  16],
        ...,
        [135, 139, 134],
        [135, 139, 134],
        [135, 139, 134]],

       [[ 23,  27,  16],
        [ 25,  29,  18],
        [ 25,  27,  15],
        ...,
        [135, 139, 134],
        [134, 138, 133],
        [134, 138, 133]],

       ...,

       [[ 26,  27,  18],
        [ 21,  22,  13],
        [ 25,  26,  16],
        ...,
        [134, 135, 126],
        [136, 137, 128],
        [135, 136, 127]],

       [[ 25,  28,  19],
        [ 25,  28,  19],
        [ 22,  23,  14],
        ...,
        [134, 135, 126],
        [138, 139, 130],
        [134, 135, 126]],

       [[ 21,  24,  15],
        [ 23,  26,  17],
        [ 23,  24,  15],
        ...,
        [131, 132, 123],
        [135, 136, 127],
        [134, 135, 126]]], dtype=uint8), 'state': array([2.5884697e-01, 9.3984650e-04, 2.4771872e-01, 3.0632956e+00,
       1.5323242e+00, 3.0632887e+00, 0.0000000e+00, 6.7674702e-01],
      dtype=float32), 'image_wrist': array([[[  3,   8,  11],
        [ 51,  58,  61],
        [106, 115, 118],
        ...,
        [ 27,  39,  79],
        [ 31,  35,  88],
        [ 24,  25,  85]],

       [[  3,  10,  13],
        [ 11,  21,  21],
        [130, 142, 144],
        ...,
        [ 26,  36,  76],
        [ 24,  29,  78],
        [ 21,  23,  77]],

       [[  5,  15,  15],
        [  0,  11,   9],
        [123, 137, 136],
        ...,
        [ 21,  27,  70],
        [ 22,  25,  69],
        [ 18,  21,  65]],

       ...,

       [[  2,   1,   3],
        [  4,   3,   5],
        [  5,   4,   6],
        ...,
        [  3,   2,   4],
        [  2,   1,   3],
        [  1,   0,   2]],

       [[  1,   0,   2],
        [  2,   1,   3],
        [  2,   1,   3],
        ...,
        [  2,   1,   3],
        [  2,   1,   3],
        [  2,   1,   3]],

       [[  4,   3,   5],
        [  3,   2,   4],
        [  3,   2,   4],
        ...,
        [  2,   1,   3],
        [  2,   1,   3],
        [  2,   1,   3]]], dtype=uint8)}, 'reward': array(0, dtype=object), 'language_text': 'tap the sponge'}]}

Exception ignored in: <function RLDSLogger.__del__ at 0x7e456c7269e0>
Traceback (most recent call last):
  File "/home/moma/oxe_envlogger/oxe_envlogger/rlds_logger.py", line 174, in __del__
  File "/home/moma/oxe_envlogger/oxe_envlogger/rlds_logger.py", line 166, in close
  File "/home/moma/anaconda3/envs/serl/lib/python3.10/site-packages/envlogger/backends/tfds_backend_writer.py", line 106, in _write_and_reset_episode
  File "/home/moma/anaconda3/envs/serl/lib/python3.10/site-packages/envlogger/backends/tfds_backend_writer.py", line 45, in get_rlds_episode
AttributeError: 'NoneType' object has no attribute 'to_rlds_step'
Exception ignored in: <function BackendWriter.__del__ at 0x7e456dbb7640>
Traceback (most recent call last):
  File "/home/moma/anaconda3/envs/serl/lib/python3.10/site-packages/envlogger/backends/backend_writer.py", line 65, in __del__
  File "/home/moma/anaconda3/envs/serl/lib/python3.10/site-packages/envlogger/backends/tfds_backend_writer.py", line 125, in close
AttributeError: 'NoneType' object has no attribute 'info'

Fix

Error is the result of using reset (R) more than once. Data collection works fine when reset is only used once.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions