Skip to content

test(cpu-imaging-py-test): Pillow + imageio + scikit-image carpet - #1875

Open
Lfan-ke wants to merge 1 commit into
rcore-os:devfrom
Lfan-ke:apps-starry-cpu-imaging-py-test
Open

test(cpu-imaging-py-test): Pillow + imageio + scikit-image carpet#1875
Lfan-ke wants to merge 1 commit into
rcore-os:devfrom
Lfan-ke:apps-starry-cpu-imaging-py-test

Conversation

@Lfan-ke

@Lfan-ke Lfan-ke commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

概述

apps/starry/cpu-imaging-py-test:Python imaging carpet(C 侧纯 CPU),OpenCV carpet 的 imaging 库对应项。每断言都是逐像素/element-exact 对 numpy/闭式金标 + 跨库一致,"import PIL"不是测试。库负责处理,仅 numpy/闭式参照+比对自写。确定性(np.random.seed 0x233,两跑一致)。

Cells 与断言(host 真跑绿, 三门 fail==0 && total==EXPECTED==pass, mutation-tested)

cell 断言
imaging_pil Image getpixel/resize NEAREST+BILINEAR闭式/rotate/convert L(601-2定点)/ImageDraw逐像素/ImageFilter核/PNG/BMP/PPM/TIFF/GIF byte-exact+JPEG PSNR/histogram/split-merge
imaging_imageio imread/imwrite各格式byte-exact+bytes encode/decode+JPEG PSNR+GIF/TIFF多帧+mp4(ffmpeg honest-skip)
imaging_skimage rgb2gray(BT.709)/rgb2hsv-lab/gaussian-sobel-otsu/resize-rotate-warp/morphology/canny-corner/regionprops(area/centroid/bbox)全vs numpy
imaging_realassets PIL+imageio+skimage解码同文件byte-exact一致+SHA+主色, honest-skip

共 114 断言。★PIL RGB→L(ITU-R 601-2, green 0.587)与 skimage rgb2gray(BT.709, 0.7154)各对自己文档公式(混淆即 bug)。自生成 24x24 sample.png(闭式腿), 真测试图在 git submodule(Lfan-ke/hw4os-s5d1t2 media 分支, git-LFS)经 ASSET_DIR. prebuild 建 honest per-arch manifest(cell 仅在 wheel 可 import 的 arch 列出)。

特殊声明:素材仅用于 OS 功能完整性 & 正确性验证,不作他用!有事请找:@Lfan-ke

复用 Pillow/imageio/scikit-image + 复用 py-sci numpy 不造轮子; 取包 pip download musllinux wheel 官方 HTTP; gen_goldens.py numpy 重导交叉核; seed 0x233。

关键文件: carpetsprebuild.sh

@mai-team-app mai-team-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

本 PR 新增 apps/starry/cpu-imaging-py-test,为四个架构提供 Pillow、imageio、scikit-image 的 QEMU 应用 carpet;它不改动 Starry syscall/ABI,book/guideline/starry/syscall.md 不适用。该变更属于新增的应用工作流,已按 feature-development.md 作为共享、运行时高风险能力审查;现有 py-sci2 是相邻的 Python 科学计算应用模式,未发现与基线实现重复,也未发现解决同一 imaging 交付的开放 PR(检索到的 GPU/Vulkan PR 仅为相邻而非重复)。

发现 1 个阻塞问题:依赖获取失败会被降级为缩小测试清单,导致所声明的 imageio/skimage 覆盖可被静默跳过而仍报告成功,详见行内评论。

验证:git diff --check origin/dev...HEADbash -n prebuild.sh programs/run_all.sh、Python AST/TOML 解析均通过;cargo xtask starry app qemu --help 成功构建并显示应用入口。未完成当前头的应用 QEMU 运行:PR 新增的应用未被本 PR 的 CI 工作流触发;组织 CI 的主 CI 工作流在该头为 failure,现有成功 job 不覆盖本应用。仓库的 starry-apps.yml 虽定义了四架构 cargo xtask starry app qemu --all,但仅按定时或手动触发,不能作为本 PR 的当前头运行证据。该缺口与上述静默降级共同使应用声明无法验证。

既有 review、行内评论和 PR 讨论均为空,没有待处理的旧线程。除上述问题外,未观察到本变更影响现有内核接口;修复后应在每个仍公开 QEMU 配置的架构上验证依赖安装及完整四个 cell 的真实运行结果。审查清单已完成:基线规范、应用布局/运行器、配置锚点、CI、重复/重叠和本地静态检查已核对;不适用项为 syscall ABI 和 crates.io patch(无 Cargo 元数据变更)。

Powered by gpt-5.6-terra

if ! "$pip" download "${PIP_PKGS[@]}" \
--dest "$WHEELS" --only-binary=:all: \
--python-version "$pymm" --implementation cp --abi "cp${pymm//./}" \
--platform "$pip_plat" --platform any 2>"$WHEELS/download.log"; then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

