[chassis_base] Import device_info and fix chassis_base_test imports (fixes 202608 build) - #130
Merged
Ying Xie (yxieca) merged 1 commit intoAug 24, 2026
Conversation
PR Azure#128 backported upstream sonic-net/sonic-platform-common#731 ("Provide BMC defaults for system status LED methods in ChassisBase") into 202608. The cherry-pick applied without conflict, but it landed code that depends on imports 202608 does not have, breaking the build: * sonic_platform_base/chassis_base.py references `device_info` in initizalize_system_led(), set_status_led() and get_status_led(), but never imports it -> NameError. * tests/chassis_base_test.py uses `mock` and the `chassis_base` module in the new tests, but imports neither -> the module fails to import and pytest cannot collect the file. Upstream carries that import from sonic-net/sonic-platform-common#700 ("[CPO] Extend ChassisBase to support CPO ports"), later hardened by sonic-net/sonic-platform-common#734 ("Allow device_info import to fail in chassis_base.py"). Neither was backported to 202608, so PR Azure#128's premise that chassis_base.py "already has" the import does not hold on this branch. Backport only the import from #734, keeping the try/except form so the file matches upstream master and future 202605 -> 202608 merges do not conflict here. The CPO hunks of #700/#734 are deliberately left out: 202608 has no CPO support, and this is a build fix, not a feature backport. The regression test from #734 is included, minus its CPO-only assertions. (cherry picked from commit 20ce85f04bbcbb0dd0f37c15e4c2ce5fb31f9dfb, partial) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: ae309a30-f718-45f3-804d-645a8384d80d Signed-off-by: Ying Xie <ying.xie@microsoft.com>
Ying Xie (yxieca)
deleted the
yxieca/202608-chassis-base-device-info-import
branch
August 24, 2026 16:37
7 tasks
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.
Description
202608currently fails to build. PR #128 backported upstream sonic-net/sonic-platform-common#731 (Provide BMC defaults for system status LED methods in ChassisBase) into this branch. The cherry-pick applied without conflict, but it landed code that depends on imports202608does not have:sonic_platform_base/chassis_base.pydevice_info(3 call sites)NameErrortests/chassis_base_test.pymocktests/chassis_base_test.pychassis_baseBecause the decorators are evaluated at class-body time, pytest cannot even collect
tests/chassis_base_test.py.Why the import is missing
Upstream gets
device_infoinchassis_base.pyfrom sonic-net/sonic-platform-common#700 ([CPO] Extend ChassisBase to support CPO ports), which added it in order to calldevice_info.get_cpo_data(). It was later hardened by sonic-net/sonic-platform-common#734 (Allow device_info import to fail in chassis_base.py).Neither was backported to
202608. PR #128's description states:That is true on
master, but not on202608. The description was carried over verbatim from the upstream PR by the automated backport, so the missing prerequisite went unnoticed.What this PR does
Backports only the import from #734, and adds the two missing test imports.
Deliberately not included:
cpo_data/construct_cpo_devices) —202608has no CPO support, and this is a build fix, not a feature backportmock_get_cpo_data,get_num_cpos)The
try/except ImportErrorform is kept rather than a plain import so this hunk matches upstreammasterbyte-for-byte, meaning future202605→202608auto-merges will not conflict here. It also matches the contract asserted by #128's owntest_system_led_no_device_info, which exercises thedevice_info is Nonepath.Motivation and Context
Unblocks the
202608sonic-buildimagebuild.How Has This Been Tested?
python -m py_compilepasses on both filespyflakesreports no undefined names (previouslymockandchassis_basewere undefined)test_device_info_import_failurecovers thedevice_info is NonepathNote:
202607,202601and other branches carrying #128-style backports may have the same gap; not checked here.