Skip to content

Sometimes registry.get_spec returns a Spec, sometimes a dict #393

@nickjalbert

Description

@nickjalbert

From our conversation here, we ran into a type issue with registry.get_spec() when we were publishing a run (probably a WebRegistry btw). We expect to get a Spec back from get_spec() but instead get a pure dict during the publishing of a run and DeepDiff blows up.

Note, we have a quick fix in that PR, but we should probably get to the bottom of get_spec() not returning a Spec.

Repro:

git revert 6c7958744913d555941fe75af830426457c2100e
# Edit the line ~160 pcs/component.py 
#     "existing = registry.get_spec(self.identifier, error_if_not_found=False)" 
# and pass a `flatten=False` param
# If you don't do the above, you'll get a "missing 1 required positional argument: flatten" error
cd example_agents/random
rm -rf mlruns/
agentos run agent
# run the local server in a different tab
USE_LOCAL_SERVER=True agentos publish <run_id from previous command>

Expected:
The run is published

Actual:

creating cls <class 'pcs.argument_set.ArgumentSet'> with kwargs {'parent': None, 'kwargs': {}, 'args': []}
creating cls <class 'pcs.command.Command'> with kwargs {'log_return_value': True, 'function_name': 'run_episodes', 'component': <pcs.instance_manager.Instance object at 0x7f695d60eeb0>, 'argument_set': <pcs.argument_set.ArgumentSet object at 0x7f695d695af0>}
Traceback (most recent call last):
  File "/home/nickj/agentos/lean-env/bin/agentos", line 33, in <module>
    sys.exit(load_entry_point('agentos', 'console_scripts', 'agentos')())
  File "/home/nickj/agentos/lean-env/lib/python3.9/site-packages/click/core.py", line 1137, in __call__
    return self.main(*args, **kwargs)
  File "/home/nickj/agentos/lean-env/lib/python3.9/site-packages/click/core.py", line 1062, in main
    rv = self.invoke(ctx)
  File "/home/nickj/agentos/lean-env/lib/python3.9/site-packages/click/core.py", line 1668, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/nickj/agentos/lean-env/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/nickj/agentos/lean-env/lib/python3.9/site-packages/click/core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "/home/nickj/agentos/agentos/cli.py", line 270, in publish
    r.to_registry(Registry.from_default())
  File "/home/nickj/agentos/pcs/component.py", line 171, in to_registry
    self._all_dependencies_to_registry(registry, False)
  File "/home/nickj/agentos/pcs/component.py", line 183, in _all_dependencies_to_registry
    d.to_registry(
  File "/home/nickj/agentos/pcs/component.py", line 171, in to_registry
    self._all_dependencies_to_registry(registry, False)
  File "/home/nickj/agentos/pcs/component.py", line 183, in _all_dependencies_to_registry
    d.to_registry(
  File "/home/nickj/agentos/pcs/component.py", line 171, in to_registry
    self._all_dependencies_to_registry(registry, False)
  File "/home/nickj/agentos/pcs/component.py", line 183, in _all_dependencies_to_registry
    d.to_registry(
  File "/home/nickj/agentos/pcs/component.py", line 160, in to_registry
    self._all_dependencies_to_registry(registry, True)
  File "/home/nickj/agentos/pcs/component.py", line 183, in _all_dependencies_to_registry
    d.to_registry(
  File "/home/nickj/agentos/pcs/component.py", line 160, in to_registry
    self._all_dependencies_to_registry(registry, True)
  File "/home/nickj/agentos/pcs/component.py", line 183, in _all_dependencies_to_registry
    d.to_registry(
  File "/home/nickj/agentos/pcs/component.py", line 160, in to_registry
    self._all_dependencies_to_registry(registry, True)
  File "/home/nickj/agentos/pcs/component.py", line 183, in _all_dependencies_to_registry
    d.to_registry(
  File "/home/nickj/agentos/pcs/component.py", line 160, in to_registry
    self._all_dependencies_to_registry(registry, True)
  File "/home/nickj/agentos/pcs/component.py", line 183, in _all_dependencies_to_registry
    d.to_registry(
  File "/home/nickj/agentos/pcs/component.py", line 165, in to_registry
    assert not diff, (
AssertionError: A spec with identifier '6a635e836d08615d56a5d5afb39fa7f6ab73ae2a' already exists in registry '<pcs.registry.WebRegistry object at 0x7f695d689fd0>' and differs from the one you're trying to add. Diff of existing spec vs this spec:
 {'type_changes': {'root': {'old_type': <class 'dict'>, 'new_type': <class 'pcs.specs.Spec'>, 'old_value': {'6a635e836d08615d56a5d5afb39fa7f6ab73ae2a': {'path': '/home/nickj/agentos/example_agents/random', 'type': 'LocalRepo', 'default_version': None}}, 'new_value': {'6a635e836d08615d56a5d5afb39fa7f6ab73ae2a': {'type': 'LocalRepo', 'default_version': None, 'path': '/home/nickj/agentos/example_agents/random'}}}}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions