Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/streaming fix windows #48

Merged
merged 13 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 10 additions & 13 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,23 @@ jobs:
experimental: [false,]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest pytest-cov wheel
pip install -e .
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
run: uv sync --all-extras --dev

- name: Run unit and system tests
run: |
pytest -v --cov=mokapot tests/
uv run pytest -v --cov=mokapot tests/

- name: Upload coverage to codecov
uses: codecov/codecov-action@v3
with:
Expand Down
3 changes: 2 additions & 1 deletion mokapot/brew.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ def brew(
max_workers=max_workers,
)
)
# If model training has failed
else:
logging.info("Model training failed. Setting scores to zero.")
scores = [np.zeros(x) for x in data_size]
# Find which is best: the learned model, the best feature, or
# a pretrained model.
Expand Down Expand Up @@ -540,6 +540,7 @@ def _fit_model(train_set, psms, model, fold):
model.fit(train_set)
except RuntimeError as msg:
if str(msg) != "Model performs worse after training.":
LOGGER.info(f"Fold {fold + 1}: {msg}")
raise

if model.is_trained:
Expand Down
4 changes: 3 additions & 1 deletion mokapot/brew_rollup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ def parse_arguments(main_args):
# todo: we should update this copyright notice asap
desc = (
f"mokapot version {__version__}.\n"
"Written by William E. Fondrie ([email protected]) while in the \n"
"Originally written by William E. Fondrie ([email protected]) while in the \n"
"Department of Genome Sciences at the University of Washington.\n\n"
"Extended by Samia Ben Fredj, Elmar Zander, Vishal Sukumar and \n"
"Siegfried Gessulat while at MSAID. \n\n"
"Official code website: https://github.com/wfondrie/mokapot\n\n"
"More documentation and examples: https://mokapot.readthedocs.io"
)
Expand Down
1 change: 1 addition & 0 deletions mokapot/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ def fit(self, dataset: LinearPsmDataset):
if num_passed[i] == 0:
raise RuntimeError("Model performs worse after training.")


# If the model performs worse than what was initialized:
if (
num_passed[-1] < (start_labels == 1).sum()
Expand Down
2 changes: 2 additions & 0 deletions mokapot/mokapot.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def main(main_args=None):
level=verbosity_dict[config.verbosity],
)
logging.captureWarnings(True)
numba_logger = logging.getLogger('numba')
numba_logger.setLevel(logging.WARNING)

# Suppress warning if asked for
if config.suppress_warnings:
Expand Down
7 changes: 6 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,15 @@ docs = [
"ipykernel>=5.3.0",
"recommonmark>=0.5.0",
]
dev = [

[tool.uv]
dev-dependencies = [
"pre-commit>=2.7.1",
"ruff>=0.4.4",
"pytest>=8.2.2",
"flake8>=7.1.1",
"wheel>=0.44.0",
"pytest-cov>=5.0.0"
]

[project.scripts]
Expand Down
2 changes: 1 addition & 1 deletion tests/helpers/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def _run_cli(
params = flatten(params)
params = [str(param) for param in params]
if run_in_subprocess:
cmd = ["python", "-m", module] + params
cmd = ["uv", "run", "python", "-m", module] + params
try:
res = subprocess.run(
cmd, check=True, capture_output=capture_output
Expand Down
2 changes: 1 addition & 1 deletion tests/system_tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def phospho_files():

def test_basic_cli(tmp_path, scope_files):
"""Test that basic cli works."""
params = [scope_files[0], "--dest_dir", tmp_path]
params = [scope_files[0], "--dest_dir", tmp_path, "--verbosity", 3]
run_mokapot_cli(params)
assert file_approx_len(tmp_path, "targets.psms.csv", 5487)
assert file_approx_len(tmp_path, "targets.peptides.csv", 5183)
Expand Down
2,576 changes: 2,576 additions & 0 deletions uv.lock

Large diffs are not rendered by default.