Skip to content

Resolve a child's defaults function in the child's import context (v0.1.38) - #87

Merged
Volv-G merged 2 commits into
masterfrom
child-defaults-import-context
Nov 19, 2026
Merged

Volv-G merged 2 commits into
masterfrom
child-defaults-import-context

Conversation

@Volv-G

@Volv-G Volv-G commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

Follow-up to #86. A child's own task_annotations function is called for the child's compile key in _process_subpipeline_children, before _compile_pipeline_fn puts the child's source dir on sys.path. A function that lazily imports a sibling of the child (e.g. from my_annotation_helper import annotations_for next to the child's .py) therefore raised ModuleNotFoundError when the child was reached through subpipeline(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.path with _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, and task_annotations=defaults where defaults(cfg) imports the helper. Compiled through a parent and compiled directly, it gives the same annotations. The test fails with ModuleNotFoundError on the current master.

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

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.
@Volv-G
Volv-G requested a review from Ark-kun as a code owner November 19, 2026 02:55
@Volv-G
Volv-G merged commit e58c149 into master Nov 19, 2026
6 checks passed
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