-
Notifications
You must be signed in to change notification settings - Fork 23
fix: forward step_name through the _v1 Session.run_task wrapper #345
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
Merged
seant-aws
merged 2 commits into
OpenJobDescription:mainline
from
seant-aws:run-task-step-name
Aug 6, 2026
Merged
Changes from all commits
Commits
Show all changes
2 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
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,107 @@ | ||
| # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
|
|
||
| """Tests that the _v1 Session.run_task accepts and forwards step_name | ||
| to the Rust binding without error (RFC 0008). | ||
|
|
||
| The full wrap-action integration (``{{WrappedStep.Name}}`` resolution inside an | ||
| ``onWrapTaskRun`` hook) is validated by the worker-agent's differential runtime | ||
| test. This test verifies the _v1 Python wrapper plumbs the kwarg through. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import time | ||
| import uuid | ||
| from pathlib import Path | ||
|
|
||
| import pytest | ||
|
|
||
| from openjd.model._v1 import create_job, decode_job_template | ||
| from openjd.sessions._v1 import Session, SessionState, ActionState | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Helpers | ||
| # --------------------------------------------------------------------------- | ||
|
|
||
| _SIMPLE_TEMPLATE = { | ||
| "specificationVersion": "jobtemplate-2023-09", | ||
| "name": "StepNameTest", | ||
| "steps": [ | ||
| { | ||
| "name": "MyStep", | ||
| "script": { | ||
| "actions": { | ||
| "onRun": {"command": "echo", "args": ["hello-from-task"]}, | ||
| } | ||
| }, | ||
| } | ||
| ], | ||
| } | ||
|
|
||
|
|
||
| def _run_until_ready(session: Session, timeout_s: float = 10.0) -> None: | ||
| deadline = time.time() + timeout_s | ||
| while session.state == SessionState.RUNNING and time.time() < deadline: | ||
| time.sleep(0.05) | ||
|
|
||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Tests | ||
| # --------------------------------------------------------------------------- | ||
|
|
||
|
|
||
| class TestV1RunTaskStepName: | ||
| """Verify that _v1 Session.run_task forwards step_name to the Rust binding.""" | ||
|
|
||
| def test_run_task_accepts_step_name( | ||
| self, tmp_path: Path, caplog: pytest.LogCaptureFixture | ||
| ) -> None: | ||
| """run_task(step_name=...) succeeds and the task completes normally.""" | ||
| job_template = decode_job_template(template=_SIMPLE_TEMPLATE) | ||
| job = create_job(job_template=job_template, job_parameter_values={}) | ||
| step = job.steps[0] | ||
|
|
||
| with Session( | ||
| session_id=uuid.uuid4().hex, | ||
| job_parameter_values={}, | ||
| session_root_directory=tmp_path, | ||
| ) as session: | ||
| session.run_task( | ||
| step_script=step.script, | ||
| task_parameter_values={}, | ||
| resolved_symtab=step.resolved_symtab, | ||
| step_name="MyStep", | ||
| ) | ||
| _run_until_ready(session) | ||
|
|
||
| assert session.state == SessionState.READY | ||
| assert session.action_status is not None | ||
| assert session.action_status.state == ActionState.SUCCESS | ||
| assert session.action_status.exit_code == 0 | ||
|
|
||
| messages = "\n".join(caplog.messages) | ||
| assert "hello-from-task" in messages | ||
|
|
||
| def test_run_task_step_name_none_also_works(self, tmp_path: Path) -> None: | ||
| """step_name=None (the default) still works.""" | ||
| job_template = decode_job_template(template=_SIMPLE_TEMPLATE) | ||
| job = create_job(job_template=job_template, job_parameter_values={}) | ||
| step = job.steps[0] | ||
|
|
||
| with Session( | ||
| session_id=uuid.uuid4().hex, | ||
| job_parameter_values={}, | ||
| session_root_directory=tmp_path, | ||
| ) as session: | ||
| session.run_task( | ||
| step_script=step.script, | ||
| task_parameter_values={}, | ||
| resolved_symtab=step.resolved_symtab, | ||
| # step_name defaults to None | ||
| ) | ||
| _run_until_ready(session) | ||
|
|
||
| assert session.state == SessionState.READY | ||
| assert session.action_status is not None | ||
| assert session.action_status.state == ActionState.SUCCESS | ||
| assert session.action_status.exit_code == 0 |
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.
The floor was bumped to
0.11.2, but the comment above still explains only why0.11.1was the floor ("0.11.1 is the floor because…"). Sincerun_tasknow forwardsstep_nameto the Rust binding,0.11.2is presumably required because it is the first release whoseSession.run_taskacceptsstep_name/ surfacesWrappedStep.Name. Worth adding a line documenting that so the rationale for the new floor is captured (otherwise a future reader could mistakenly relax it back to0.11.1, which would breakrun_task(step_name=…)at runtime).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.
OK since we're doing minor bumps.