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

General improvements (pydanticv2, health checks, better testing, cleanup) #98

Merged
merged 25 commits into from
Oct 8, 2024

Conversation

tyler-romero
Copy link
Member

@tyler-romero tyler-romero commented Oct 6, 2024

Clean up the codebase and make some general improvements:

  1. Upgrade to pydanticv2
  2. Add health checks
  3. Move database models to their own file (standard practice, helps prevent circular imports)
  4. Use in-memory DB for all tests
  5. Rename things in the database manager
  6. Remove unused or useless code (remote.py, the detectors endpoints)
  7. Additional (but still weak) tests for POST /image_query (that dont require a docker container)
  8. Correct error codes and exceptions
  9. Just generally clean and consolidate things

@tyler-romero tyler-romero changed the title General improvements (pydanticv2, health checks, cleanup) General improvements (pydanticv2, health checks, better testing, cleanup) Oct 6, 2024
Copy link
Member Author

Choose a reason for hiding this comment

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

Anyone know of any reason why these were needed? I think these sort of passthroughs to the cloud should be handled by nginx.

Copy link
Member Author

Choose a reason for hiding this comment

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

Dead code

pyproject.toml Outdated
framegrab = "^0.5.0"
groundlight = "^0.17.6"
groundlight = "<0.18.0"
Copy link
Member Author

@tyler-romero tyler-romero Oct 6, 2024

Choose a reason for hiding this comment

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

Needed until the endpoint is updated to handle the new sdk response format for non-binary modes.

Copy link
Contributor

Choose a reason for hiding this comment

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

See my comment on your other PR - we should really be pinning to a specific version here

logger.debug(f"Edge detector confidence is high enough to return. {detector_id=}")

result_type, results = _mode_to_result_type(detector_metadata.mode, results)
patience_time = patience_time or constants.DEFAULT_PATIENCE_TIME
Copy link
Contributor

@CoreyEWood CoreyEWood Oct 7, 2024

Choose a reason for hiding this comment

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

This might create a small bug - this will go to the False case if patience_time is 0.0, right? (fixed in my incoming PR so no need to change here)

Copy link
Member Author

Choose a reason for hiding this comment

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

good point! thanks!

@@ -41,19 +42,20 @@ def create_iqe(
return iq


def safe_call_api(api_method: Callable, **kwargs):
def safe_call_sdk(api_method: Callable, **kwargs):
Copy link
Contributor

Choose a reason for hiding this comment

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

Just flagging that this is what's creating issues with test_reset_retry (here) from the SDK tests.

@tyler-romero tyler-romero force-pushed the tyler/general-improvements-2 branch from a189299 to 4870100 Compare October 7, 2024 23:44
Copy link
Contributor

@tomfaulhaber tomfaulhaber left a comment

Choose a reason for hiding this comment

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

This is a lot of stuff, but it looks good!

. test/setup_plain_test_env.sh && poetry run pytest -vs -k "not test_motdet"
. test/setup_plain_test_env.sh && poetry run pytest --cov=app --cov-report=lcov -vs -k "not test_motdet and not _live"

test-with-docker: install # Run tests that require a live edge-endpoint server and valid GL API token
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also have a test-all target that runs all the tests (Docker and non-Docker) in a single run.

@@ -9,7 +10,10 @@ install-pre-commit: install ## Install pre-commit hooks. Requires .pre-commit-c
poetry run pre-commit install

test: install ## Run unit tests in verbose mode
. test/setup_plain_test_env.sh && poetry run pytest -vs -k "not test_motdet"
. test/setup_plain_test_env.sh && poetry run pytest --cov=app --cov-report=lcov -vs -k "not test_motdet and not _live"
Copy link
Contributor

Choose a reason for hiding this comment

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

There seems to be no default situation that includes the motion detection test. Is this intentional?

Copy link
Member Author

Choose a reason for hiding this comment

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

You might think that, but we run them in their own separate job... Probably worth consolidating that too.

tyler-romero and others added 2 commits October 7, 2024 17:13
Adds to previous code to fully support new mode structure. 

Multiclass is not supported for the time being but will be easy to add.

---------

Co-authored-by: Auto-format Bot <autoformatbot@groundlight.ai>
Co-authored-by: Tyler Romero <tyler@groundlight.ai>
@tyler-romero tyler-romero merged commit b9fa032 into main Oct 8, 2024
6 checks passed
@tyler-romero tyler-romero deleted the tyler/general-improvements-2 branch October 8, 2024 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants