From 582c5a3893d18f9c1d2c317121a3ee7dc9086ee8 Mon Sep 17 00:00:00 2001 From: Travis Date: Thu, 13 Aug 2026 06:40:51 -0700 Subject: [PATCH] Run the Docker build checks with python -I The image carries two copies of the package: the source tree that COPY . . places at /app, and the copy pip builds into site-packages. The source tree has every data file, because they are checked into git. The installed copy has only what package_data selected, which is what was broken in 0.1.2. The build checks were reading the wrong copy. Both ran under WORKDIR /app, and python -c puts the working directory at the head of sys.path, so `import BLIMMP_Scripts` found /app/BLIMMP_Scripts and never reached site-packages. Nothing outside the image was involved; both copies are baked in. Two consequences, both visible in the published 0.1.3 image: - The packaged-data assertion inspected the source tree, where the five required files exist by construction. It could not fail. That is why the broken 0.1.2 image built cleanly, and it means the guard added against a packaging regression did nothing. - ensure_module_graphs() resolved its target directory relative to the source copy, so the KEGG module graphs extracted into /app, which nothing reads at run time. site-packages received none of the 340 module_*_nodes.json files, so every run re-extracts from the zip into a cache dir instead of using graphs baked into the image. Run time was never affected. The BLIMMP console script lives in /usr/local/bin, and for a script Python puts the script's own directory on sys.path rather than the working directory, so real runs have always imported from site-packages. -I (isolated mode) keeps the working directory off sys.path, so both commands resolve to the installed copy. The assertion now fails the build if package_data drops a file again. Verified against the published 0.1.3 image by pulling its layers from ghcr: site-packages holds the data files but no extracted graphs, and the extraction sits under /app instead. Once merged, bump the version to 0.1.4 and tag v0.1.4 to publish an image with the graphs pre-extracted. Implemented with assistance from Claude (Opus 5) --- Dockerfile | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index f3ac893..ec33bd9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,10 +10,16 @@ RUN pip install --no-cache-dir . # Singularity mounts the image read-only at run time, so leaving this to first # use would fail on HPC. Also fails the build if the data files did not make it # into the installed package. -RUN python -c "\ +# +# -I (isolated mode) keeps the working directory off sys.path. Without it both +# commands below import the COPYed source tree at /app instead of the installed +# package: the graphs get extracted into /app where nothing reads them, and the +# assertion inspects the source tree, where the files trivially exist and so can +# never fail. Do not drop the flag. +RUN python -I -c "\ from BLIMMP_Scripts.module_detection import ensure_module_graphs; \ print('module graphs:', ensure_module_graphs())" \ - && python -c "\ + && python -I -c "\ import BLIMMP_Scripts, pathlib, sys; \ root = pathlib.Path(BLIMMP_Scripts.__file__).parent; \ required = ['Data_Dependencies/kegg_bacteria_modules.json', \