Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed CI/CD Tests for Edge-Endpoint #70

Merged
merged 46 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
2cebf22
Updated sdk version
honeytung Jun 29, 2024
1f5e275
Updated sdk model
honeytung Jun 29, 2024
b90a327
Fixed pydantic checks
honeytung Jun 29, 2024
6c73ba6
Removed metadata
honeytung Jun 29, 2024
6b28fcb
Added pydantic module validation
honeytung Jun 29, 2024
2157023
Increased confidence target value
honeytung Jul 1, 2024
0513f53
Added debugging text
honeytung Jul 1, 2024
e07cdfc
Updated inference threshold
honeytung Jul 1, 2024
d66f149
Updated witb new patience_time
honeytung Jul 1, 2024
627849f
Added more debugging messages
honeytung Jul 2, 2024
86a0caa
Allowed pytest to display logs
honeytung Jul 2, 2024
581f8ff
Changed the motion detection test so that it checks the confidence wh…
honeytung Jul 2, 2024
59b05d6
Increased confidence threshold
honeytung Jul 2, 2024
624bd0b
Fixed TypeError bug
honeytung Jul 2, 2024
eab80f9
Reverted test case
honeytung Jul 2, 2024
37bd6a9
Pytest tests
honeytung Jul 2, 2024
60553f8
Updated image
honeytung Jul 2, 2024
3a1e41b
Added comments
honeytung Jul 2, 2024
0e2fcd5
Added more information in error messages
honeytung Jul 2, 2024
92a5ecb
Updated FrameGrab to 0.5.2
honeytung Jul 2, 2024
fb53c5e
Added logic to check if the request has timeout
honeytung Jul 2, 2024
a0f2523
Added comments
honeytung Jul 3, 2024
cd34d62
Fixed typo
honeytung Jul 3, 2024
1bd778f
Increased wait time
honeytung Jul 3, 2024
5c8c0b6
Added tests for human review
honeytung Jul 3, 2024
2b715bc
Added confidence logging messages
honeytung Jul 3, 2024
6e27aa0
Added confidence message
honeytung Jul 3, 2024
12a31d3
Updated motion detection test
honeytung Jul 3, 2024
84f4840
Removed debug logs
honeytung Jul 3, 2024
0057541
Fixed confidence logic for pytest skip
honeytung Jul 3, 2024
8f873e2
Automatically reformatting code with black and isort
Jul 3, 2024
fd8232b
Updated test to use a higher detector confidence threshold
honeytung Jul 4, 2024
a5db3ad
Update confidence threshold to be guarantee cloud escalation
honeytung Jul 4, 2024
9ebc22c
Refactored code
honeytung Jul 8, 2024
ae78c67
Automatically reformatting code with black and isort
Jul 8, 2024
e85b22f
Added debug message for _is_confident_enough()
honeytung Jul 8, 2024
703f65c
Automatically reformatting code with black and isort
Jul 8, 2024
75300e5
Removed threshold
honeytung Jul 8, 2024
945d276
Automatically reformatting code with black and isort
Jul 8, 2024
66cf159
Updated threshold
honeytung Jul 8, 2024
a6aaf2c
Removed wait time to prevent from escalating to cloud labelers
honeytung Jul 8, 2024
a65561b
Automatically reformatting code with black and isort
Jul 8, 2024
c40d38c
Removed test case as it is based on sdk misunderstanding
honeytung Jul 8, 2024
2d0e32f
Automatically reformatting code with black and isort
Jul 8, 2024
d4c8720
Added patience_time
honeytung Jul 8, 2024
a94c2cf
Automatically reformatting code with black and isort
Jul 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/api/routes/image_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ async def post_image_query(
detector_metadata=get_detector_metadata(detector_id=detector_id, gl=gl),
confidence_threshold=confidence_threshold,
):
logger.debug("Motion detection confidence is high enough to return")
logger.debug("Motion detection confidence is high enough to return.")
app_state.db_manager.create_iqe_record(record=new_image_query)
return new_image_query

Expand Down
6 changes: 4 additions & 2 deletions app/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,24 @@

import ksuid
from fastapi import HTTPException
from model import ClassificationResult, ImageQuery, ImageQueryTypeEnum, ResultTypeEnum
from model import BinaryClassificationResult, ImageQuery, ImageQueryTypeEnum, ResultTypeEnum
from PIL import Image


