Skip to content

Commit

Permalink
Merge pull request #2 from NERC-CEH/lint_test
Browse files Browse the repository at this point in the history
Test lint and coverage workflows
  • Loading branch information
metazool authored Jul 1, 2024
2 parents dbb603a + 8a324f4 commit f80abf4
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 30 deletions.
14 changes: 0 additions & 14 deletions .github/workflows/coverage.yml

This file was deleted.

21 changes: 21 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

Expand All @@ -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/[email protected]
with:
coverageFile: coverage.xml
token: ${{ secrets.GITHUB_TOKEN }}
14 changes: 11 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
13 changes: 9 additions & 4 deletions cyto_ml/data/vectorstore.py
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion cyto_ml/models/scivision.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []

0 comments on commit f80abf4

Please sign in to comment.