fix: pin pytantan to 0.1.3 and add defensive lazy import#67
Merged
Conversation
Reverts pytantan to the v0.1.3 build recipe that was confirmed working in production, and moves the pytantan import inside softmask_fasta() so a broken pytantan installation no longer SIGILLs unrelated funannotate2 subcommands (--help, install, etc.). - pyproject.toml / pixi.toml / pixi.lock: pin pytantan to 0.1.3 (PyPI). v0.1.4's runtime SIMD dispatch has been unreliable on x86_64 hosts without AVX2 (notably Rosetta 2 on Apple Silicon). v0.1.3 builds cleanly with HAVE_AVX2:BOOL=OFF and funannotate2 only uses RepeatFinder / default_scoring_matrix which exist in both versions. - Dockerfile: restore the minimal SKBUILD_CMAKE_ARGS-based rebuild (scikit-build-core's own env var, semicolon-separated, bypasses the env-var filtering that affects CMAKE_ARGS). Keep the objdump and file-presence guards as cheap insurance against any regression. - funannotate2/fastx.py: defer 'from pytantan.lib import ...' to inside softmask_fasta(); raise a descriptive RuntimeError on ImportError so the failure mode is actionable instead of a SIGILL at process start. - funannotate2/predict.py: wrap the softmask_fasta() call in try/except, restore the original FASTA on failure, log critical message, and exit cleanly with code 1.
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
Belt-and-braces fix for the recurring
Illegal instructionSIGILL when running thefunannotate2Docker image under Rosetta 2 on Apple Silicon. Combines a known-working pytantan version with defensive import handling so that even a brokenpytantaninstallation can no longer take down the entire CLI.Changes
1. Pin
pytantanto v0.1.3pyproject.toml:pytantan>=0.1.4→pytantan>=0.1.3pixi.toml:pytantan = ">=0.1.4"→pytantan = "==0.1.3"pixi.lock: regenerated viapixi update pytantan(now resolves to 0.1.3)v0.1.3 was the last release with a straightforward CMake gate where
HAVE_AVX2=OFFis sufficient to produce a portable build. v0.1.4's runtime SIMD dispatch added complexity without giving us anything we use — funannotate2 only consumesRepeatFinderanddefault_scoring_matrix, which are identical in both versions.2. Restore the proven Dockerfile recipe
SKBUILD_CMAKE_ARGSis scikit-build-core's own env var (semicolon-separated CMake list) and is passed directly into the innercmakeinvocation, bypassing the env-var filtering that affected previous attempts withCMAKE_ARGS. The objdump + file-presence guards are retained as cheap insurance — they will fail the build loudly if any AVX2 instructions sneak in.3. Defensive lazy import in
funannotate2/fastx.pyMoved
from pytantan.lib import RepeatFinder, default_scoring_matrixfrom module top intosoftmask_fasta(), wrapped intry/except ImportError→ raises a descriptiveRuntimeError. As a result:funannotate2 --help,funannotate2 install, etc. never crash even if pytantan is broken in the user's environment.4. Graceful handling in
funannotate2/predict.pyWrapped the
softmask_fasta()call intry/except (RuntimeError, ImportError):Validation
tests/unit/test_predict.py+test_fastx.pypass.test_predict_functions.py,test_predict_comprehensive.py,test_fastx_additional.py,test_fastx_more.pypass.funannotate2.fastximports cleanly withpytantanblocked at the meta-path level, and thatsoftmask_fasta()then raises a descriptiveRuntimeErroronly when invoked.Post-merge action
The
docker.ymlworkflow only publishes:lateston release tags or manualworkflow_dispatch. After merging this PR, run Actions → Build and Publish Docker Image → Run workflow onmain(withpush=true) to republish:latestwith the working v0.1.3 image.Pull Request opened by Augment Code with guidance from the PR author