From ad23d1dd1a5b4b2a23f5f2cff6a6adfad9c72d49 Mon Sep 17 00:00:00 2001 From: "J. Sebastian Paez" Date: Wed, 14 Dec 2022 16:42:42 -0600 Subject: [PATCH] changed metadata import to allow the groups arg (#86) * changed metadata import to allow the groups arg * fixed actions version * moved py311 to experimental * Update tests.yml * added instance check the need for hparam selection * review changes --- .github/workflows/tests.yml | 6 +++++- mokapot/model.py | 3 ++- mokapot/plugins/__init__.py | 7 +++---- pyproject.toml | 1 + 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6e5dfea9..b1f0f0e8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,16 +9,20 @@ on: jobs: build: runs-on: ${{ matrix.os }} + continue-on-error: ${{ matrix.experimental }} strategy: + fail-fast: false matrix: + python-version: ['3.8', '3.9', '3.10',] os: [ubuntu-latest, windows-latest, macos-latest] + experimental: [false,] steps: - uses: actions/checkout@v3 - name: Set up Python uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: ${{ matrix.python-version }} - name: Install dependencies run: | diff --git a/mokapot/model.py b/mokapot/model.py index 59f6f1ee..ade5a4ff 100644 --- a/mokapot/model.py +++ b/mokapot/model.py @@ -23,6 +23,7 @@ from sklearn.base import clone from sklearn.svm import LinearSVC from sklearn.model_selection import GridSearchCV +from sklearn.model_selection._search import BaseSearchCV from sklearn.preprocessing import StandardScaler from sklearn.exceptions import NotFittedError @@ -154,7 +155,7 @@ def __init__( self.fold = None # Sort out whether we need to optimize hyperparameters: - if hasattr(self.estimator, "estimator"): + if isinstance(self.estimator, BaseSearchCV): self._needs_cv = True else: self._needs_cv = False diff --git a/mokapot/plugins/__init__.py b/mokapot/plugins/__init__.py index e76b255d..f4ba7c69 100644 --- a/mokapot/plugins/__init__.py +++ b/mokapot/plugins/__init__.py @@ -5,10 +5,9 @@ import pandas as pd -try: - from importlib.metadata import entry_points -except ImportError: - from importlib_metadata import entry_points +# Once the min supported version reaches 3.10, the standard library should +# be used like so -> from importlib.metadata import entry_points +from importlib_metadata import entry_points from argparse import _ArgumentGroup from typing import Any diff --git a/pyproject.toml b/pyproject.toml index d8f92c87..bb197a50 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,6 +23,7 @@ dependencies = [ "lxml>=4.6.2", "triqler>=0.6.2", "joblib>=1.1.0", + "importlib-metadata>=5.1.0", ] dynamic = ["version"]