-
Notifications
You must be signed in to change notification settings - Fork 2
feat(tangle-cli): add python_pipeline authoring DSL #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Silin144
wants to merge
3
commits into
TangleML:master
Choose a base branch
from
Silin144:feat/python-pipeline-dsl
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
43 changes: 43 additions & 0 deletions
43
packages/tangle-cli/src/tangle_cli/python_pipeline/__init__.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| """Python-first authoring surface for Tangle pipelines. | ||
|
|
||
| End users write:: | ||
|
|
||
| from tangle_cli.python_pipeline import pipeline, task, registered, ref, raw, subpipeline, TaskEnv, In, Out | ||
|
|
||
| ``cfg`` is NOT a top-level export — it is a parameter the framework | ||
| injects into the user's pipeline function at trace time. Importing the | ||
| :class:`tangle_cli.python_pipeline.cfg.Cfg` class is reserved for the | ||
| compile driver. | ||
|
|
||
| ``import tangle_cli.python_pipeline`` is kept light: it does not | ||
| eagerly import the heavy ``tangle_cli.component_generator`` codegen | ||
| module or the tracer machinery. | ||
|
|
||
| Module map: authoring entry points live in :mod:`.pipeline`, | ||
| :mod:`.task`, :mod:`.subpipeline`, :mod:`.registered`, :mod:`.ref` and | ||
| :mod:`.raw`; the trace-time IR is built in :mod:`.trace` / :mod:`.graph` | ||
| and lowered to the dehydrated dict shape by :mod:`.emit`. | ||
| """ | ||
| from __future__ import annotations | ||
|
|
||
| from .pipeline import pipeline | ||
| from .raw import raw | ||
| from .ref import ref | ||
| from .registered import registered | ||
| from .subpipeline import subpipeline | ||
| from .task import task | ||
| from .task_env import TaskEnv | ||
| from .types import In, Out, Outputs | ||
|
|
||
| __all__ = [ | ||
| "pipeline", | ||
| "task", | ||
| "registered", | ||
| "ref", | ||
| "raw", | ||
| "subpipeline", | ||
| "TaskEnv", | ||
| "In", | ||
| "Out", | ||
| "Outputs", | ||
| ] |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(AI-assisted)
I think this still has one small edge case: mixed
ast.Importstatements that combine an authoring module with a real runtime import are still removed as a whole statement._is_authoring_import()returns true when any alias is a registered authoring module:and the strip loop then removes the full statement line range. So a source line like:
would strip
ostoo, even thoughosmay be a real runtime helper needed by the baked component code. That seems to violate the nearby contract that unrelated runtime helpers must survive stripping.The existing
AuthoringStripError/ TaskEnv mixed-import coverage appears to cover a different case: TaskEnv env-binding imports such asfrom _envs import UPI, helper, after env names are collected. It does not seem to guard this general authoring-module + runtime-moduleast.Importcase.Could we either rewrite mixed
ast.Importstatements to drop only the authoring alias(es), or fail fast whenlen(node.names) > 1and one alias is an authoring module, telling authors to split authoring imports from runtime imports?