-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
be8db8a
commit 7c2b2da
Showing
5 changed files
with
76 additions
and
39 deletions.
There are no files selected for viewing
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
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,33 @@ | ||
import pytest | ||
from groundlight import ExperimentalApi | ||
from datetime import datetime | ||
|
||
from groundlight import ExperimentalApi, Groundlight, Detector, ImageQuery | ||
|
||
@pytest.fixture(name="gl") | ||
def fixture_gl() -> Groundlight: | ||
"""Creates a Groundlight client object for testing.""" | ||
_gl = Groundlight() | ||
_gl.DEFAULT_WAIT = 10 | ||
return _gl | ||
|
||
@pytest.fixture(name="detector") | ||
def fixture_detector(gl: Groundlight) -> Detector: | ||
"""Creates a new Test detector.""" | ||
name = f"Test {datetime.utcnow()}" # Need a unique name | ||
query = "Is there a dog?" | ||
pipeline_config = "never-review" | ||
return gl.create_detector(name=name, query=query, pipeline_config=pipeline_config) | ||
|
||
@pytest.fixture(name="image_query_yes") | ||
def fixture_image_query_yes(gl: Groundlight, detector: Detector) -> ImageQuery: | ||
iq = gl.submit_image_query(detector=detector.id, image="test/assets/dog.jpeg", human_review="NEVER") | ||
return iq | ||
|
||
@pytest.fixture(name="image_query_no") | ||
def fixture_image_query_no(gl: Groundlight, detector: Detector) -> ImageQuery: | ||
iq = gl.submit_image_query(detector=detector.id, image="test/assets/cat.jpeg", human_review="NEVER") | ||
return iq | ||
|
||
@pytest.fixture(name="gl_experimental") | ||
def _gl() -> ExperimentalApi: | ||
return ExperimentalApi() |
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,13 +1,28 @@ | ||
from datetime import datetime | ||
|
||
from groundlight import ExperimentalApi | ||
from groundlight import ExperimentalApi, Detector, ImageQuery, ROI | ||
|
||
|
||
def test_detector_groups(gl: ExperimentalApi): | ||
def test_detector_groups(gl_experimental: ExperimentalApi): | ||
""" | ||
verify that we can create a detector group and retrieve it | ||
""" | ||
name = f"Test {datetime.utcnow()}" | ||
created_group = gl.create_detector_group(name) | ||
all_groups = gl.list_detector_groups() | ||
created_group = gl_experimental.create_detector_group(name) | ||
all_groups = gl_experimental.list_detector_groups() | ||
assert created_group in all_groups | ||
|
||
def test_submit_roi(gl_experimental: ExperimentalApi, image_query_yes: ImageQuery): | ||
""" | ||
verify that we can submit an ROI | ||
""" | ||
label_name = "dog" | ||
roi = gl_experimental.create_roi(label_name, (0, 0), (0.5, 0.5)) | ||
gl_experimental.add_label(image_query_yes.id, "YES", [roi]) | ||
|
||
def test_submit_rois(gl_experimental: ExperimentalApi, image_query_no: ImageQuery): | ||
""" | ||
verify that we can submit multiple ROIs | ||
""" | ||
label_name = "dog" | ||
roi = gl_experimental.create_roi(label_name, (0, 0), (0.5, 0.5)) | ||
gl_experimental.add_label(image_query_no, "YES", [roi]*3) |