Repository navigation
Resolve a child's defaults function in the child's import context (v0.1.38) - #87
Merged
Merged
Conversation
The child's own `task_annotations` function was called for its compile key before the child's source dir was put on `sys.path`, so a function that imports a sibling of the child (e.g. `from my_helper import annotations_for`) raised ModuleNotFoundError when the child was reached through `subpipeline(child)`, though compiling the child directly worked. It is now resolved under the same import setup the child's trace uses.
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.
Follow-up to #86. A child's own
task_annotationsfunction is called for the child's compile key in_process_subpipeline_children, before_compile_pipeline_fnputs the child's source dir onsys.path. A function that lazily imports a sibling of the child (e.g.from my_annotation_helper import annotations_fornext to the child's.py) therefore raisedModuleNotFoundErrorwhen the child was reached throughsubpipeline(child), although compiling the child directly worked.The function is now resolved under the same import setup the child's trace uses: the child's source dir is recorded for the after-compile purge, shadowing modules are evicted, and the dir is put on
sys.pathwith_temp_sys_path. The key then uses the resulting mapping. Mapping defaults and children without a config are unchanged.Test: a child in its own directory, with a
config.yaml, a sibling helper module, andtask_annotations=defaultswheredefaults(cfg)imports the helper. Compiled through a parent and compiled directly, it gives the same annotations. The test fails withModuleNotFoundErroron the currentmaster.Bumps the version to 0.1.38.
Raised in review of the shop/world vendoring of tangle-cli: https://delta.shopify.io/shop/world/pull/2480347#discussion_r2600832335890