From ac1c11461e2fdfa30a2df1acdbf4a610fd2fa49d Mon Sep 17 00:00:00 2001 From: Brandon <132288221+brandon-groundlight@users.noreply.github.com> Date: Wed, 3 Apr 2024 15:27:05 -0700 Subject: [PATCH] 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 --- .github/workflows/cicd.yaml | 15 ++++++++------- test/unit/test_actions.py | 8 ++++++-- test/unit/test_images.py | 5 ++++- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/.github/workflows/cicd.yaml b/.github/workflows/cicd.yaml index d3efbf1e..2a42405e 100644 --- a/.github/workflows/cicd.yaml +++ b/.github/workflows/cicd.yaml @@ -2,6 +2,7 @@ # to pypi. name: cicd on: + workflow_dispatch: push: env: @@ -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 @@ -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" @@ -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 }} @@ -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 diff --git a/test/unit/test_actions.py b/test/unit/test_actions.py index c4451d10..bb84b047 100644 --- a/test/unit/test_actions.py +++ b/test/unit/test_actions.py @@ -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", "test@example.com") rule2 = gl.get_rule(rule.id) assert rule == rule2 @@ -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", "test@example.com") diff --git a/test/unit/test_images.py b/test/unit/test_images.py index edab2651..e35a3cc5 100644 --- a/test/unit/test_images.py +++ b/test/unit/test_images.py @@ -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)