Skip to content

Project metadata collection fails in jupyter notebook #715

@wk9874

Description

@wk9874

Not sure why this is seemingly isolated to a juypter notebook with a pip installed simvue, but...

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[10], line 8
      4 import numpy
      6 with Run() as run:
      7     # Initialize a run on the server, optionally providing a name, tags, folder etc
----> 8     run.init(
      9         name="random-numbers-example-%d" % time.time(),
     10         tags=["example", "random-numbers"],
     11         folder="/examples",
     12     )
     14     # Initialise an empty array which expects integers to store our random numbers in
     15     all_numbers = numpy.array([], dtype=numpy.int64)  

File ~/.pyenv/versions/3.10.14/lib/python3.10/site-packages/simvue/utilities.py:245, in skip_if_failed.<locals>.decorator.<locals>.wrapper(self, *args, **kwargs)
    243 # Handle case where Pydantic validates the inputs
    244 try:
--> 245     return class_func(self, *args, **kwargs)
    246 except pydantic.ValidationError as e:
    247     error_str = parse_pydantic_error(e)

File ~/.pyenv/versions/3.10.14/lib/python3.10/site-packages/pydantic/_internal/_validate_call.py:38, in update_wrapper_attributes.<locals>.wrapper_function(*args, **kwargs)
     36 @functools.wraps(wrapped)
     37 def wrapper_function(*args, **kwargs):
---> 38     return wrapper(*args, **kwargs)

File ~/.pyenv/versions/3.10.14/lib/python3.10/site-packages/pydantic/_internal/_validate_call.py:111, in ValidateCallWrapper.__call__(self, *args, **kwargs)
    110 def __call__(self, *args: Any, **kwargs: Any) -> Any:
--> 111     res = self.__pydantic_validator__.validate_python(pydantic_core.ArgsKwargs(args, kwargs))
    112     if self.__return_pydantic_validator__:
    113         return self.__return_pydantic_validator__(res)

File ~/.pyenv/versions/3.10.14/lib/python3.10/site-packages/simvue/run.py:697, in Run.init(self, name, metadata, tags, description, folder, notification, running, retention_period, timeout, visibility, no_color)
    695 self._sv_obj.status = self._status
    696 self._sv_obj.tags = tags
--> 697 self._sv_obj.metadata = (metadata or {}) | git_info(os.getcwd()) | environment()
    698 self._sv_obj.heartbeat_timeout = timeout
    699 self._sv_obj.alerts = []

File ~/.pyenv/versions/3.10.14/lib/python3.10/site-packages/simvue/metadata.py:191, in environment(repository)
    189 def environment(repository: pathlib.Path = pathlib.Path.cwd()) -> dict[str, typing.Any]:
    190     """Retrieve environment metadata"""
--> 191     _environment_meta = flatdict.FlatDict(
    192         _python_env(repository), delimiter="."
    193     ).as_dict()
    194     _environment_meta |= flatdict.FlatDict(
    195         _rust_env(repository), delimiter="."
    196     ).as_dict()
    197     _environment_meta |= flatdict.FlatDict(
    198         _julia_env(repository), delimiter="."
    199     ).as_dict()

File ~/.pyenv/versions/3.10.14/lib/python3.10/site-packages/flatdict.py:29, in FlatDict.__init__(self, value, delimiter, dict_class)
     27 self._values = dict_class()
     28 self._delimiter = delimiter
---> 29 self.update(value)

File ~/.pyenv/versions/3.10.14/lib/python3.10/site-packages/flatdict.py:356, in FlatDict.update(self, other, **kwargs)
    343 def update(self, other=None, **kwargs):
    344     """Update the flat dictionary with the key/value pairs from other,
    345     overwriting existing keys.
    346 
   (...)
    354 
    355     """
--> 356     [self.__setitem__(k, v) for k, v in dict(other or kwargs).items()]

File ~/.pyenv/versions/3.10.14/lib/python3.10/site-packages/flatdict.py:356, in <listcomp>(.0)
    343 def update(self, other=None, **kwargs):
    344     """Update the flat dictionary with the key/value pairs from other,
    345     overwriting existing keys.
    346 
   (...)
    354 
    355     """
--> 356     [self.__setitem__(k, v) for k, v in dict(other or kwargs).items()]

File ~/.pyenv/versions/3.10.14/lib/python3.10/site-packages/flatdict.py:154, in FlatDict.__setitem__(self, key, value)
    151     elif not isinstance(self._values[pk], FlatDict):
    152         raise TypeError(
    153             'Assignment to invalid type for key {}'.format(pk))
--> 154     self._values[pk][ck] = value
    155 else:
    156     self._values[key] = value

File ~/.pyenv/versions/3.10.14/lib/python3.10/site-packages/flatdict.py:154, in FlatDict.__setitem__(self, key, value)
    151     elif not isinstance(self._values[pk], FlatDict):
    152         raise TypeError(
    153             'Assignment to invalid type for key {}'.format(pk))
--> 154     self._values[pk][ck] = value
    155 else:
    156     self._values[key] = value

File ~/.pyenv/versions/3.10.14/lib/python3.10/site-packages/flatdict.py:154, in FlatDict.__setitem__(self, key, value)
    151     elif not isinstance(self._values[pk], FlatDict):
    152         raise TypeError(
    153             'Assignment to invalid type for key {}'.format(pk))
--> 154     self._values[pk][ck] = value
    155 else:
    156     self._values[key] = value

File ~/.pyenv/versions/3.10.14/lib/python3.10/site-packages/flatdict.py:152, in FlatDict.__setitem__(self, key, value)
    150         return
    151     elif not isinstance(self._values[pk], FlatDict):
--> 152         raise TypeError(
    153             'Assignment to invalid type for key {}'.format(pk))
    154     self._values[pk][ck] = value
    155 else:

TypeError: Assignment to invalid type for key yaml

Looks like the converting of a flat dict back to a nested dict fails due to this entry:

 'python.environment.ruamel.yaml': '0.18.6', 'python.environment.ruamel.yaml.clib': '0.2.8'

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