-
Notifications
You must be signed in to change notification settings - Fork 0
Route stage I/O through Gremlin, drop direct State imports #1088
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
Closed
Closed
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
4c05165
Update stage signatures to accept gremlin instead of state
xbrianh 2a85931
Reorganize state utility functions into state_utils module
xbrianh 9638349
Address review feedback
xbrianh 4e92eeb
normalize
xbrianh 3e5de3c
Fix failing checks
xbrianh 1459234
Fix failing checks
xbrianh f907218
Fix failing checks
xbrianh 15f75cd
Fix failing checks
xbrianh 4f58c32
Fix failing checks
xbrianh ad48d8e
Fix failing checks
xbrianh 913a868
Address review comments: remove State.state property setter, fix test…
xbrianh d7189fe
normalize
xbrianh 48f5a2b
Fix failing checks
xbrianh 46af15a
Fix CI failures
xbrianh f9cee24
Fix CI failures
xbrianh 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
Some comments aren't visible on the classic Files Changed page.
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
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
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
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
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
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,49 @@ | ||
| from __future__ import annotations | ||
|
|
||
| import datetime | ||
| import pathlib | ||
| import re | ||
| import secrets | ||
| from typing import Any | ||
|
|
||
| from gremlins import paths as _paths | ||
|
|
||
| _GREMLIN_ID_RE = re.compile(r"^[A-Za-z0-9_-]+$") | ||
|
|
||
|
|
||
| def validate_gremlin_id(gremlin_id: str) -> None: | ||
| """Raise ValueError if gremlin_id is not a safe, non-path-traversing identifier.""" | ||
| if ".." in gremlin_id or not _GREMLIN_ID_RE.match(gremlin_id): | ||
| raise ValueError(f"gremlin_id contains illegal characters: {gremlin_id!r}") | ||
|
|
||
|
|
||
| def resolve_state_file(gremlin_id: str | None) -> pathlib.Path | None: | ||
| """Return path to state.json for gremlin_id, or None when gremlin_id is absent.""" | ||
| if not gremlin_id: | ||
| return None | ||
| return _paths.state_root() / gremlin_id / "state.json" | ||
|
|
||
|
|
||
| def resolve_artifact_dir(gremlin_id: str | None = None) -> pathlib.Path: | ||
| """Resolve the artifacts directory for the current run.""" | ||
| state_root = _paths.state_root() | ||
| if gremlin_id: | ||
| artifact_dir = state_root / gremlin_id / "artifacts" | ||
| else: | ||
| ts = datetime.datetime.now().strftime("%Y%m%d-%H%M%S") | ||
| rand = secrets.token_hex(3) | ||
| artifact_dir = state_root / "direct" / f"{ts}-{rand}" / "artifacts" | ||
| artifact_dir.mkdir(parents=True, exist_ok=True) | ||
| return artifact_dir | ||
|
|
||
|
|
||
| def landable_shape(state: dict[str, Any]) -> str: | ||
| """Classify artifact shape for land dispatch.""" | ||
| artifacts = list(state.get("artifacts") or []) | ||
| prs = [art for art in artifacts if art.get("type") == "pr"] | ||
|
|
||
| if not prs: | ||
| return "empty" | ||
| if len(prs) == 1: | ||
| return "one_pr" | ||
| return "many_prs" |
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
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
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
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
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
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
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
Oops, something went wrong.
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.
Same as #3350576190 — part of larger refactoring to eliminate State imports from stage modules.