Skip to content

Commit ac1c114

Browse files
brandon-wadaAuto-format Bot
andauthored
Unique detector name (#197)
* 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 <autoformatbot@groundlight.ai>
1 parent 61c43ad commit ac1c114

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

.github/workflows/cicd.yaml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# to pypi.
33
name: cicd
44
on:
5+
workflow_dispatch:
56
push:
67

78
env:
@@ -87,18 +88,18 @@ jobs:
8788
test-api-reference-docs:
8889
runs-on: ubuntu-latest
8990
steps:
90-
- name: get code
91+
- name: get code
9192
uses: actions/checkout@v4
9293
- name: install python
9394
uses: actions/setup-python@v4
9495
with:
9596
python-version: ${{ env.PYTHON_VERSION }}
96-
- name: install poetry
97+
- name: install poetry
9798
uses: snok/install-poetry@v1
9899
with:
99100
version: ${{ env.POETRY_VERSION }}
100101

101-
- name: Install dependencies
102+
- name: Install dependencies
102103
run: make install-sphinx-deps
103104

104105
- name: Build API documentation
@@ -107,7 +108,7 @@ jobs:
107108
108109
# Run integration tests against the API (only on the main branch, though). The comprehensive
109110
# version runs a matrix of python versions for better coverage.
110-
# This tests runs on
111+
# This tests runs on
111112
# - merges to main
112113
# - releases
113114
# - branch names ending with "-fulltest"
@@ -235,7 +236,7 @@ jobs:
235236
steps:
236237
- name: Get code
237238
uses: actions/checkout@v4
238-
- name: Install poetry
239+
- name: Install poetry
239240
uses: snok/install-poetry@v1
240241
with:
241242
version: ${{ env.POETRY_VERSION }}
@@ -248,12 +249,12 @@ jobs:
248249
run: npm install
249250
- name: Install sphinx dependencies
250251
run: |
251-
cd ..
252+
cd ..
252253
make install-sphinx-deps
253254
- name: Build website
254255
run: |
255256
cd ..
256-
make docs-comprehensive
257+
make docs-comprehensive
257258
- name: Deploy website (if on main branch)
258259
# Docs: https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-docusaurus
259260
uses: peaceiris/actions-gh-pages@v3

test/unit/test_actions.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
from datetime import datetime
2+
13
import pytest
24
from groundlight import ExperimentalApi
35
from openapi_client.exceptions import NotFoundException
46

57

68
def test_create_action(gl: ExperimentalApi):
7-
det = gl.get_or_create_detector("testing_detector", "test_query")
9+
name = f"Test {datetime.utcnow()}"
10+
det = gl.get_or_create_detector(name, "test_query")
811
rule = gl.create_rule(det, "test_rule", "EMAIL", "test@example.com")
912
rule2 = gl.get_rule(rule.id)
1013
assert rule == rule2
@@ -15,10 +18,11 @@ def test_create_action(gl: ExperimentalApi):
1518

1619
@pytest.mark.skip(reason="actions are global on account, the test matrix collides with itself") # type: ignore
1720
def test_get_all_actions(gl: ExperimentalApi):
21+
name = f"Test {datetime.utcnow()}"
1822
num_test_rules = 13 # needs to be larger than the default page size
1923
gl.ITEMS_PER_PAGE = 10
2024
assert gl.ITEMS_PER_PAGE < num_test_rules
21-
det = gl.get_or_create_detector("test_detector", "test_query")
25+
det = gl.get_or_create_detector(name, "test_query")
2226
gl.delete_all_rules()
2327
for i in range(num_test_rules):
2428
_ = gl.create_rule(det, f"test_rule_{i}", "EMAIL", "test@example.com")

test/unit/test_images.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
from datetime import datetime
2+
13
import PIL
24
from groundlight import ExperimentalApi
35

46

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

0 commit comments

Comments
 (0)