| 404 | # it is ok to expect updates to be reflected after a server restart. |
| 405 | @lru_cache(maxsize=2) # noqa: B019 |
| 406 | def get_config(self, *, hide_secrets: bool = True) -> PartialMarimoConfig: |
| 407 | if self.filename is None: |
| 408 | return {} |
| 409 | try: |
| 410 | filepath = Path(self.filename) |
| 411 | if not filepath.is_file(): |
| 412 | return {} |
| 413 | |
| 414 | from marimo._utils.scripts import read_pyproject_from_script |
| 415 | |
| 416 | script_content = filepath.read_text(encoding="utf-8") |
| 417 | script_config = read_pyproject_from_script(script_content) |
| 418 | if script_config is None: |
| 419 | return {} |
| 420 | |
| 421 | script_config = sanitize_pyproject_dict( |
| 422 | script_config, |
| 423 | (("tool", "marimo", "runtime", "auto_instantiate"),), |
| 424 | ) |
| 425 | |
| 426 | marimo_config = get_marimo_config_from_pyproject_dict( |
| 427 | script_config |
| 428 | ) |
| 429 | if marimo_config is None: |
| 430 | return {} |
| 431 | |
| 432 | except Exception as e: |
| 433 | LOGGER.warning("Failed to read script config: %s", e) |
| 434 | return {} |
| 435 | |
| 436 | if hide_secrets: |
| 437 | return mask_secrets_partial(marimo_config) |
| 438 | return marimo_config |
| 439 | |
| 440 | |
| 441 | class UserConfigManager(MarimoConfigReader): |