`bentoml.save_config` always crashes with `yaml.representer.RepresenterError`
Author: betacatslingCreated Sep 14, 2026Updated Sep 14, 2026
Description
bentoml.save_config(config_file_handle) is a public API exported from
bentoml/__init__.py that is supposed to write the resolved BentoML
configuration to a file handle. It currently dumps the BentoMLContainer.config
provider object instead of the configuration dictionary:
content = yaml.safe_dump(BentoMLContainer.config)yaml.safe_dump cannot represent a simple_di Configuration provider, so the
call raises RepresenterError every time:
yaml.representer.RepresenterError: ('cannot represent an object',
Configuration(data={'version': 1, 'api_server': ...}))Reproduction
import io
import bentoml
buf = io.StringIO()
bentoml.save_config(buf) # raises RepresenterErrorExpected behavior
The resolved configuration dict should be written, e.g.
yaml.safe_dump(BentoMLContainer.config.get()), producing a YAML document with
the api_server, runners, tracing, monitoring, and version keys.
Environment
- BentoML main @ 517b343b81aeb0b01bbd908e58e53ad9c12ef7eb
Source: bentoml/BentoML