Skip to content

Conversation

@mwiebe
Copy link
Contributor

@mwiebe mwiebe commented Nov 5, 2025

What was the problem/requirement? (What/Why)

We need the ability to run subprocesses that run the same way as all the action subprocesses do, but are not actions specified in the job template. This includes the need to control whether they inherit the full session environment including envEnter variables or not.

The proposed change in #281 solves the problem, but introduces a new parameter to run_task that doesn't fit within the spirit of the OpenJD Task, which is a specific entity within the specification.

This change was created using Kiro with the Claude Sonnet 4.5 model.

What was the solution? (How)

This new function provides the ability to run an ad hoc command within the session environment, choosing whether to use the environment variables from the session enter actions or to ignore them. The parameters for the command are direct, so you don't have to construct a temporary Action or StepAction object to run a simple command.

What is the impact of this change?

The Session object is more flexible to use in custom use cases.

How was this change tested?

Implemented unit tests for the new functionality.

Was this change documented?

Added a docstring.

Is this a breaking change?

No

Does this change impact security?

No


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@mwiebe mwiebe force-pushed the session-run-subprocess branch 2 times, most recently from 5780572 to 0c1e13c Compare November 5, 2025 20:51
@mwiebe mwiebe marked this pull request as ready for review November 5, 2025 22:25
@mwiebe mwiebe requested a review from a team as a code owner November 5, 2025 22:25
@mwiebe mwiebe force-pushed the session-run-subprocess branch 2 times, most recently from 5e4afd8 to 6984f6c Compare November 5, 2025 22:43
Comment on lines +865 to +923
This method is non-blocking; it will exit when the subprocess is either
confirmed to have started running, or has failed to be started.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to make blocking an parameter? Maybe not, I'm not quite what the intended use case is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This behavior fits run_subprocess into the sequential actions that are part of a session, just like the existing run_task or enter_environment. Expanding the environment to run in parallel to other actions makes sense, but it would need more verification that the code is compatible with that concurrency, compared to fitting in the existing patterns the way it is now. Because of that, I'd rather wait until we have that use case to expand it.

ValueError: If timeout is provided and is not a positive integer, or if command is empty.
"""
# State validation
if self.state != SessionState.READY:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not allow RUNNING? If we want to run multiple subprocesses using this new method, it looks like the session would be in RUNNING after the first call and the second call would fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing as for the non-blocking part.

@mwiebe mwiebe force-pushed the session-run-subprocess branch from 6984f6c to 548d800 Compare November 7, 2025 21:45
@mwiebe mwiebe force-pushed the session-run-subprocess branch from 548d800 to 2733518 Compare November 15, 2025 01:32
@mwiebe mwiebe enabled auto-merge (rebase) December 1, 2025 17:19
This new function provides the ability to run an ad hoc command within
the session environment, choosing whether to use the environment
variables from the session enter actions or to ignore them. The
parameters for the command are direct, so you don't have to construct a
temporary Action or StepAction object to run a simple command.

Signed-off-by: Mark <[email protected]>
@mwiebe mwiebe force-pushed the session-run-subprocess branch from 2733518 to 1e6c05b Compare December 1, 2025 17:20
@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 1, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@mwiebe mwiebe merged commit 80026e9 into OpenJobDescription:mainline Dec 1, 2025
24 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants