Skip to content

Commit

Permalink
Unique detector name (#197)
Browse files Browse the repository at this point in the history
* Looks like the problem is that the different github runners all reached for the same detector at the same time

* Make it easier to debug this next time by triggering the full tests manually through github

* Automatically reformatting code

---------

Co-authored-by: Auto-format Bot <[email protected]>
  • Loading branch information
brandon-groundlight and Auto-format Bot authored Apr 3, 2024
1 parent 61c43ad commit ac1c114
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/cicd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# to pypi.
name: cicd
on:
workflow_dispatch:
push:

env:
Expand Down Expand Up @@ -87,18 +88,18 @@ jobs:
test-api-reference-docs:
runs-on: ubuntu-latest
steps:
- name: get code
- name: get code
uses: actions/checkout@v4
- name: install python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: install poetry
- name: install poetry
uses: snok/install-poetry@v1
with:
version: ${{ env.POETRY_VERSION }}

- name: Install dependencies
- name: Install dependencies
run: make install-sphinx-deps

- name: Build API documentation
Expand All @@ -107,7 +108,7 @@ jobs:
# Run integration tests against the API (only on the main branch, though). The comprehensive
# version runs a matrix of python versions for better coverage.
# This tests runs on
# This tests runs on
# - merges to main
# - releases
# - branch names ending with "-fulltest"
Expand Down Expand Up @@ -235,7 +236,7 @@ jobs:
steps:
- name: Get code
uses: actions/checkout@v4
- name: Install poetry
- name: Install poetry
uses: snok/install-poetry@v1
with:
version: ${{ env.POETRY_VERSION }}
Expand All @@ -248,12 +249,12 @@ jobs:
run: npm install
- name: Install sphinx dependencies
run: |
cd ..
cd ..
make install-sphinx-deps
- name: Build website
run: |
cd ..
make docs-comprehensive
make docs-comprehensive
- name: Deploy website (if on main branch)
# Docs: https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-docusaurus
uses: peaceiris/actions-gh-pages@v3
Expand Down
8 changes: 6 additions & 2 deletions test/unit/test_actions.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from datetime import datetime

import pytest
from groundlight import ExperimentalApi
from openapi_client.exceptions import NotFoundException


def test_create_action(gl: ExperimentalApi):
det = gl.get_or_create_detector("testing_detector", "test_query")
name = f"Test {datetime.utcnow()}"
det = gl.get_or_create_detector(name, "test_query")
rule = gl.create_rule(det, "test_rule", "EMAIL", "[email protected]")
rule2 = gl.get_rule(rule.id)
assert rule == rule2
Expand All @@ -15,10 +18,11 @@ def test_create_action(gl: ExperimentalApi):

@pytest.mark.skip(reason="actions are global on account, the test matrix collides with itself") # type: ignore
def test_get_all_actions(gl: ExperimentalApi):
name = f"Test {datetime.utcnow()}"
num_test_rules = 13 # needs to be larger than the default page size
gl.ITEMS_PER_PAGE = 10
assert gl.ITEMS_PER_PAGE < num_test_rules
det = gl.get_or_create_detector("test_detector", "test_query")
det = gl.get_or_create_detector(name, "test_query")
gl.delete_all_rules()
for i in range(num_test_rules):
_ = gl.create_rule(det, f"test_rule_{i}", "EMAIL", "[email protected]")
Expand Down
5 changes: 4 additions & 1 deletion test/unit/test_images.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
from datetime import datetime

import PIL
from groundlight import ExperimentalApi


def test_get_image(gl: ExperimentalApi):
det = gl.get_or_create_detector("test_detector", "test_query")
name = f"Test {datetime.utcnow()}"
det = gl.get_or_create_detector(name, "test_query")
iq = gl.submit_image_query(det, image="test/assets/dog.jpeg", wait=10)
gl.get_image(iq.id)
assert isinstance(PIL.Image.open(gl.get_image(iq.id)), PIL.Image.Image)

0 comments on commit ac1c114

Please sign in to comment.