diff --git a/setup.cfg b/setup.cfg index 066f32f..ec747f8 100644 --- a/setup.cfg +++ b/setup.cfg @@ -4,7 +4,7 @@ [metadata] name = chemlift version = 0.0.1-dev -description = Chemical language interfaced fine-tuning of large-language models +description = Chemical language interfaced predictions using large-language models long_description = file: README.md long_description_content_type = text/markdown @@ -42,7 +42,11 @@ classifiers = Programming Language :: Python :: 3.10 Programming Language :: Python :: 3.11 Programming Language :: Python :: 3 :: Only -keywords = +keywords = + llm + chemistry + lift + [options] @@ -50,7 +54,7 @@ install_requires = more_itertools tqdm transformers - peft + peft gptchem datasets accelerate @@ -114,51 +118,35 @@ show_missing = True exclude_lines = pragma: no cover raise NotImplementedError - if __name__ == "__main__": - if TYPE_CHECKING: - def __str__ - def __repr__ + ########################## # Darglint Configuration # ########################## [darglint] -docstring_style = sphinx +docstring_style = google strictness = short -######################### -# Flake8 Configuration # -# (.flake8) # -######################### -[flake8] -ignore = - S301 # pickle - S403 # pickle - S404 - S603 - W503 # Line break before binary operator (flake8 is wrong) - E203 # whitespace before ':' -exclude = - .tox, - .git, - __pycache__, - docs/source/conf.py, - build, - dist, - tests/fixtures/*, - *.pyc, - *.egg-info, - .cache, - .eggs, - data -max-line-length = 120 -max-complexity = 20 -import-order-style = pycharm -application-import-names = - chemlift - tests - - -[tool:pytest] -env_files = - .env \ No newline at end of file +[tool.ruff] +exclude = + ".tox" + ".git" + "__pycache__" + "docs/source/conf.py" + "build" + "dist" + "tests/fixtures/*" + "*.pyc" + "*.egg-info" + ".cache" + ".eggs" + "data" +line-length = 120 +select = + "C9" + "E" + "F" + "W" + +[tool.ruff.mccabe] +max-complexity = 20 \ No newline at end of file diff --git a/src/chemlift/icl/fewshotclassifier.py b/src/chemlift/icl/fewshotclassifier.py index 6f7f667..c2c4e73 100644 --- a/src/chemlift/icl/fewshotclassifier.py +++ b/src/chemlift/icl/fewshotclassifier.py @@ -1,8 +1,6 @@ from loguru import logger from numpy.typing import ArrayLike -from typing import Union from chemlift.icl.fewshotpredictor import FewShotPredictor -from chemlift.icl.utils import LangChainChatModelWrapper class FewShotClassifier(FewShotPredictor): diff --git a/src/chemlift/icl/fewshotpredictor.py b/src/chemlift/icl/fewshotpredictor.py index 9d5e5d8..11ed606 100644 --- a/src/chemlift/icl/fewshotpredictor.py +++ b/src/chemlift/icl/fewshotpredictor.py @@ -6,7 +6,6 @@ from numpy.typing import ArrayLike import enum from typing import Union -from chemlift.icl.fewshotpredictor import FewShotPredictor from chemlift.icl.utils import LangChainChatModelWrapper diff --git a/src/chemlift/icl/utils.py b/src/chemlift/icl/utils.py index 5deeed5..5dbef18 100644 --- a/src/chemlift/icl/utils.py +++ b/src/chemlift/icl/utils.py @@ -1,5 +1,13 @@ class LangChainChatModelWrapper: - """Wrapper for chat model to make it accept plain text prompts.""" + """Wrapper for chat model to make it accept plain text prompts. + + Examples: + >>> from chemlift.icl.utils import LangChainChatModelWrapper + >>> from langchain.chat_models import ChatOpenAI + >>> model = ChatOpenAI(model="gpt-4") + >>> model = LangChainChatModelWrapper(model) + >>> model.generate(["Hello, how are you?"]) + """ def __init__(self, model): self.model = model diff --git a/src/chemlift/utils.py b/src/chemlift/utils.py index 48bd732..d034c6b 100644 --- a/src/chemlift/utils.py +++ b/src/chemlift/utils.py @@ -14,7 +14,7 @@ def array_of_ints_without_nan(arr): def try_exccept_nan(f, x): try: return f(x) - except: + except Exception: return np.nan diff --git a/tox.ini b/tox.ini index 6f9eaf7..7edf2e8 100644 --- a/tox.ini +++ b/tox.ini @@ -16,7 +16,7 @@ envlist = lint manifest pyroma - flake8 + rufff mypy # documentation linters/checkers doc8 @@ -39,20 +39,12 @@ extras = tests [testenv:doctests] -description = Test that documentation examples run properly commands = xdoctest -m src deps = xdoctest pygments -[testenv:treon] -description = Test that notebooks can run to completion -commants = - treon notebooks/ -deps = - treon - [testenv:coverage-clean] deps = coverage skip_install = true @@ -84,23 +76,13 @@ skip_install = true commands = check-manifest description = Check that the MANIFEST.in is written properly and give feedback on how to fix it. -[testenv:flake8] -skip_install = true +[testenv:ruff] +skip_install = false deps = - darglint - flake8<5.0.0 - flake8-black - flake8-bandit - flake8-bugbear - flake8-colors - flake8-docstrings - flake8-isort - flake8-print - pep8-naming - pydocstyle + ruff commands = - flake8 src/ tests/ -description = Run the flake8 tool with several plugins (bandit, docstrings, import order, pep8 naming). See https://cthoyt.com/2020/04/25/how-to-code-with-me-flake8.html for more information. + ruff src/ tests/ +description = Run the ruff tool with several plugins (bandit, docstrings, import order, pep8 naming). [testenv:pyroma] deps = @@ -221,4 +203,4 @@ commands = bump2version patch git push allowlist_externals = - git + git \ No newline at end of file