阻塞:这里把 pip download 失败当成成功返回,且 141-143 行也吞掉离线安装失败;之后 expected_cells 会删除 imageio/skimage/realassets,run_all.sh 仍会在只执行 PIL 的情况下输出 TEST PASSED。这会让缺少 musllinux wheel 的已声明架构(尤其是 RISC-V/LoongArch)在完全没有新增库覆盖时绿灯,与本 PR“四架构 Pillow + imageio + scikit-image carpet”的交付不一致。请将这些依赖的下载、安装和目标导入设为该应用支持架构的硬失败;如果某架构确实无法供应 wheel,请不要暴露该架构的 QEMU 配置,并在文档中明确缩小支持范围。

@mai-team-app mai-team-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

本 PR 新增 apps/starry/cpu-imaging-py-test,用四份 QEMU 配置交付 Pillow、imageio、scikit-image 的 Python imaging carpet。它不修改 Starry syscall/Linux ABI,因此 book/guideline/starry/syscall.md 不适用;作为新增可运行应用,按 feature-development.md 归为共享的运行时工作流审查。应用布局位于 apps/starry/,未观察到对现有内核接口或 Cargo 依赖解析(无 [patch.crates-io])的影响。

存在 1 个阻塞问题,见行内评论:依赖获取/安装失败会缩小 manifest,随后只运行 PIL 仍可输出 TEST PASSED,使公开宣称的 imageio/skimage 覆盖被静默跳过。这也延续了上一轮在祖先提交提出、但当前 head 未修复的合理意见。

验证结果:git diff --check origin/dev...HEADbash -n prebuild.shsh -n programs/run_all.sh 和 Python AST 编译均通过;cargo xtask starry app qemu --help 成功构建并确认应用入口。组织 CI 的当前 head 有 71 个 check(success=23、skipped=35、cancelled=12、failure=1);格式检查等成功,但没有当前头执行本新增 app 的完整四架构 QEMU 流程,故这些成功 job 不能证明本应用交付。CI 工作流为 failure,且当前代码的静默降级本身足以阻塞合入。

重复/重叠分析:基线中仅有相邻的 py-sci/py-sci2 Python 科学计算模式;开放 PR #1874 是 OpenCV carpet,和本 PR 的 imaging-library 覆盖互补而非重复。既有 PR 讨论为空;唯一历史行内意见已按当前 head 复核,仍未解决。

修复后请让每个保留 QEMU 配置的架构在 imageio/skimage 不可下载、不可安装或不可导入时失败;无法提供 wheel 的架构应移除配置并在 README 中缩小支持范围。随后执行相应架构的 cargo xtask starry app qemu -t cpu-imaging-py-test --arch <arch>,确认四个 cell 的运行证据。审查清单已完成;剩余阻塞项仅为上述覆盖伪成功及其运行验证。

Powered by gpt-5.6-terra

--platform "$pip_plat" --platform any 2>"$WHEELS/download.log"; then
echo "prebuild: pip could not resolve imageio/scikit-image wheels for $pip_plat (cp${pymm//./})" >&2
echo "prebuild: see $WHEELS/download.log; the imageio/skimage cells will honest-skip on-target" >&2
return 0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

阻塞(测试覆盖伪成功):这里把 pip download 失败作为成功返回,并吞掉离线安装失败;随后 manifest 会删除 imageio/skimage/realassets,run_all.sh 仍会在只执行 PIL 时输出 TEST PASSED。这会让已声明架构完全没有新增库覆盖时绿灯,和本 PR 的“四架构 Pillow + imageio + scikit-image carpet”交付不一致。请将这些依赖的下载、安装和目标导入设为支持架构的硬失败;若某架构确实无法提供 wheel,请移除其 QEMU 配置并在文档中明确缩小支持范围。

@mai-team-app
mai-team-app Bot requested a review from YanLien August 5, 2026 09:33
@Lfan-ke
Lfan-ke force-pushed the apps-starry-cpu-imaging-py-test branch 2 times, most recently from ee8e469 to 564d148 Compare August 6, 2026 15:06
Python imaging carpet (C-side, pure CPU) - the imaging-library counterpart of the OpenCV
carpet. Every assertion is per-pixel / element-exact vs a numpy / closed-form golden, plus
cross-library consistency; "import PIL" is NOT a test. The libs do the work; only the
numpy/closed-form reference + comparison are self-written. Deterministic; np.random.seed
0x233 on the only RNG paths (markers identical across runs).

Cells (three-gate fail==0 && total==EXPECTED==pass, mutation-tested):
- imaging_pil (45): Image new/getpixel/putdata, resize NEAREST block-exact + BILINEAR
  closed form, rotate/transpose/flip == np.rot90/reverse, convert RGB<->L (601-2 fixed
  point (R*19595+G*38470+B*7471+0x8000)>>16) + RGBA, ImageDraw rect/line/ellipse(pi r^2)/
  polygon/text analytic masks, ImageFilter BLUR/GaussianBlur/FIND_EDGES on impulse+step,
  PNG/BMP/PPM/TIFF/GIF byte-exact + JPEG PSNR, getbbox/histogram/split/merge/ImageChops.
