Skip to content

Commit 88fab44

Browse files
author
Jon Palmer
committed
Fix: Make annorefine import optional for CI compatibility
- Make annorefine import optional in log.py with try/except - Add ANNOREFINE_AVAILABLE flag to check if module is installed - Update system_info() to conditionally include annorefine version - Add annorefine to macOS CI workflow dependencies - Fixes ImportError in unit tests when annorefine is not installed This allows the test suite to run even when annorefine is not available, while still supporting the full functionality when it is installed.
1 parent bd0a02e commit 88fab44

2 files changed

Lines changed: 25 additions & 10 deletions

File tree

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
if [[ "${{ matrix.use_conda }}" == "true" ]]; then
5656
# Use conda for macOS to avoid mappy build issues
5757
conda install -c conda-forge -c bioconda mappy numpy pytest pytest-cov -y
58-
pip install natsort gfftk buscolite gapmm2 pyhmmer pyfastx requests gb-io json-repair pytantan
58+
pip install natsort gfftk buscolite gapmm2 pyhmmer pyfastx requests gb-io json-repair pytantan annorefine
5959
pip install -e . --no-deps
6060
else
6161
# Linux - use pip as normal

funannotate2/log.py

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55

66
import buscolite
77
import gfftk
8-
import annorefine
8+
9+
try:
10+
import annorefine
11+
ANNOREFINE_AVAILABLE = True
12+
except ImportError:
13+
ANNOREFINE_AVAILABLE = False
914

1015
from .__init__ import __version__
1116
from .utilities import human_readable_size
@@ -110,15 +115,25 @@ def system_info(log):
110115
Returns:
111116
- None
112117
"""
113-
log(
114-
"Python v{}; funannotate2 v{}; gfftk v{}; buscolite v{}; annorefine v{}".format(
115-
platform.python_version(),
116-
__version__,
117-
gfftk.__version__,
118-
buscolite.__version__,
119-
annorefine.__version__,
118+
if ANNOREFINE_AVAILABLE:
119+
log(
120+
"Python v{}; funannotate2 v{}; gfftk v{}; buscolite v{}; annorefine v{}".format(
121+
platform.python_version(),
122+
__version__,
123+
gfftk.__version__,
124+
buscolite.__version__,
125+
annorefine.__version__,
126+
)
127+
)
128+
else:
129+
log(
130+
"Python v{}; funannotate2 v{}; gfftk v{}; buscolite v{}".format(
131+
platform.python_version(),
132+
__version__,
133+
gfftk.__version__,
134+
buscolite.__version__,
135+
)
120136
)
121-
)
122137

123138

124139
def finishLogging(log, module):

0 commit comments

Comments
 (0)