mirror of
https://github.com/samsledje/D-SCRIPT.git
synced 2026-06-04 15:04:24 +08:00
* Expand test coverage with comprehensive test suites Add extensive test coverage for previously untested modules: - test_utils.py: Comprehensive tests for utility functions (setup_logger, log, RBF, parse_device, load_hdf5_parallel, PairedDataset, collate_paired_sequences) - test_glider.py: Complete test suite for graph-based link prediction module (get_dim, densify, compute_X_normalized, scoring functions, GLIDE algorithms) - test_loading.py: Tests for parallel HDF5 data loading with LoadingPool, including edge cases, error handling, and integration tests - test_language_model.py: Expanded from 2 to 13 test methods, adding coverage for lm_embed, embed_from_fasta with various edge cases and validations These additions significantly improve test coverage for: - dscript/utils.py (167 lines, previously untested) - dscript/glider.py (346 lines, previously untested) - dscript/loading.py (92 lines, previously untested) - dscript/language_model.py (minimal coverage expanded) Total new test methods: ~200+ assertions across 4 test modules * Add comprehensive tests for command modules and worker functions Create four new test modules to expand coverage of previously untested code: 1. test_extract_3di.py (19 test methods, ~370 lines) - Tests for 3Di sequence extraction from PDB/CIF files - Argument parsing, file filtering, FASTA output validation - Integration tests for full workflow - Covers dscript/commands/extract_3di.py (~58 lines) 2. test_par_writer.py (24 test methods, ~400 lines) - Tests for parallel prediction writer process - TSV output writing, threshold filtering, contact map storage - HDF5 contact map dataset handling - Progress tracking and data type validation - Covers dscript/commands/par_writer.py (~40 lines) 3. test_main.py (24 test methods, ~320 lines) - Tests for CLI entry point and argument parsing - CitationAction class testing - All subcommand registration and invocation - Version and help flag handling - Integration tests for command dispatch - Covers dscript/__main__.py (~87 lines, increasing from ~85% to ~95%) 4. test_load_worker.py (23 test methods, ~330 lines) - Direct unit tests for HDF5 loading worker function - Queue handling, data type conversion, memory sharing - Error handling for corrupted/missing files - Multi-dimensional array support - Covers dscript/load_worker.py (~25 lines, previously only indirect coverage) Total additions: - ~1,420 lines of new test code - 90+ test methods with comprehensive assertions - ~210 lines of source code now directly tested - Addresses high-priority gaps identified in coverage analysis These tests complement the existing suite and focus on command-line interface components and parallel processing infrastructure. * Fix linting issues and apply code formatting - Remove unused variables flagged by ruff - Apply ruff formatting to all test files - Ensure all pre-commit hooks pass Changes: - test_loading.py: Remove unused 'f' variable - test_main.py: Remove unused 'fake_out' and 'output' variables - test_utils.py: Remove unused 'log_file' variable and tmp_path param - Applied ruff formatting to maintain code style consistency * Fix test_load_worker.py hanging issue in CI Rewrote test_load_worker.py to prevent CI hangs that occurred when tests called the blocking worker function directly. The worker function _hdf5_load_partial_func runs in an infinite loop waiting on a queue, which caused tests to hang indefinitely. Changes: - Created run_worker_with_timeout() helper that wraps worker execution in a daemon thread with configurable timeout (default 5 seconds) - Modified all tests to use this helper and assert successful completion - Changed queue operations from blocking get() to non-blocking get_nowait() - Reduced test count from 23 to 16 focused tests - Added documentation noting worker is primarily tested via LoadingPool This should resolve the CI timeout issue where tests hung at 43% completion. * Rewrite test_language_model.py to use mocks instead of real model The original tests were calling the real language model which: - Downloads/loads pretrained model weights (slow, can fail) - Runs actual neural network inference (resource intensive) - Causes test failures when model files aren't available Changes: - Rewrote unit tests to mock get_pretrained() function - Mock model returns realistic tensor shapes but doesn't load weights - Tests are now fast, reliable, and don't require model files - Moved real model tests to TestLanguageModelIntegration class - Marked integration tests with @pytest.mark.slow so they can be skipped - Removed unnecessary loguru import that caused import errors - Removed problematic setup.py install step from setup_class This should fix the 4 failing tests reported by CI. * fix failing tests * Update .github/workflows/autorun-tests.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update .github/workflows/autorun-tests.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Add test coverage report for easy reference Generated comprehensive test coverage report showing: - Total coverage: 51% (2230 statements, 1099 missing) - 294 tests passing (excluding slow tests) - 13 tests failing (related to external model downloads) Key improvements from test expansion: - utils.py: 100% coverage (was 0%) - glider.py: 98% coverage (was 0%) - load_worker.py: 100% coverage (was 0%) - alphabets.py: 100% coverage (maintained) - models/contact.py: 100% coverage (maintained) - models/embedding.py: 97% coverage (improved) - models/interaction.py: 95% coverage (improved) This report can be regenerated with: uv run pytest --cov=dscript --cov-report=term-missing -m "not slow" 2>&1 | tee coverage_report.txt * Add .coverage to .gitignore * add coverage text file --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
59 lines
3.9 KiB
Plaintext
59 lines
3.9 KiB
Plaintext
============================= test session starts ==============================
|
|
platform linux -- Python 3.12.11, pytest-9.0.2, pluggy-1.6.0
|
|
rootdir: /mnt/home/ssledzieski/GitHub/D-SCRIPT
|
|
configfile: pyproject.toml
|
|
testpaths: dscript/tests
|
|
plugins: anyio-4.12.0, cov-7.0.0
|
|
collected 309 items / 2 deselected / 307 selected
|
|
|
|
dscript/tests/test_alphabets.py ........................ [ 7%]
|
|
dscript/tests/test_commands.py .......... [ 11%]
|
|
dscript/tests/test_extract_3di.py ............ [ 14%]
|
|
dscript/tests/test_fasta.py ......... [ 17%]
|
|
dscript/tests/test_foldseek.py ............. [ 22%]
|
|
dscript/tests/test_glider.py ........................................... [ 36%]
|
|
....... [ 38%]
|
|
dscript/tests/test_language_model.py ......... [ 41%]
|
|
dscript/tests/test_load_worker.py ............. [ 45%]
|
|
dscript/tests/test_main.py ......................... [ 53%]
|
|
dscript/tests/test_models_contact.py ................. [ 59%]
|
|
dscript/tests/test_models_embedding.py ........................... [ 68%]
|
|
dscript/tests/test_models_interaction.py ............................ [ 77%]
|
|
dscript/tests/test_par_writer.py ................ [ 82%]
|
|
dscript/tests/test_pretrained.py .................... [ 88%]
|
|
dscript/tests/test_utils.py .................................. [100%]
|
|
|
|
================================ tests coverage ================================
|
|
_______________ coverage: platform linux, python 3.12.11-final-0 _______________
|
|
|
|
Name Stmts Miss Cover Missing
|
|
---------------------------------------------------------------------
|
|
dscript/__init__.py 5 0 100%
|
|
dscript/__main__.py 35 1 97% 87
|
|
dscript/alphabets.py 49 0 100%
|
|
dscript/commands/__init__.py 1 0 100%
|
|
dscript/commands/embed.py 32 13 59% 47-59, 63-65
|
|
dscript/commands/evaluate.py 169 128 24% 112-154, 161-170, 180-291, 295-297
|
|
dscript/commands/extract_3di.py 33 4 88% 55-58
|
|
dscript/commands/par_worker.py 64 57 11% 22-121
|
|
dscript/commands/par_writer.py 31 0 100%
|
|
dscript/commands/predict_bipartite.py 199 143 28% 137-152, 155-159, 162-171, 174-176, 181-208, 220-418, 422-424
|
|
dscript/commands/predict_block.py 289 243 16% 127-561, 565-567
|
|
dscript/commands/predict_serial.py 176 136 23% 97-295, 299-301
|
|
dscript/commands/train.py 358 264 26% 265-301, 331-342, 394-454, 484-532, 537-831, 841-869, 873-875
|
|
dscript/fasta.py 44 6 86% 61-66
|
|
dscript/foldseek.py 35 1 97% 70
|
|
dscript/glider.py 185 3 98% 106-108
|
|
dscript/language_model.py 73 15 79% 31, 39, 61-63, 74, 85, 108-109, 129-134
|
|
dscript/load_worker.py 14 0 100%
|
|
dscript/loading.py 69 58 16% 15-34, 38-59, 63-85, 88-92
|
|
dscript/models/__init__.py 1 0 100%
|
|
dscript/models/contact.py 44 0 100%
|
|
dscript/models/embedding.py 76 2 97% 143-144
|
|
dscript/models/interaction.py 94 5 95% 201-206, 229
|
|
dscript/pretrained.py 88 1 99% 109
|
|
dscript/utils.py 66 0 100%
|
|
---------------------------------------------------------------------
|
|
TOTAL 2230 1080 52%
|
|
================= 307 passed, 2 deselected in 94.25s (0:01:34) =================
|