Skip to content

log_metrics gives an exception when timestamp is specified #702

@alahiff

Description

@alahiff

This bug appears in 2.0.0a0.

With:

run.log_metrics({'random_number': 10*random.random()}, timestamp='2025-02-19 08:48:25.998963')

I get:

Traceback (most recent call last):
  File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/home/alahiff/client/20250219/venv/lib/python3.10/site-packages/simvue/factory/dispatch/queued.py", line 144, in run
    self._callback(_buffer, queue_label)
  File "/home/alahiff/client/20250219/venv/lib/python3.10/site-packages/simvue/run.py", line 438, in _dispatch_callback
    _metrics = Metrics.new(
  File "/home/alahiff/client/20250219/venv/lib/python3.10/site-packages/pydantic/_internal/_validate_call.py", line 38, in wrapper_function
    return wrapper(*args, **kwargs)
  File "/home/alahiff/client/20250219/venv/lib/python3.10/site-packages/pydantic/_internal/_validate_call.py", line 111, in __call__
    res = self.__pydantic_validator__.validate_python(pydantic_core.ArgsKwargs(args, kwargs))
pydantic_core._pydantic_core.ValidationError: 1 validation error for Metrics.new
metrics.0.timestamp
  Assertion failed, Invalid timestamp, expected form '%Y-%m-%dT%H:%M:%S.%f' [type=assertion_error, input_value='2025-02-19 08:48:25.998963', input_type=str]
    For further information visit https://errors.pydantic.dev/2.10/v/assertion_error

And with:

run.log_metrics({'random_number': 10*random.random()}, timestamp='2025-02-19T08:48:25.998963')

I get:

Traceback (most recent call last):
  File "/home/alahiff/client/20250219/run2.py", line 7, in <module>
    with Run() as run:
  File "/home/alahiff/client/20250219/venv/lib/python3.10/site-packages/simvue/run.py", line 279, in __exit__
    self._handle_exception_throw(exc_type, value, traceback)
  File "/home/alahiff/client/20250219/venv/lib/python3.10/site-packages/simvue/run.py", line 252, in _handle_exception_throw
    self.log_event(_event_msg)
  File "/home/alahiff/client/20250219/venv/lib/python3.10/site-packages/simvue/utilities.py", line 244, in wrapper
    return class_func(self, *args, **kwargs)
  File "/home/alahiff/client/20250219/venv/lib/python3.10/site-packages/simvue/run.py", line 100, in _wrapper
    return _function(self, *args, **kwargs)
  File "/home/alahiff/client/20250219/venv/lib/python3.10/site-packages/simvue/utilities.py", line 281, in wrapper
    return class_func(self, *args, **kwargs)
  File "/home/alahiff/client/20250219/venv/lib/python3.10/site-packages/pydantic/_internal/_validate_call.py", line 38, in wrapper_function
    return wrapper(*args, **kwargs)
  File "/home/alahiff/client/20250219/venv/lib/python3.10/site-packages/pydantic/_internal/_validate_call.py", line 111, in __call__
    res = self.__pydantic_validator__.validate_python(pydantic_core.ArgsKwargs(args, kwargs))
  File "/home/alahiff/client/20250219/venv/lib/python3.10/site-packages/simvue/run.py", line 1162, in log_event
    self._dispatcher.add_item(_data, "events", self._queue_blocking)
  File "/home/alahiff/client/20250219/venv/lib/python3.10/site-packages/simvue/factory/dispatch/queued.py", line 80, in add_item
    raise RuntimeError(
RuntimeError: Cannot append item '{'message': 'Traceback (most recent call last):\n\n  File "/home/alahiff/client/20250219/run2.py", line 13, in <module>\n    run.log_metrics({\'random_number\': 10*random.random()}, timestamp=\'2025-02-19T08:48:25.998963\')\n\n  File "/home/alahiff/client/20250219/venv/lib/python3.10/site-packages/simvue/utilities.py", line 244, in wrapper\n    return class_func(self, *args, **kwargs)\n\n  File "/home/alahiff/client/20250219/venv/lib/python3.10/site-packages/simvue/run.py", line 100, in _wrapper\n    return _function(self, *args, **kwargs)\n\n  File "/home/alahiff/client/20250219/venv/lib/python3.10/site-packages/simvue/utilities.py", line 281, in wrapper\n    return class_func(self, *args, **kwargs)\n\n  File "/home/alahiff/client/20250219/venv/lib/python3.10/site-packages/pydantic/_internal/_validate_call.py", line 38, in wrapper_function\n    return wrapper(*args, **kwargs)\n\n  File "/home/alahiff/client/20250219/venv/lib/python3.10/site-packages/pydantic/_internal/_validate_call.py", line 111, in __call__\n    res = self.__pydantic_validator__.validate_python(pydantic_core.ArgsKwargs(args, kwargs))\n\n  File "/home/alahiff/client/20250219/venv/lib/python3.10/site-packages/simvue/run.py", line 1237, in log_metrics\n    add_dispatch = self._add_metrics_to_dispatch(\n\n  File "/home/alahiff/client/20250219/venv/lib/python3.10/site-packages/simvue/run.py", line 1196, in _add_metrics_to_dispatch\n    self._error("Invalid timestamp format", join_on_fail)\n\n  File "/home/alahiff/client/20250219/venv/lib/python3.10/site-packages/simvue/run.py", line 543, in _error\n    raise SimvueRunError(message)\n\nsimvue.exception.SimvueRunError: Invalid timestamp format\n', 'timestamp': '2025-02-19T08:51:51.861031'}' to queue 'events', termination called.

Metadata

Metadata

Assignees

Labels

ready for testingThis issue has been fixed and is ready for testing

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions