From ecb27d1838f14fbd61685e225a2a7994685a8523 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Fri, 19 Jul 2024 11:20:24 -0700 Subject: [PATCH] Example with CI - precommited --- .github/workflows/modal.yml | 2 +- tests/conftest.py | 3 ++- tests/test_cheminf.py | 1 + tools/cheminf/cheminf.py | 4 ++-- tools/deploy.py | 2 -- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/modal.yml b/.github/workflows/modal.yml index a949911..104128f 100644 --- a/.github/workflows/modal.yml +++ b/.github/workflows/modal.yml @@ -23,4 +23,4 @@ jobs: MODAL_TOKEN_ID: ${{ secrets.MODAL_TOKEN_ID }} CHEMENV_NAME: "-dev" - name: Run tests - run: pytest tests/ \ No newline at end of file + run: pytest tests/ diff --git a/tests/conftest.py b/tests/conftest.py index 6409c40..0913382 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,7 +1,8 @@ import os import pytest + @pytest.fixture(scope="function") def app_name(): chemenv_name = os.getenv("CHEMENV_NAME", "") - return f"chemenv{chemenv_name}" \ No newline at end of file + return f"chemenv{chemenv_name}" diff --git a/tests/test_cheminf.py b/tests/test_cheminf.py index 0d14c53..dd91a3b 100644 --- a/tests/test_cheminf.py +++ b/tests/test_cheminf.py @@ -1,6 +1,7 @@ import pytest import modal + @pytest.mark.asyncio async def test_tanimoto(app_name): fxn = modal.Function.lookup(app_name, "tanimoto") diff --git a/tools/cheminf/cheminf.py b/tools/cheminf/cheminf.py index e5dba2c..868dd63 100644 --- a/tools/cheminf/cheminf.py +++ b/tools/cheminf/cheminf.py @@ -19,5 +19,5 @@ def tanimoto(s1: str, s2: str) -> float: fp1 = AllChem.GetMorganFingerprintAsBitVect(mol1, 2, nBits=2048) fp2 = AllChem.GetMorganFingerprintAsBitVect(mol2, 2, nBits=2048) return DataStructs.TanimotoSimilarity(fp1, fp2) - except (TypeError, ValueError, AttributeError): - return "Error: Not a valid SMILES string" + except (TypeError, ValueError, AttributeError) as e: + raise ValueError("Invalid SMILES strings") from e diff --git a/tools/deploy.py b/tools/deploy.py index 333e5a4..3e306c6 100644 --- a/tools/deploy.py +++ b/tools/deploy.py @@ -9,5 +9,3 @@ chemenv_name = f"-{chemenv_name}" app = App(f"chemenv{chemenv_name}") app.include(cheminf_app) - -