You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package a dependency-free Python compatibility shim with Microsoft.DotNet.Helix.JobSender
copy the shim beside legacy RunnerScripts/scriptrunner/scriptrunner.py through a build-transitive target
stage result files and script logs under HELIX_WORKITEM_UPLOAD_ROOT so the machine-side Helix client retains ownership of credentials and uploads
preserve legacy queues by using a namespace package without helix/__init__.py
document the shim as temporary and explicitly exclude credential-dependent continuationrunner.py
Motivation
New AOT Helix queues no longer install the legacy Python helix package. Existing JobSender consumers can still submit payloads that invoke scriptrunner.py, causing ModuleNotFoundError before their tests run and preventing their expected script logs and TestResults.zip from being published.
This keeps public Arcade independent from the internal machine-client implementation. The shim only implements the submitted runner surface; the Helix client continues to own storage authentication, retries, uploads, and event publication.
Validation
dotnet test src/Microsoft.DotNet.Helix/JobSender.Tests/Microsoft.DotNet.Helix.JobSender.Tests.csproj --no-restore — 6 passed
exercised the AppCompat scriptrunner.py shape end to end with a synthetic RunMstest.cmd
verified stdout and stderr are logged
verified TestResults.zip is staged under HELIX_WORKITEM_UPLOAD_ROOT
packed Microsoft.DotNet.Helix.JobSender.12.0.0-dev and verified all compatibility files are present
verified a consuming build copies the files to RunnerScripts/scriptrunner
Follow-up
The AOT client change that emits legacy Logs events for staged .helix-logs files and fails work items on upload/event-publication failures is being handled in dotnet-helix-machines.
Package a dependency-free Python compatibility surface for existing JobSender consumers and stage result uploads for the AOT Helix client.
Co-authored-by: Copilot <[email protected]>
Copilot-Session: 1878358f-1e80-41bf-a8d5-4b3d0e13d7f9
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
There are correctness/resiliency issues in the new compatibility logging/test execution code that should be addressed before approval.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
This PR adds a dependency-free Python compatibility shim that can be packaged with Microsoft.DotNet.Helix.JobSender to keep legacy scriptrunner.py payloads working on newer Helix queues that no longer install the legacy helix Python package. The shim stages logs and result artifacts under HELIX_WORKITEM_UPLOAD_ROOT so the machine-side Helix client remains responsible for credentials and uploads.
Changes:
Package legacy-runner Python compatibility modules (namespace-package style, no helix/__init__.py) and a build-transitive targets file to copy them into consuming outputs under RunnerScripts/scriptrunner/helix.
Implement minimal helix.* runner surfaces (logging, process execution, cmdline parsing, staging “uploads” to HELIX_WORKITEM_UPLOAD_ROOT).
Add tests (Python unittest + C# process-driven runner) validating import surface and staging behavior; document the compatibility shim and explicitly exclude continuationrunner.py.
File summaries
File
Description
src/Microsoft.DotNet.Helix/JobSender/Readme.md
Documents the legacy runner shim behavior, limits, and opt-out property.
set_logfile() adds a FileHandler without ensuring the destination directory exists. If HELIX_LOG_ROOT points to a non-existent directory, this will raise and prevent the runner from emitting any results/logs.
The Python compatibility tests inherited the ambient Helix work-item environment, so on a legacy queue the child imported the installed helix package (which wins over this namespace shim) and uploaded using real result-container tokens instead of staging. Child processes now run with a sanitized environment and skip with an explicit reason when an installed helix takes precedence.
Also emit true UTC log timestamps, create the log directory in set_logfile, and make the xUnit wrapper fall back to another interpreter name and time out instead of hanging.
Co-authored-by: Copilot <[email protected]>
Copilot-Session: 1878358f-1e80-41bf-a8d5-4b3d0e13d7f9
This test hard-fails when no Python interpreter is present, which can make dotnet test for the repo environment-dependent (e.g., developer machines or constrained CI images). Consider skipping the test when Python isn't available, since the compatibility behavior can only be validated when an interpreter exists.
The reason will be displayed to describe this comment to others. Learn more.
Copilot review overview
🟡 Changes recommended
The shim has a couple of robustness gaps (path validation error handling and log file encoding) that can cause avoidable runtime failures on some environments.
Get a fresh assessment by requesting another Copilot review.
Staged logs used the machine's locale encoding. Under a non-UTF-8 locale (cp1252 on many Windows images, where AppCompat runs) logging silently dropped every non-ASCII line, so the restored script log could arrive empty.
Also accept text streams when staging, since legacy payloads may pass either stream type, and report a name that cannot be compared against the upload root as the same traversal error instead of leaking commonpath's own message.
Co-authored-by: Copilot <[email protected]>
Copilot-Session: 1878358f-1e80-41bf-a8d5-4b3d0e13d7f9
The reason will be displayed to describe this comment to others. Learn more.
Copilot review overview
🔵 Needs a closer look
There are correctness/reliability issues in the compatibility runner logging and the process-based tests’ interpreter resolution that should be addressed before merging.
The test only probes python/python3 on PATH, but Helix work items guarantee a Python executable via HELIX_PYTHONPATH (see src/Microsoft.DotNet.Helix/Sdk/Readme.md). Prefer HELIX_PYTHONPATH when present so the test runs reliably in Helix environments even if PATH doesn’t include python.
Convert command arguments to strings before logging
run_and_log_output logs the command with " ".join(args), which will raise a TypeError if any argument is not already a str (e.g., pathlib.Path or other path-like objects that subprocess.Popen accepts). Convert items to string for logging so the compatibility runner doesn’t fail before launching the process.
The precedence probe imported helix.logs, but the installed legacy package reads HELIX_CONFIG_ROOT and HELIX_LOG_ROOT at import time and raises without them. Since the probe deliberately runs with a sanitized environment, it crashed on legacy queues and the tests failed instead of skipping.
Resolve the module with importlib.util.find_spec, which reports which file would load without executing it, and include the child's output when resolution genuinely fails.
Co-authored-by: Copilot <[email protected]>
Copilot-Session: 1878358f-1e80-41bf-a8d5-4b3d0e13d7f9
This test only tries python/python3 from PATH, but the documented Helix contract exposes the interpreter through HELIX_PYTHONPATH (src/Microsoft.DotNet.Helix/Sdk/Readme.md:562-574), which need not be on PATH. On a supported queue with only that configured interpreter, the test fails with “No Python interpreter was found” before exercising the shim; prefer the environment-provided executable before keeping the local fallbacks.
os.path.commonpath was added in Python 3.5, but Helix only guarantees Python >= 3.4 on the client. On such a machine every staged upload raised AttributeError, so TestResults.zip could not be staged at all. Use a relpath-based containment check, which keeps the same traversal rejection.
Also resolve helix.logs with PathFinder in the tests. importlib.util.find_spec imports the parent package first, so a legacy 'helix' package with any import-time side effect would break the probe rather than skip.
Co-authored-by: Copilot <[email protected]>
Copilot-Session: 1878358f-1e80-41bf-a8d5-4b3d0e13d7f9
The declared --args option is only logged here; it is never added to execution_args, which is built from the positional leftovers. Any legacy payload that supplies its script arguments through --args therefore runs the script without those arguments. Pass the parsed option through using the legacy quoting semantics and cover that path in the end-to-end test.
Use HELIX_PYTHONPATH to locate the test interpreter
The test runner searches only for python/python3, but Helix guarantees the interpreter through HELIX_PYTHONPATH (see src/Microsoft.DotNet.Helix/Sdk/Readme.md:574) and that executable is not required to be on PATH. On queues exposing only the documented variable, this test fails with "No Python interpreter was found" before exercising the shim; prefer that environment variable and keep the name-based fallback for local runs.
Replace incompatible subprocess.run usage for Python 3.4
subprocess.run was added in Python 3.5, and the capture_output/text arguments require newer Python versions, but this compatibility test is run with the Helix interpreter whose documented minimum is Python 3.4. On that minimum runtime this helper raises before checking module resolution; use a Popen/communicate compatibility helper instead (and apply it to the other subprocess.run calls below).
Record why HELIX_RESULTS_CONTAINER_* is not stripped here: legacy helix.proc inherits the whole environment, the Helix client already exports those variables to the work item command that calls this, and legacy payloads may use them to upload directly. Narrowing them is a client-side decision for the whole work item.
Co-authored-by: Copilot <[email protected]>
Copilot-Session: 1878358f-1e80-41bf-a8d5-4b3d0e13d7f9
This test is run as part of the Helix work-item test suite, where the documented Python contract is HELIX_PYTHONPATH (the executable may not be on PATH; see src/Microsoft.DotNet.Helix/Sdk/Readme.md:572-579). Searching only the bare python/python3 names can therefore fail with "No Python interpreter was found" on a supported AOT image even though the required interpreter is available. Try Environment.GetEnvironmentVariable("HELIX_PYTHONPATH") before the fallback names.
Helix only guarantees Python >= 3.4 on the client, but this suite used subprocess.run (3.5, with capture_output and text from 3.7), pathlib read_text/write_text/read_bytes (3.5), and importlib.util.module_from_spec (3.5). It therefore could not run on the interpreter the shim has to support, so it could not verify the shim there either.
Replace those with equivalents available in 3.4 and add a guard that parses the shipped shim, the runner fixture, and this suite, failing with an exact file, line, and version when anything newer appears. That is the check that would have caught the os.path.commonpath regression, which made every staged upload raise AttributeError.
Co-authored-by: Copilot <[email protected]>
Copilot-Session: 1878358f-1e80-41bf-a8d5-4b3d0e13d7f9
The test only probes python/python3 on PATH, but Helix guarantees the interpreter through HELIX_PYTHONPATH and does not guarantee either alias is present. Because this project is submitted as a Helix work item, an image exposing only the documented executable variable will report that no interpreter was found and fail before exercising the shim. Try HELIX_PYTHONPATH first, then retain the PATH fallbacks.
The Helix SDK readme has claimed HELIX_PYTHONPATH is only guaranteed to be >= 3.4 since 2020, a year after 3.4 reached end of life. No queue has been anywhere near it for years: Windows installs 3.13/3.14, and the oldest system interpreter in the fleet is 3.9 on AzureLinux 3 and Raspbian 11. The stale number forced hand-written stand-ins for os.path.commonpath, subprocess.run, pathlib read_text/write_text/read_bytes, and module_from_spec, which added noise without protecting any real machine.
Document 3.9, which is what the images actually provide, and drop the workarounds and the version guard that only existed to satisfy 3.4. The genuine fixes stay: UTF-8 log staging, text-stream support, UTC timestamps, directory creation in set_logfile, PathFinder resolution, and the drive-mismatch ValueError.
Co-authored-by: Copilot <[email protected]>
Copilot-Session: 1878358f-1e80-41bf-a8d5-4b3d0e13d7f9
please take another look @mmitche. As we discussed yesterday I did take a look at the Python versions. The legacy already used construct that needs at least 3.9 e.g. the 3.4 in docs was just an obsolete statement. A3 uses 3.9.4 and that seems the oldest we have in the queues.
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
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.
Summary
Microsoft.DotNet.Helix.JobSenderRunnerScripts/scriptrunner/scriptrunner.pythrough a build-transitive targetHELIX_WORKITEM_UPLOAD_ROOTso the machine-side Helix client retains ownership of credentials and uploadshelix/__init__.pycontinuationrunner.pyMotivation
New AOT Helix queues no longer install the legacy Python
helixpackage. Existing JobSender consumers can still submit payloads that invokescriptrunner.py, causingModuleNotFoundErrorbefore their tests run and preventing their expected script logs andTestResults.zipfrom being published.This keeps public Arcade independent from the internal machine-client implementation. The shim only implements the submitted runner surface; the Helix client continues to own storage authentication, retries, uploads, and event publication.
Validation
dotnet test src/Microsoft.DotNet.Helix/JobSender.Tests/Microsoft.DotNet.Helix.JobSender.Tests.csproj --no-restore— 6 passedscriptrunner.pyshape end to end with a syntheticRunMstest.cmdTestResults.zipis staged underHELIX_WORKITEM_UPLOAD_ROOTMicrosoft.DotNet.Helix.JobSender.12.0.0-devand verified all compatibility files are presentRunnerScripts/scriptrunnerFollow-up
The AOT client change that emits legacy
Logsevents for staged.helix-logsfiles and fails work items on upload/event-publication failures is being handled indotnet-helix-machines.