From af8f4dc0bac5498755a4eab0a930385468dc962b Mon Sep 17 00:00:00 2001 From: Justin Reese Date: Fri, 10 May 2024 12:08:44 -0700 Subject: [PATCH 01/10] Add GH action for pytest and lint --- .github/workflows/qc.yml | 77 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 .github/workflows/qc.yml diff --git a/.github/workflows/qc.yml b/.github/workflows/qc.yml new file mode 100644 index 00000000..fe18190d --- /dev/null +++ b/.github/workflows/qc.yml @@ -0,0 +1,77 @@ +# Built from: +# https://docs.github.com/en/actions/guides/building-and-testing-python +# https://github.com/snok/install-poetry#workflows-and-tips + +name: Build and test + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + lint: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [ '3.9', '3.10' ] + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4.3.0 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + pip install tox + - name: Check code quality with flake8 + run: tox -e flake8 + + test: + strategy: + fail-fast: false + matrix: + os: [ ubuntu-latest, windows-latest ] + python-version: [ "3.9", "3.10" ] + exclude: + - os: windows-latest + python-version: "3.9" + + runs-on: ${{ matrix.os }} + + steps: + + #---------------------------------------------- + # check-out repo and set-up python + #---------------------------------------------- + - name: Check out repository + uses: actions/checkout@v3 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + + #---------------------------------------------- + # install & configure poetry + #---------------------------------------------- + - name: Install Poetry + uses: snok/install-poetry@v1.3.1 + with: + virtualenvs-create: true + virtualenvs-in-project: true + + + - name: Install dependencies + # if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' + run: poetry install --no-interaction --no-root + + - name: Generate coverage results + run: | + poetry run pip install -U pytest + poetry run coverage run -p -m pytest tests/ + poetry run coverage combine + poetry run coverage xml + poetry run coverage report -m + From 119d7595b8d020078858d518f3239830729c2825 Mon Sep 17 00:00:00 2001 From: Justin Reese Date: Fri, 10 May 2024 12:12:02 -0700 Subject: [PATCH 02/10] Continue on lint error (at least for now) --- .github/workflows/qc.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/qc.yml b/.github/workflows/qc.yml index fe18190d..4cc1d9a9 100644 --- a/.github/workflows/qc.yml +++ b/.github/workflows/qc.yml @@ -13,6 +13,7 @@ on: jobs: lint: runs-on: ubuntu-latest + continue-on-error: true # This line allows the job to continue even if errors occur strategy: matrix: python-version: [ '3.9', '3.10' ] From b10ee8b4d843836d8f6a412ae2626d682fcf9568 Mon Sep 17 00:00:00 2001 From: Justin Reese Date: Fri, 10 May 2024 12:14:10 -0700 Subject: [PATCH 03/10] Comment out linting for now --- .github/workflows/qc.yml | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/qc.yml b/.github/workflows/qc.yml index 4cc1d9a9..80ffa66d 100644 --- a/.github/workflows/qc.yml +++ b/.github/workflows/qc.yml @@ -11,23 +11,23 @@ on: branches: [ main ] jobs: - lint: - runs-on: ubuntu-latest - continue-on-error: true # This line allows the job to continue even if errors occur - strategy: - matrix: - python-version: [ '3.9', '3.10' ] - steps: - - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4.3.0 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - pip install tox - - name: Check code quality with flake8 - run: tox -e flake8 +# lint: +# runs-on: ubuntu-latest +# continue-on-error: true # This line allows the job to continue even if errors occur +# strategy: +# matrix: +# python-version: [ '3.9', '3.10' ] +# steps: +# - uses: actions/checkout@v3 +# - name: Set up Python ${{ matrix.python-version }} +# uses: actions/setup-python@v4.3.0 +# with: +# python-version: ${{ matrix.python-version }} +# - name: Install dependencies +# run: | +# pip install tox +# - name: Check code quality with flake8 +# run: tox -e flake8 test: strategy: From a6f26c8f6836b50dcf50f7143add3c1e9e92d6cb Mon Sep 17 00:00:00 2001 From: Justin Reese Date: Fri, 10 May 2024 12:32:04 -0700 Subject: [PATCH 04/10] Run doctests --- .github/workflows/qc.yml | 21 +++------------------ tox.ini | 11 +++++++++-- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/.github/workflows/qc.yml b/.github/workflows/qc.yml index 80ffa66d..1927e312 100644 --- a/.github/workflows/qc.yml +++ b/.github/workflows/qc.yml @@ -38,36 +38,22 @@ jobs: exclude: - os: windows-latest python-version: "3.9" - runs-on: ${{ matrix.os }} - steps: - - #---------------------------------------------- - # check-out repo and set-up python - #---------------------------------------------- - - name: Check out repository - uses: actions/checkout@v3 - + - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v3 with: python-version: ${{ matrix.python-version }} - - #---------------------------------------------- - # install & configure poetry - #---------------------------------------------- - name: Install Poetry uses: snok/install-poetry@v1.3.1 with: virtualenvs-create: true virtualenvs-in-project: true - - - name: Install dependencies - # if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' run: poetry install --no-interaction --no-root - + - name: Run Doctests + run: poetry run tox -e doctest - name: Generate coverage results run: | poetry run pip install -U pytest @@ -75,4 +61,3 @@ jobs: poetry run coverage combine poetry run coverage xml poetry run coverage report -m - diff --git a/tox.ini b/tox.ini index 3cd151dd..703d07f2 100644 --- a/tox.ini +++ b/tox.ini @@ -44,6 +44,13 @@ commands = flake8 src/ tests/ description = Run the flake8 tool with several plugins (bandit, docstrings, import order, pep8 naming). +[testenv:doctest] +deps = + pytest + pytest-cov +commands = + pytest --doctest-modules src/ + ######################### # Flake8 Configuration # # (.flake8) # @@ -66,7 +73,7 @@ ignore = #S603 # subprocess call - check for execution of untrusted input. S607 # Starting a process with a partial executable path ["open" in both cases] #S608 # Possible SQL injection vector through string-based query construction. - #B024 # StreamingWriter is an abstract base class, but it has no abstract methods. + #B024 # StreamingWriter is an abstract base class, but it has no abstract methods. # Remember to use @abstractmethod, @abstractclassmethod and/or @abstractproperty decorators. #B027 # empty method in an abstract base class, but has no abstract decorator. Consider adding @abstractmethod #N803 # math-oriented classes can ignore this (e.g. hypergeometric.py) @@ -80,4 +87,4 @@ application-import-names = pheval_template tests # exclude = -# datamodels ## datamodels are auto-generated \ No newline at end of file +# datamodels ## datamodels are auto-generated From 0e4a9793abf7246d3c7265cbcdec51836516cb64 Mon Sep 17 00:00:00 2001 From: Justin Reese Date: Fri, 10 May 2024 12:35:29 -0700 Subject: [PATCH 05/10] Add tox as dev dependency --- .gitignore | 1 + poetry.lock | 95 +++++++++++++++++++++++++++++++++++++++++++++++++- pyproject.toml | 3 ++ 3 files changed, 98 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index d0097e95..d1858f8b 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ data/* prompts/* inputdir outputdir +.openai_cache.db diff --git a/poetry.lock b/poetry.lock index e2b54ab0..96322476 100644 --- a/poetry.lock +++ b/poetry.lock @@ -899,6 +899,17 @@ files = [ graph = ["objgraph (>=1.7.2)"] profile = ["gprof2dot (>=2022.7.29)"] +[[package]] +name = "distlib" +version = "0.3.8" +description = "Distribution utilities" +optional = false +python-versions = "*" +files = [ + {file = "distlib-0.3.8-py2.py3-none-any.whl", hash = "sha256:034db59a0b96f8ca18035f36290806a9a6e6bd9d1ff91e45a7f172eb17e51784"}, + {file = "distlib-0.3.8.tar.gz", hash = "sha256:1530ea13e350031b6312d8580ddb6b27a104275a31106523b8f123787f494f64"}, +] + [[package]] name = "distro" version = "1.9.0" @@ -1030,6 +1041,22 @@ files = [ {file = "fastobo-0.12.3.tar.gz", hash = "sha256:f375932a24b078706797eb9296740f2d2e6987a34309bda7c9f235aba1d74217"}, ] +[[package]] +name = "filelock" +version = "3.14.0" +description = "A platform independent file lock." +optional = false +python-versions = ">=3.8" +files = [ + {file = "filelock-3.14.0-py3-none-any.whl", hash = "sha256:43339835842f110ca7ae60f1e1c160714c5a6afd15a2873419ab185334975c0f"}, + {file = "filelock-3.14.0.tar.gz", hash = "sha256:6ea72da3be9b8c82afd3edcf99f2fffbb5076335a5ae4d03248bb5b6c3eae78a"}, +] + +[package.extras] +docs = ["furo (>=2023.9.10)", "sphinx (>=7.2.6)", "sphinx-autodoc-typehints (>=1.25.2)"] +testing = ["covdefaults (>=2.3)", "coverage (>=7.3.2)", "diff-cover (>=8.0.1)", "pytest (>=7.4.3)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)", "pytest-timeout (>=2.2)"] +typing = ["typing-extensions (>=4.8)"] + [[package]] name = "flask" version = "3.0.3" @@ -3810,6 +3837,25 @@ files = [ [package.extras] diagrams = ["jinja2", "railroad-diagrams"] +[[package]] +name = "pyproject-api" +version = "1.6.1" +description = "API to interact with the python pyproject.toml based projects" +optional = false +python-versions = ">=3.8" +files = [ + {file = "pyproject_api-1.6.1-py3-none-any.whl", hash = "sha256:4c0116d60476b0786c88692cf4e325a9814965e2469c5998b830bba16b183675"}, + {file = "pyproject_api-1.6.1.tar.gz", hash = "sha256:1817dc018adc0d1ff9ca1ed8c60e1623d5aaca40814b953af14a9cf9a5cae538"}, +] + +[package.dependencies] +packaging = ">=23.1" +tomli = {version = ">=2.0.1", markers = "python_version < \"3.11\""} + +[package.extras] +docs = ["furo (>=2023.8.19)", "sphinx (<7.2)", "sphinx-autodoc-typehints (>=1.24)"] +testing = ["covdefaults (>=2.3)", "pytest (>=7.4)", "pytest-cov (>=4.1)", "pytest-mock (>=3.11.1)", "setuptools (>=68.1.2)", "wheel (>=0.41.2)"] + [[package]] name = "pyreadline3" version = "3.4.1" @@ -5221,6 +5267,33 @@ files = [ {file = "tornado-6.4.tar.gz", hash = "sha256:72291fa6e6bc84e626589f1c29d90a5a6d593ef5ae68052ee2ef000dfd273dee"}, ] +[[package]] +name = "tox" +version = "4.15.0" +description = "tox is a generic virtualenv management and test command line tool" +optional = false +python-versions = ">=3.8" +files = [ + {file = "tox-4.15.0-py3-none-any.whl", hash = "sha256:300055f335d855b2ab1b12c5802de7f62a36d4fd53f30bd2835f6a201dda46ea"}, + {file = "tox-4.15.0.tar.gz", hash = "sha256:7a0beeef166fbe566f54f795b4906c31b428eddafc0102ac00d20998dd1933f6"}, +] + +[package.dependencies] +cachetools = ">=5.3.2" +chardet = ">=5.2" +colorama = ">=0.4.6" +filelock = ">=3.13.1" +packaging = ">=23.2" +platformdirs = ">=4.1" +pluggy = ">=1.3" +pyproject-api = ">=1.6.1" +tomli = {version = ">=2.0.1", markers = "python_version < \"3.11\""} +virtualenv = ">=20.25" + +[package.extras] +docs = ["furo (>=2023.9.10)", "sphinx (>=7.2.6)", "sphinx-argparse-cli (>=1.11.1)", "sphinx-autodoc-typehints (>=1.25.2)", "sphinx-copybutton (>=0.5.2)", "sphinx-inline-tabs (>=2023.4.21)", "sphinxcontrib-towncrier (>=0.2.1a0)", "towncrier (>=23.11)"] +testing = ["build[virtualenv] (>=1.0.3)", "covdefaults (>=2.3)", "detect-test-pollution (>=1.2)", "devpi-process (>=1)", "diff-cover (>=8.0.2)", "distlib (>=0.3.8)", "flaky (>=3.7)", "hatch-vcs (>=0.4)", "hatchling (>=1.21)", "psutil (>=5.9.7)", "pytest (>=7.4.4)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)", "pytest-xdist (>=3.5)", "re-assert (>=1.1)", "time-machine (>=2.13)", "wheel (>=0.42)"] + [[package]] name = "tqdm" version = "4.66.4" @@ -5392,6 +5465,26 @@ files = [ {file = "validators-0.28.1.tar.gz", hash = "sha256:5ac88e7916c3405f0ce38ac2ac82a477fcf4d90dbbeddd04c8193171fc17f7dc"}, ] +[[package]] +name = "virtualenv" +version = "20.26.1" +description = "Virtual Python Environment builder" +optional = false +python-versions = ">=3.7" +files = [ + {file = "virtualenv-20.26.1-py3-none-any.whl", hash = "sha256:7aa9982a728ae5892558bff6a2839c00b9ed145523ece2274fad6f414690ae75"}, + {file = "virtualenv-20.26.1.tar.gz", hash = "sha256:604bfdceaeece392802e6ae48e69cec49168b9c5f4a44e483963f9242eb0e78b"}, +] + +[package.dependencies] +distlib = ">=0.3.7,<1" +filelock = ">=3.12.2,<4" +platformdirs = ">=3.9.1,<5" + +[package.extras] +docs = ["furo (>=2023.7.26)", "proselint (>=0.13)", "sphinx (>=7.1.2,!=7.3)", "sphinx-argparse (>=0.4)", "sphinxcontrib-towncrier (>=0.2.1a0)", "towncrier (>=23.6)"] +test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess (>=1)", "flaky (>=3.7)", "packaging (>=23.1)", "pytest (>=7.4)", "pytest-env (>=0.8.2)", "pytest-freezer (>=0.4.8)", "pytest-mock (>=3.11.1)", "pytest-randomly (>=3.12)", "pytest-timeout (>=2.1)", "setuptools (>=68)", "time-machine (>=2.10)"] + [[package]] name = "watchdog" version = "4.0.0" @@ -5678,4 +5771,4 @@ multidict = ">=4.0" [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "7455db7666722ff6f052784f841c8efa02edbe54f6611e1f1c372d6539dd08a6" +content-hash = "4c8d2fd260442ce45507714fcab1917d8c606349b5860edb99f1cab1208790bc" diff --git a/pyproject.toml b/pyproject.toml index ad6bbc7e..d79ebdac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,6 +23,9 @@ coverage = "^6.5.0" # https://github.com/monarch-initiative/ontogpt.git branch multilanguage_gpt ontogpt = {git = "https://github.com/monarch-initiative/ontogpt.git", branch = "multilanguage_gpt"} +[tool.poetry.group.dev.dependencies] +tox = "^4.15.0" + [tool.pytest.ini_options] pythonpath = [ "src" From ace82010227fdc30675463f67bc9751e31a16ba3 Mon Sep 17 00:00:00 2001 From: Justin Reese Date: Fri, 10 May 2024 13:00:20 -0700 Subject: [PATCH 06/10] Pin to OntoGPT main (not multilanguage_gpt) --- pyproject.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index d79ebdac..f9da07d1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,8 +20,7 @@ pytest = "^7.1.2" pylint = "^2.15.6" pycodestyle = "^2.10.0" coverage = "^6.5.0" -# https://github.com/monarch-initiative/ontogpt.git branch multilanguage_gpt -ontogpt = {git = "https://github.com/monarch-initiative/ontogpt.git", branch = "multilanguage_gpt"} +ontogpt = {git = "https://github.com/monarch-initiative/ontogpt.git", branch = "main"} [tool.poetry.group.dev.dependencies] tox = "^4.15.0" From 0a836a467c6ebda7f697ab767bf697ea9fb5be3d Mon Sep 17 00:00:00 2001 From: Justin Reese Date: Fri, 10 May 2024 13:28:02 -0700 Subject: [PATCH 07/10] Change GH action to use python >= 3.10 --- .github/workflows/qc.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/qc.yml b/.github/workflows/qc.yml index 1927e312..d4d06f31 100644 --- a/.github/workflows/qc.yml +++ b/.github/workflows/qc.yml @@ -34,10 +34,10 @@ jobs: fail-fast: false matrix: os: [ ubuntu-latest, windows-latest ] - python-version: [ "3.9", "3.10" ] + python-version: [ "3.10" ] exclude: - os: windows-latest - python-version: "3.9" + python-version: "3.10" runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 From 889b526fdea57c7282eb96c81b567497f34d133b Mon Sep 17 00:00:00 2001 From: Justin Reese Date: Fri, 10 May 2024 13:30:55 -0700 Subject: [PATCH 08/10] poetry lock --no-update --- poetry.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/poetry.lock b/poetry.lock index 96322476..3466af55 100644 --- a/poetry.lock +++ b/poetry.lock @@ -3064,8 +3064,8 @@ web = ["Jinja2 (>=3.1.2)", "fastapi (>=0.88.0)", "uvicorn (>=0.20.0)"] [package.source] type = "git" url = "https://github.com/monarch-initiative/ontogpt.git" -reference = "multilanguage_gpt" -resolved_reference = "4613da4f2c6c7c4e33c0c29496910ba16a2afbd6" +reference = "main" +resolved_reference = "3f755df0398afc44c60a301b3a3d903438d7cccf" [[package]] name = "ontoportal-client" @@ -5771,4 +5771,4 @@ multidict = ">=4.0" [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "4c8d2fd260442ce45507714fcab1917d8c606349b5860edb99f1cab1208790bc" +content-hash = "076dee9f738378d4aae0d0985054f15ade28c227b6b75c31d91847e3c70c390b" From f862be9730f31e26d8cbddbcd5198a9d9a0b29ac Mon Sep 17 00:00:00 2001 From: Justin Reese Date: Fri, 10 May 2024 13:37:01 -0700 Subject: [PATCH 09/10] poetry install in tox.ini before doctest --- tox.ini | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tox.ini b/tox.ini index 703d07f2..018b539c 100644 --- a/tox.ini +++ b/tox.ini @@ -48,6 +48,8 @@ description = Run the flake8 tool with several plugins (bandit, docstrings, impo deps = pytest pytest-cov +commands_pre = + poetry install commands = pytest --doctest-modules src/ From fd6f6581dd8a0766abb19c380a42b9ab86cd5f44 Mon Sep 17 00:00:00 2001 From: Justin Reese Date: Fri, 10 May 2024 13:41:36 -0700 Subject: [PATCH 10/10] Allow poetry --- tox.ini | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tox.ini b/tox.ini index 018b539c..27f05cb7 100644 --- a/tox.ini +++ b/tox.ini @@ -48,6 +48,8 @@ description = Run the flake8 tool with several plugins (bandit, docstrings, impo deps = pytest pytest-cov +isolated_build = true +allowlist_externals = poetry commands_pre = poetry install commands =