Repository navigation
Run checks that import TensorFlow on a Python 3.14 runtime - #53
Merged
Merged
Conversation
TensorFlow trails new Python releases by about a year, and because this image is FROM cs50/cli, it has been the reason cs50/cli could not move its python3 forward (cs50/cli#254). The TensorFlow stack now lives in a venv on Ubuntu 26.04's python3.14 at /opt/tensorflow, and docker-entry.sh routes a job there when check50-runtime finds that its checks import tensorflow, tf_keras, keras, or transformers. Every other job stays on cs50/cli's python3, which no longer has TensorFlow installed at all. The whole check50 process moves, not just the student's python3, because the affected checks (ai50/projects traffic and attention) import tensorflow in the check module and load student code in-process via check50.py.import_. Both runtimes get requirements.txt so a check behaves the same on either; only requirements-tensorflow.txt differs. The smoke test asserts the default runtime cannot import TensorFlow, the routing picks the right checks, and check50 grades a TensorFlow submission end to end on the 3.14 runtime.
…eels requirements.txt is installed into both runtimes, and cs50/cli:canary is now Python 3.15 (cs50/cli#256), so each pin needs cp314 and cp315 wheels. These are the first versions of each that have both; no pandas 2.x has cp315. Pillow's JPEG output decides whether a CS50P shirt submission passes (the check byte-hashes the saved image), so the reference solution was run against the check's six muppet inputs under Pillow 11.3.0, 12.3.0, and 13.0.0: all six hashes match on every version. Verified by building the Python layers FROM cs50/cli:latest (3.14) and cs50/cli:canary (3.15) and running the smoke test's Python sections on each.
…'s flags Ubuntu 26.04's python3.14 package stays at 3.14.4 for the life of the release and backports security fixes only, so TensorFlow checks would have graded on an interpreter behind the one students had on 3.14. The runtime is now CPython 3.14.10 built with the same configure flags as cs50/cli, installed with /opt/tensorflow as its prefix and an rpath so libpython resolves without an ld.so.conf entry. Bumping it is one version string. The smoke test asserts the runtime is this build (prefix, CONFIG_ARGS, and libpython from /opt/tensorflow/lib) and that its stdlib extension modules import, so a fallback to some other 3.14 cannot pass unnoticed.
… test suite A pin bump in either requirements file no longer rebuilds CPython from source: the build, which is the slowest layer, now sits above both COPYs, and both runtimes are installed from one layer that also cleans up after itself. The -dev packages join the first apt-get install, and check50-runtime is copied in beside docker-entry.sh so editing it does not re-run the TensorFlow import check. cs50/cli's configure line passes --without-tests, which is not a CPython option (autoconf ignores it), so the runtime was shipping Lib/test and the _test* extension modules, ~116 MB. The flag is now --disable-test-modules, and the version is one ARG. The smoke test passes TF_PREFIX and TF into each container instead of splicing them into quoted scripts, shares the non-TensorFlow stack assertions between the two runtime sections so they cannot drift, and adds an unparsable check to the routing fixtures: check50-runtime must still exit 0 with no output, leaving the error for check50 to report, or docker-entry.sh's set -e would kill the job first. check50-runtime's usage line is a constant rather than a docstring index, and comments that restated adjacent code are gone.
rongxin-liu
added a commit
to cs50/cli
that referenced
this pull request
Nov 25, 2026
…test suite configure has been warning "unrecognized options: --disable-static, --without-tests" on every build. Neither is a CPython option. --disable-static did nothing (a shared build installs no libpython.a), and --without-tests quietly shipped Lib/test plus the _test* extension modules, 176 MB in the 3.15 image. --disable-test-modules is the real flag; PGO training still runs from the source tree, and lib/python3.15 drops to 225 MB. The smoke test asserts Lib/test and _testcapi are absent so a return to the no-op flag cannot pass. (Spotted by rongxin-liu while reviewing cs50/check#53.)
This was referenced Nov 26, 2026
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.
Summary
check50 jobs whose checks import TensorFlow now run on a Python 3.14 runtime of their own, so cs50/cli's
python3no longer has to wait for TensorFlow to support a new Python before it can move. Every other job runs on cs50/cli'spython3as before, and that runtime no longer has TensorFlow installed at all.This is the first half of the Python 3.15 move and is safe to merge on its own:
mainbuildsFROM cs50/cli:latest, still 3.14, so nothing about how a job runs changes beyond TensorFlow checks running on a 3.14.10 built here rather than in cs50/cli. Thecs50/clihalf (cs50/cli#256) waits oncs50/server,cs50/codespace, the EB apps, and recompiling the.pycchecks oncs50/problems@2022/pythonfor 3.15.Why the whole check50 process moves
It is not enough to swap the student's
python3. The two TensorFlow checks (ai50/projectstrafficandattention)import tensorflowin the check module itself and load student code into the check50 process withcheck50.py.import_. Sodocker-entry.shprepends the runtime'sbintoPATHbefore invokingcheck50, which switches check50,python3, and anything the checks spawn in one step.Design decisions
/opt/tensorflowas its prefix, so TensorFlow checks grade on the same interpreter students had on 3.14. Ubuntu'spython3.14package was considered and rejected: it stays at 3.14.4 for the life of the release with security backports only. The build adds ~4 min; bumping it is oneARG. One flag differs from cs50/cli: its--without-testsis not a CPython configure option (autoconf ignores it), so that build shipsLib/testand the_test*modules, ~116 MB. This runtime passes--disable-test-modulesinstead; cs50/cli should get the same fix.check50-runtimeno longer re-runs the TensorFlow import check.requirements.txt. Onlyrequirements-tensorflow.txtdiffers. A student'straffic.pythat also importspandasbehaves the same whichever runtime its job lands on, and a routing false positive is harmless. Cost: ~300 MB of duplicated non-TF packages; the image is 10.0 GB vs 10.2 GB for currentlatest, since the 2.1 GB TF stack moved rather than duplicated.ast, notgrep.check50-runtimescans the problem directory lib50 returns for imports oftensorflow,tf_keras,keras, ortransformers. It catchesimport numpy, tensorflow as tf,from tensorflow.keras import …, and imports inside functions, and ignores comments and strings. A check it cannot parse routes to the default runtime and exits 0, so check50 reports the syntax error rather thandocker-entry.sh'sset -eending the job first. It does not followcheck50.import_checks("../other")into sibling directories; no ai50 check uses that.requirements.txtnow has to install on both 3.14 and 3.15,numpy,pandas,scikit-learn, andPillowmove to the first versions with both cp314 and cp315 wheels (2.5.5,3.0.6,1.9.1,12.3.0); no pandas 2.x has cp315. The CS50Pshirtcheck byte-hashes the JPEG a student's Pillow writes, so the reference solution was run against the check's six inputs under Pillow 11.3.0, 12.3.0, and 13.0.0: all six hashes match on every version.Against the real local clone of
ai50/projects:trafficandattentionroute to 3.14;shopping,parser,nimstay on the default runtime.Verification
Built for arm64 and ran
tests/smoke.shon the finished image (first commit); every check passed. The pin bump was then verified by building the Python layersFROM cs50/cli:latest(3.14) andFROM cs50/cli:canary(3.15) and running the smoke test's Python sections on each: both pass, with the TensorFlow runtime at 3.14.10 either way. CI here builds againstcanary, so the run on this PR is the real 3.15-base configuration.The last commit (layer order,
--disable-test-modules, smoke-test changes) has not been built locally. It was checked bybash -n, by runningcheck50-runtimeagainst every routing fixture, and by a dry run oftests/smoke.shagainst a stubdockerthat confirmed each in-container script parses; the CI run on this push is its first full build.New assertions, so a rebuild cannot quietly undo the split:
tensorflow,tf_keras,keras, ortransformerscheck50-runtimeroutes five fixture check dirs correctly and exits 0 with no output on an unparsable onecheck50 --devon the 3.14 runtime grades a TensorFlow-using check against a TensorFlow-usingtraffic.pyend to end, including acheck50.run("python3 …")subprocess that must report(3, 14)tf_keras/TFBertForMaskedLMassertions now run on the 3.14 runtime, at build time and in the smoke testsys.prefixis/opt/tensorflow,CONFIG_ARGScarries the optimization flags,libpython3.14resolves from its prefix, and every stdlib extension module importsThe non-TensorFlow stack assertions (imports, nltk data, cv2, scikit-learn) are one shared snippet run on each runtime, so the two sections cannot drift apart.
Related: cs50/cli#254