- imaging_imageio (21): imread/imwrite PNG/BMP/TIFF/PPM/PGM byte-exact, in-memory bytes
  encode/decode, JPEG PSNR, GIF + volumetric TIFF multi-frame round-trip, improps.
- imaging_skimage (37): rgb2gray (BT.709 0.2125/0.7154/0.0721), rgb2hsv/lab round-trip,
  gaussian/sobel/threshold_otsu, resize/rescale/rotate/warp, morphology
  erosion/dilation/opening/closing, canny/corner_harris/corner_peaks, label/regionprops
  (area/centroid/bbox), exposure rescale/histogram, img_as_float/ubyte - all vs numpy.
- imaging_realassets (corpus-scaled): PIL + imageio + skimage decode the same file ->
  byte-exact agreement + shared SHA-256 + consistent dominant color, per staged image plus
  the committed red golden. A decode failure of a staged asset hard-fails; never a vacuous
  skip.

PIL RGB->L (ITU-R 601-2) and skimage rgb2gray (BT.709) are asserted against their OWN
documented formulas (green 0.587 vs 0.7154) - conflating them would be a bug. A tiny
committed programs/sample_red.png drives the pinned closed-form leg; real test images live
in a git submodule (Lfan-ke/hw4os-s5d1t2 media branch, git-LFS) via ASSET_DIR. prebuild
uses a fixed manifest (all four cells always run) - a missing imageio/scikit-image
musllinux wheel is a hard failure, not a silent per-arch drop.

Signed-off-by: 林晨/禾可 <chengkelfan@qq.com>
Signed-off-by: Leo Cheng <chengkelfan@qq.com>
@Lfan-ke
Lfan-ke force-pushed the apps-starry-cpu-imaging-py-test branch from 564d148 to fe3fb82 Compare August 6, 2026 15:48

@mai-team-app mai-team-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

本 PR 新增 apps/starry/cpu-imaging-py-test,以四个 QEMU 架构运行 Pillow、imageio 和 scikit-image 的 Python imaging carpet。它不改变 Starry syscall/Linux ABI,因此 book/guideline/starry/syscall.md 不适用;作为新增可运行应用,已按 feature-development.md 的共享运行时工作流要求审查。变更位于 apps/starry/,未影响现有内核接口,也没有 Cargo 或 [patch.crates-io] 改动。

存在 1 个阻塞问题,见行内评论:当前头实际执行 README 给出的 cargo xtask starry app qemu -t cpu-imaging-py-test --arch x86_64 后,apk 安装和目标 musllinux wheel 下载完成,但宿主 pip 安装 numpy-2.5.1-cp314-cp314-musllinux_1_2_x86_64.whl 时报告 is not a supported wheel on this platform,预构建以状态 5 失败,QEMU 未启动。因此该新增应用当前无法在已声明的 x86_64 支持路径运行。

验证:git diff --check origin/dev...HEADbash -n prebuild.sh programs/run_all.sh、所有新增 Python 文件的 AST 解析和八份 TOML 解析均通过;cargo xtask starry app qemu --help 已成功构建。组织当前头的 check-runs 为 success=3、skipped=6、cancelled=2;其中没有执行本新增应用的四架构 QEMU 工作流(starry-apps.yml 仅定时或手动触发),故这些成功检查不能覆盖本问题。

基线中相邻的 py-sci/py-sci2 是 Python 科学计算应用模式;开放 PR #1874 是 OpenCV carpet,覆盖互补而非重复。PR 讨论为空;此前关于静默缩小 manifest 的合理评论已在当前头通过固定 manifest 和导入硬失败得到处理。请先修复 wheel 的目标端安装路径,并重新执行每个公开架构的文档命令,确认四个 cell 真实运行后再请求复审。

Powered by gpt-5.6-terra

exit 5
fi
echo "prebuild: installing wheels offline into $sitepkgs"
"$pip" install --no-index --find-links "$WHEELS" --target "$sitepkgs" --upgrade \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

阻塞(应用预构建失败):这里用宿主 pip 安装前面按 musllinux 目标下载的 wheel,却没有使用目标解释器或目标平台。实测按当前下载参数取得 numpy-...-musllinux_1_2_x86_64.whl 后,执行这条 pip install --target ... --no-deps *.whl 直接报 is not a supported wheel on this platform 并退出 1,因此 x86_64 在 QEMU 前就无法生成 overlay,四架构应用声明也无法成立。请改为在 qemu-user/staging root 内用目标 python3 -m pip 离线安装,或安全地解包到 target site-packages,并保留目标端依赖导入验证。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant