Skip to content

docs(export): fix runnable Exporter examples - #272

Open
onion-hong wants to merge 1 commit into
Tencent:mainfrom
onion-hong:codex/fix-exporter-doc-examples
Open

docs(export): fix runnable Exporter examples#272
onion-hong wants to merge 1 commit into
Tencent:mainfrom
onion-hong:codex/fix-exporter-doc-examples

Conversation

@onion-hong

Copy link
Copy Markdown
Contributor

The Exporter class examples pass a filename string to an API that expects a model module. Running the doctest on upstream b44ea12 fails with AttributeError: 'str' object has no attribute 'named_modules' during export preflight.

Build a randomly initialized model from YAML and pass its .model to both examples. Small TorchScript exports keep the examples runnable without downloading pretrained weights or requiring an additional export backend. Capture the returned path so the doctest does not depend on its printed representation. This changes documentation only.

Validation:

  • Reproduced the failure on upstream b44ea12.
  • python -m pytest --doctest-modules ultralytics/engine/exporter.py -q: 1 passed after the change, including real TorchScript exports.
  • ruff format --check ultralytics/engine/exporter.py and git diff --check passed.
  • Ruff lint still reports pre-existing diagnostics outside the changed examples; codespell is not installed in the validation environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant