Repository navigation
feat(experiment): add python_path to make modules importable in task workers - #292
Merged
bpiwowar merged 2 commits intoOct 21, 2026
Merged
Conversation
…workers Task workers reconstruct the task module by file path and do not inherit the launching interpreter's sys.path. A Task.execute() that imports a module by name at run time (plugin registries, factories, sibling packages) therefore fails with ModuleNotFoundError when driving experiments programmatically via experiment(), which exposed no way to add worker import paths (project_paths is only used for git info). Add an optional `python_path` argument to experiment(); its entries are resolved and appended to workspace.python_path, which the script builder already injects into the worker's sys.path. Equivalent to exporting PYTHONPATH before submitting, but discoverable from the API. Adds a regression test (plus a strict-xfail control proving the fix is load-bearing). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
|
hi @model-collapse ! Thanks a lot for your contribution, we were mostly launching experiments through the CLI and never had this issue :) |
Collaborator
|
Thanks @model-collapse, this is a useful addition. The CLI already fills A few things before merging:
Minor points, not blocking:
Thanks again! |
- modern type hints for python_path - entries are searched in the order given (sys.path.insert reverses them) - document python_path in experiments.md - clear PYTHONPATH in the strict-xfail control test - ruff-format the test Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Task workers reconstruct the task module by file path and do not inherit the launching interpreter's sys.path. A Task.execute() that imports a module by name at run time (plugin registries, factories, sibling packages) therefore fails with ModuleNotFoundError when driving experiments programmatically via experiment(), which exposed no way to add worker import paths (project_paths is only used for git info).
Add an optional
python_pathargument to experiment(); its entries are resolved and appended to workspace.python_path, which the script builder already injects into the worker's sys.path. Equivalent to exporting PYTHONPATH before submitting, but discoverable from the API.Adds a regression test (plus a strict-xfail control proving the fix is load-bearing).