Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Getting KeyError when Name or version is missing from YAML Config #4884

Open
muneebable opened this issue Jul 26, 2024 · 1 comment
Open
Labels
feedback-wanted Request for feedback

Comments

@muneebable
Copy link

muneebable commented Jul 26, 2024

Describe the bug

I was doing a bentoml build and I am getting the error

Traceback (most recent call last):
  File "~/usr/vendors/pyenv/versions/housing_valuation/bin/bentoml", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "~/usr/vendors/pyenv/versions/3.11.4/envs/housing_valuation/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/usr/vendors/pyenv/versions/3.11.4/envs/housing_valuation/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "~/usr/vendors/pyenv/versions/3.11.4/envs/housing_valuation/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/usr/vendors/pyenv/versions/3.11.4/envs/housing_valuation/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/usr/vendors/pyenv/versions/3.11.4/envs/housing_valuation/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/usr/vendors/pyenv/versions/3.11.4/envs/housing_valuation/lib/python3.11/site-packages/bentoml_cli/utils.py", line 362, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "~/usr/vendors/pyenv/versions/3.11.4/envs/housing_valuation/lib/python3.11/site-packages/bentoml_cli/utils.py", line 333, in wrapper
    return_value = func(*args, **kwargs)
                   ^^^^^^^^^^^^^^^^^^^^^
  File "~/usr/vendors/pyenv/versions/3.11.4/envs/housing_valuation/lib/python3.11/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ~/usr/vendors/pyenv/versions/3.11.4/envs/housing_valuation/lib/python3.11/site-packages/bentoml_cli/utils.py", line 290, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "~/usr/vendors/pyenv/versions/3.11.4/envs/housing_valuation/lib/python3.11/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/usr/vendors/pyenv/versions/3.11.4/envs/housing_valuation/lib/python3.11/site-packages/simple_di/__init__.py", line 139, in _
    return func(*_inject_args(bind.args), **_inject_kwargs(bind.kwargs))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/usr/vendors/pyenv/versions/3.11.4/envs/housing_valuation/lib/python3.11/site-packages/bentoml_cli/bentos.py", line 371, in build
    ).save(_bento_store)
      ^^^^^^^^^^^^^^^^^^
  File "~/usr/vendors/pyenv/versions/3.11.4/envs/housing_valuation/lib/python3.11/site-packages/simple_di/__init__.py", line 139, in _
    return func(*_inject_args(bind.args), **_inject_kwargs(bind.kwargs))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/usr/vendors/pyenv/versions/3.11.4/envs/housing_valuation/lib/python3.11/site-packages/bentoml/_internal/bento/bento.py", line 390, in save
    with bento_store.register(self.tag) as bento_path:
  File "~/usr/vendors/pyenv/versions/3.11.4/lib/python3.11/contextlib.py", line 144, in __exit__
    next(self.gen)
  File ~/usr/vendors/pyenv/versions/3.11.4/envs/housing_valuation/lib/python3.11/site-packages/bentoml/_internal/store.py", line 177, in register
    or self.get(_tag).creation_time >= self.get(_tag.name).creation_time
       ^^^^^^^^^^^^^^
  File "/~/usr/vendors/pyenv/versions/3.11.4/envs/housing_valuation/lib/python3.11/site-packages/bentoml/_internal/store.py", line 141, in get
    return self._get_item(_tag)
           ^^^^^^^^^^^^^^^^^^^^
  File ~/usr/vendors/pyenv/versions/3.11.4/envs/housing_valuation/lib/python3.11/site-packages/bentoml/_internal/store.py", line 102, in _get_item
    return self._item_type.from_fs(self._fs.opendir(tag.path()))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/usr/vendors/pyenv/versions/3.11.4/envs/housing_valuation/lib/python3.11/site-packages/bentoml/_internal/bento/bento.py", line 307, in from_fs
    info = BentoInfo.from_yaml_file(bento_yaml)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/usr/vendors/pyenv/versions/3.11.4/envs/housing_valuation/lib/python3.11/site-packages/bentoml/_internal/bento/bento.py", line 539, in from_yaml_file
    yaml_content["tag"] = Tag(yaml_content["name"], yaml_content["version"])
                              ~~~~~~~~~~~~^^^^^^^^
KeyError: 'name'

This error should be catched instead of failing the build. My yaml content look like this

{
  "service": "service:svc",
  "bentoml_version": "1.1.1",
  "creation_time": "2024-07-26T17:03:11.523664+00:00",
  "labels": {
    "owner": "root",
    "stage": "dev"
  },
  "models": [
    {
      "tag": "project_neighbor_scaler:usnn32sloc3v4bgt",
      "module": "bentoml.sklearn",
      "creation_time": "2024-07-26T17:01:04.181244+00:00"
    },
    {
      "tag": "project_target_scaler:usmvjqcloc4u6bgt",
      "module": "bentoml.sklearn",
      "creation_time": "2024-07-26T17:01:04.171380+00:00"
    },
    {
      "tag": "project_model:usip2gklocshgbgt",
      "module": "bentoml.pytorch",
      "creation_time": "2024-07-26T17:01:04.122590+00:00"
    }
  ],
  "runners": [
    {
      "name": "project_model",
      "runnable_type": "NewClass",
      "embedded": False,
      "models": [
        "project_model:usip2gklocshgbgt"
      ],
      "resource_config": None
    },
    {
      "name": "project_target_scaler",
      "runnable_type": "SklearnRunnable",
      "embedded": False,
      "models": [
        "project_target_scaler:usmvjqcloc4u6bgt"
      ],
      "resource_config": None
    },
    {
      "name": "project_neighbor_scaler",
      "runnable_type": "SklearnRunnable",
      "embedded": False,
      "models": [
        "project_neighbor_scaler:usnn32sloc3v4bgt"
      ],
      "resource_config": None
    }
  ],
  "apis": [
    {
      "name": "inference",
      "input_type": "JSON",
      "output_type": "JSON"
    }
  ],
  "docker": {
    "distro": "debian",
    "python_version": "3.11",
    "cuda_version": None,
    "env": None,
    "system_packages": [
      "libblas-dev",
      "liblapack-dev",
      "gfortran"
    ],
    "setup_script": None,
    "base_image": None,
    "dockerfile_template": None
  },
  "python": {
    "requirements_txt": "requirements/requirements.txt",
    "packages": None,
    "lock_packages": None,
    "index_url": None,
    "no_index": None,
    "trusted_host": None,
    "find_links": None,
    "extra_index_url": None,
    "pip_args": None,
    "wheels": None
  },
  "conda": {
    "environment_yml": None,
    "channels": None,
    "dependencies": None,
    "pip": None
  }
}

To reproduce

No response

Expected behavior

No response

Environment

bentoml: 1.1.1
python 3.11.4

@muneebable muneebable added the bug Something isn't working label Jul 26, 2024
@frostming
Copy link
Contributor

Can you try it on the latest version?

@frostming frostming added feedback-wanted Request for feedback and removed bug Something isn't working labels Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feedback-wanted Request for feedback
Projects
None yet
Development

No branches or pull requests

2 participants