Skip to content

fix: name the module relative to the MLproject in the export header - #160

Open
mortenoh wants to merge 1 commit into
mainfrom
fix/mlproject-export-relative-source
Open

mortenoh wants to merge 1 commit into
mainfrom
fix/mlproject-export-relative-source

Conversation

@mortenoh

Copy link
Copy Markdown
Contributor

Summary

chapkit mlproject export writes the module path into the MLproject header. When the module was not in the MLproject's folder, that was the absolute path, for example /Users/<name>/.../src/my_model/service.py. A committed MLproject then carried a machine-specific path, and export --check failed on every other machine, CI included, because it compares the whole file. A src/-layout service had to keep a root main.py only to get a portable header.

  • The header names the module relative to the MLproject's folder, for example src/my_model/service.py. The absolute path remains only where no relative path exists, such as a module on another drive on Windows.
  • When the MLproject is not next to the module, the header's regenerate command adds -o <name>, because export otherwise writes next to the module.
  • A module next to its MLproject, the usual main.py case, is unchanged: the header still reads main.py.

The MLproject guide describes exporting a src/-layout service to the project root.

Test plan

  • New test: a module in src/pkg/ exported to the project root gets a relative header with no temporary path in it, and the header's command run from the project folder passes --check.
  • Existing export tests, including -o into another folder and into the module's folder.
  • make lint; full test suite: 1095 passed, 12 skipped.
  • Exported chapkit_deep_auto_regressive_model from src/chapkit_deep_auto_regressive/service.py: the header is relative and the MLproject body is unchanged.

When the service module was not in the MLproject's folder, the header
recorded its absolute path, so a committed MLproject carried a
machine-specific path and --check failed on every other machine. A
src-layout service had to keep a root main.py only to get a portable
header.

The header now names the module relative to the MLproject's folder (the
absolute path stays only where no relative one exists, such as another
drive on Windows), and its regenerate command adds -o when the MLproject
is not next to the module.
@codecov

codecov Bot commented Nov 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

This branch has not been deployed

No deployments
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