Repository navigation
Fix azure SDK namespace shadowing in CRUD pipeline steps (run via -m crud.main) - #1317
Closed
Xu Xue (xuexu6666) wants to merge 1 commit into
Closed
Xu Xue (xuexu6666) wants to merge 1 commit into
Xu Xue (xuexu6666) wants to merge 1 commit into
Conversation
The crud engine/machine steps ran main.py as a file (python3 $PYTHON_SCRIPT_FILE), which puts modules/python/crud/ on sys.path[0]. After Azure#1231 added crud/azure/__init__.py, that regular package shadows the installed 'azure' SDK namespace, so 'from azure.core.exceptions import ...' fails with ModuleNotFoundError: No module named 'azure.core'. Invoke as a module instead (python3 -m crud.main) so sys.path[0] is modules/python: the azure SDK resolves from site-packages and crud.azure still imports. Drop the now-unused PYTHON_SCRIPT_FILE env var.
Xu Xue (xuexu6666)
requested review from
Alyssa Vu (alyssa1303),
Sumanth Reddy CH (sumanthreddy29),
Vittoria (vittoriasalim) and
xinWeiWei24
as code owners
September 9, 2026 15:06
Xu Xue (xuexu6666)
requested review from
Leonard Du (LeonardCareer),
Liyu Ma (liyu-ma) and
Lei Yao (wonderyl)
as code owners
September 9, 2026 15:06
|
For reviewers only: reply |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The changes consistently apply the -m crud.main invocation and remove the unused env var across all listed pipeline steps, directly addressing the verified namespace-shadowing failure mode.
Pull request overview
This PR fixes Azure SDK import failures in the GPU Cluster CRUD / Machine-API pipeline steps by avoiding Python namespace shadowing (crud/azure shadowing the installed azure SDK) when invoking the CRUD entrypoint.
Changes:
- Switch CRUD execution from running
crud/main.pyas a file to running it as a module (python3 -m crud.main) sosys.path[0]ismodules/pythonrather thanmodules/python/crud. - Remove the now-unneeded
PYTHON_SCRIPT_FILEenvironment variable from the affected pipeline steps.
File summaries
| File | Description |
|---|---|
| steps/engine/machine/k8s/execute.yml | Invoke Machine API CRUD via python3 -m crud.main and drop PYTHON_SCRIPT_FILE. |
| steps/engine/machine/k8s/collect.yml | Invoke result collection via python3 -m crud.main and drop PYTHON_SCRIPT_FILE. |
| steps/engine/crud/k8s/execute.yml | Invoke CRUD create/scale/workloads/delete via python3 -m crud.main and drop PYTHON_SCRIPT_FILE. |
| steps/engine/crud/k8s/collect.yml | Invoke CRUD collection via python3 -m crud.main and drop PYTHON_SCRIPT_FILE. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
The GPU Cluster CRUD pipeline (and other CRUD/Machine-API pipelines) have failed on every run since #1231 merged. Both CRUD tasks fail immediately:
azure-coreis installed correctly by "Install Dependencies" — this is namespace shadowing, not a missing dependency.Root cause
The steps run the script as a file:
Running
python3 .../crud/main.pyputs the script's own directory —modules/python/crud/— atsys.path[0]. #1231 addedmodules/python/crud/azure/__init__.py, turningcrud/azure/into a regular package. Found first onsys.path, it shadows the installedazureSDK namespace package, soazure.corecan no longer be resolved.Unit tests didn't catch this because pytest runs with a different
sys.paththat never placescrud/atsys.path[0].Fix
Invoke the module with
-minstead of running the file.python3 -m crud.mainputsmodules/python(the working directory) onsys.path[0]instead ofcrud/, so theazureSDK resolves from site-packages whilecrud.azurestill imports. This is also what thetelescope-crudentry point registered in #1231 was intended for. The now-unusedPYTHON_SCRIPT_FILEenv var is removed.Applied to all affected engine steps:
steps/engine/crud/k8s/execute.ymlsteps/engine/crud/k8s/collect.ymlsteps/engine/machine/k8s/execute.ymlsteps/engine/machine/k8s/collect.ymlVerification
Reproduced the shadowing and confirmed the fix locally: