diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml deleted file mode 100644 index 01344aa..0000000 --- a/.github/workflows/coverage.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: 'coverage' -on: - pull_request: - branches: - - main -jobs: - coverage: - runs-on: ubuntu-latest - steps: - - name: Test coverage report - uses: orgoro/coverage@v3.1 - with: - coverageFile: coverage.xml - token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..ccef985 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,21 @@ +name: flake8 Lint + +on: [push, pull_request] + +jobs: + flake8-lint: + runs-on: ubuntu-latest + name: Lint + steps: + - name: Check out source repository + uses: actions/checkout@v3 + - name: Set up Python environment + uses: actions/setup-python@v4 + with: + python-version: "3.9" + - name: flake8 Lint + uses: py-actions/flake8@v2 + with: + max-line-length: "120" + path: "cyto_ml" + plugins: "flake8-bugbear==22.1.11 flake8-black" \ No newline at end of file diff --git a/.github/workflows/conda.yml b/.github/workflows/pytest_coverage.yml similarity index 52% rename from .github/workflows/conda.yml rename to .github/workflows/pytest_coverage.yml index 08484c4..f99692d 100644 --- a/.github/workflows/conda.yml +++ b/.github/workflows/pytest_coverage.yml @@ -1,7 +1,5 @@ on: - push: - branches: [ "main" ] pull_request: branches: [ "main" ] @@ -25,6 +23,21 @@ jobs: environment-file: environment.yml python-version: ${{ matrix.python-version }} auto-activate-base: false - - run: | - pip install pytest-cov - python -m pytest --cov=cyto_ml --cov-report xml:coverage.xml tests/ + - run: pip install pytest-cov + - run: python -m pytest --cov=cyto_ml --cov-report xml:coverage.xml tests/ + - uses: actions/upload-artifact@v4 + with: + name: coverage.xml + path: coverage.xml + coverage: + needs: tests + runs-on: ubuntu-latest + steps: + - uses: actions/download-artifact@v4 + with: + name: coverage.xml + - name: Test coverage report + uses: orgoro/coverage@v3.1 + with: + coverageFile: coverage.xml + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d1c28ce..fb8c22a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,9 +2,17 @@ This is a small prototype but we welcome contributions to it. -* Please create a pull request with additions or changes +* Please [create a pull request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request) with additions or changes. * Please use a python formatter and linter to clean your code to PEP8 standard - we like `[black](https://pypi.org/project/black/)` as a formatting convention -* Please contribute a test that covers your changes -* Please provide brief instructions to a reviewer about how to exercise your code +* Please make sure you add a test for the code that you add. If you're not familiar with tests [this might be a helpful starting point](https://realpython.com/pytest-python-testing/) +* It's considerate to provide brief instructions to a reviewer about how to run your code and what to expect. + +If you've got any questions about this, we're happy to help, please reach out to the [EDS RSE team](https://github.com/NERC-CEH/rse_group/discussions) + +## TODO + +* Add links to git commit style guides, workflow outliens +* Add links to examples of projects with reasonable test coverage + Thank you for thinking about contributing <3 diff --git a/README.md b/README.md index 1c54f9d..135ccc9 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -# [insert name here] +# Plankton ML -This repository contains code and configuration for processing and analysing images of plankton samples. +This repository contains code and configuration for processing and analysing images of plankton samples. It's experimental, serving as much as a proposed template for new projects than as a project in itself. -It's a sister project to an image annotation app that is not yet released, written by researchers and data scientists at the UK Centre for Ecology and Hydrology in the early stages of a collaborative project that wasn't taken forward. +It's a companion project to an R-shiny based image annotation app that is not yet released, written by researchers and data scientists at the UK Centre for Ecology and Hydrology in the early stages of a collaboration that was placed on hold. ## Installation diff --git a/cyto_ml/data/vectorstore.py b/cyto_ml/data/vectorstore.py index d6e06c2..ed0e9bf 100644 --- a/cyto_ml/data/vectorstore.py +++ b/cyto_ml/data/vectorstore.py @@ -1,18 +1,23 @@ import chromadb -from chromadb.db.base import NotFoundError, UniqueConstraintError +from chromadb.db.base import UniqueConstraintError from typing import Optional +import logging + +logging.basicConfig(level=logging.INFO) client = chromadb.PersistentClient(path="./vectors") -def vector_store(name: Optional[str] = 'test_collection'): + +def vector_store(name: Optional[str] = "test_collection"): """ Return a vector store specified by name, default test_collection """ try: collection = client.create_collection( - name=name, metadata={"hnsw:space": "cosine"} # l2 is the default + name=name, metadata={"hnsw:space": "cosine"} # default similarity ) except UniqueConstraintError as err: collection = client.get_collection(name) - + logging.info(err) + return collection diff --git a/cyto_ml/models/scivision.py b/cyto_ml/models/scivision.py index 1be163f..3de3ea8 100644 --- a/cyto_ml/models/scivision.py +++ b/cyto_ml/models/scivision.py @@ -4,7 +4,9 @@ import torchvision from xarray import DataArray -SCIVISION_URL = "https://github.com/alan-turing-institute/plankton-cefas-scivision" +SCIVISION_URL = ( + "https://github.com/alan-turing-institute/plankton-cefas-scivision" # noqa: E501 +) def load_model(url: str): diff --git a/pyproject.toml b/pyproject.toml index deb0e18..8510474 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,3 +4,5 @@ version = "0.1" description = "This package supports the processing and analysis of plankton sample data" readme = "README.md" requires-python = "<3.10" +[tool.setuptools] +py-modules = []