def create_iqe(detector_id: str, label: str, confidence: float, query: str = "") -> ImageQuery:
iq = ImageQuery(
metadata=None,
id=prefixed_ksuid(prefix="iqe_"),
type=ImageQueryTypeEnum.image_query,
created_at=datetime.utcnow(),
query=query,
detector_id=detector_id,
result_type=ResultTypeEnum.binary_classification,
result=ClassificationResult(
result=BinaryClassificationResult(
confidence=confidence,
label=label,
),
patience_time=30.0,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was there a specific reason to add this? It should be taken as an argument to create_iqe and the true requested patience_time should be set here from post_image_query

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea I added when I was doing some testing and forget to add to post_image_query. Will add it back.

)
return iq

Expand Down
6 changes: 3 additions & 3 deletions deploy/k3s/edge_deployment/edge_deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ spec:
serviceAccountName: edge-endpoint-service-account
initContainers:
- name: database-prep
image: 723181461334.dkr.ecr.us-west-2.amazonaws.com/edge-endpoint:harry-filesize-increase-97f8caf33-dirty-acfc15abc21676c
image: 723181461334.dkr.ecr.us-west-2.amazonaws.com/edge-endpoint:cicd-fix-37bd6a998-dirty-651bd9e5ddf401a
imagePullPolicy: IfNotPresent
env:
# Flag to indicate whether or not to reset all database tables. Resetting WILL delete
Expand All @@ -59,7 +59,7 @@ spec:

containers:
- name: edge-endpoint
image: 723181461334.dkr.ecr.us-west-2.amazonaws.com/edge-endpoint:harry-filesize-increase-97f8caf33-dirty-acfc15abc21676c
image: 723181461334.dkr.ecr.us-west-2.amazonaws.com/edge-endpoint:cicd-fix-37bd6a998-dirty-651bd9e5ddf401a
imagePullPolicy: IfNotPresent
ports:
- containerPort: 6717
Expand All @@ -83,7 +83,7 @@ spec:
mountPath: /opt/groundlight/edge/sqlite

- name: inference-model-updater
image: 723181461334.dkr.ecr.us-west-2.amazonaws.com/edge-endpoint:harry-filesize-increase-97f8caf33-dirty-acfc15abc21676c
image: 723181461334.dkr.ecr.us-west-2.amazonaws.com/edge-endpoint:cicd-fix-37bd6a998-dirty-651bd9e5ddf401a
imagePullPolicy: IfNotPresent
command: ["/bin/bash", "-c"]
args: ["poetry run python -m app.model_updater.update_models"]
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fastapi = "^0.88.0"
pydantic = "<2.0"
opencv-python = "^4.7.0.72"
pillow = "^9.5.0"
framegrab = "^0.4.3"
framegrab = "^0.5.0"
pyyaml = "^6.0"
svix-ksuid = "^0.6.2"
cachetools = "^5.3.1"
Expand All @@ -21,7 +21,7 @@ kubernetes = "^27.2.0"
jinja2 = "^3.1.2"
SQLAlchemy = "2.0.22"
APScheduler = "3.10.4"
groundlight = "^0.13.1"
groundlight = "^0.17.0"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes me happy


[tool.poetry.group.dev.dependencies]
pytest = "^7.2.0"
Expand Down
34 changes: 0 additions & 34 deletions test/api/test_motdet.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,37 +231,3 @@ def test_motion_detection_skipped_when_human_review_requested(gl: Groundlight, r
assert new_response.id.startswith(
"iq_"
), "ImageQuery id should start with 'iq_' because it was created on the cloud, because Human Review was requested"


def test_motion_detection_not_sufficient_if_doesnt_meet_conf_threshold(gl: Groundlight, root_config: RootEdgeConfig):
if not motion_detection_enabled(root_config):
pytest.skip("Motion detection is disabled")

detector_id = DETECTORS["dog_detector"]["detector_id"]
detector = gl.get_detector(id=detector_id)

original_image = Image.open("test/assets/dog.jpeg")

# Set up opportunity for motion detection
base_iq_response = gl.submit_image_query(
detector=detector.id, image=original_image, wait=10, confidence_threshold=0.5
)
if (
base_iq_response.result is None
or base_iq_response.result.confidence is None
or base_iq_response.result.confidence == 1.0
):
pytest.skip("This test requires that the cached image query response has a confidence < 1.0")

new_response = gl.submit_image_query(
detector=detector.id,
image=original_image,
wait=10,
confidence_threshold=base_iq_response.result.confidence + 1e-5, # Require a higher confidence than before
)

assert new_response.id != base_iq_response.id, "ImageQuery id should be different whether or not motion det is run"
assert new_response.id.startswith("iq_"), (
"ImageQuery id should start with 'iq_' because it was created on the cloud, because the cached mot det response"
" did not meet the confidence threshold"
)