-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from NERC-CEH/lint_test
Test lint and coverage workflows
- Loading branch information
Showing
8 changed files
with
67 additions
and
30 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/[email protected] | ||
with: | ||
coverageFile: coverage.xml | ||
token: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters