pyronear / pyro-api

Alert Management API for wildfire prevention, detection & monitoring. Built with FastAPI & PostgreSQL
Apache License 2.0
21 stars 9 forks source link

refactor(models): implement the new data model #322

Closed frgfm closed 3 months ago

frgfm commented 4 months ago

Following up on #304, this PR introduces the following modifications:

The only things missing are:

In the following PRs, this is what will be added:

Any feedback is welcome!

MateoLostanlen commented 4 months ago

Hi @frgfm, Love this PR! It will make life easier for us and for pyronear newbies as well !

Just a few things:

To anticipate the use of camera ptz it would be preferable to have a tuple for azimuth in the camera table and to have an azimuth entry (float this time) in the detection table.

Localization is missing from the detection table too.

I'm not sure how you intend to associate a camera list with a user (sdis 7 for example). What do you have planned?

frgfm commented 4 months ago

To anticipate the use of camera ptz it would be preferable to have a tuple for azimuth in the camera table and to have an azimuth entry (float this time) in the detection table.

Could you remind me of how is a camera ptz different and why the tuple?

Localization is missing from the detection table too.

It's by design: considering that at this stage, we report a detection from a camera, but we don't have more. But perhaps you mean the bounding box on the image itself? If so, I agree that we need to add it. Perhaps in the next PR to keep this one simple? Would a keypoint be enough? (I'm thinking about the usefulness, and the bounding box is linked to the type of model we use, but it's far from comprehensive, a keypoint would perhaps be more robust for the data model?)

I'm not sure how you intend to associate a camera list with a user (sdis 7 for example). What do you have planned?

cf. the region/scope followup PR I mentioned in the description. Hesitating on the name, but I think "organizations" would work:

Then the rest of the logic is easy to implement, and that doesn't complicate things too much

MateoLostanlen commented 4 months ago

Basically, ptz cameras can be oriented along 3 axes. In our case, both our cameras and those of the Firefighters will patrol N predefined positions. It would therefore be interesting to have these N positions in the form of a tuple (or list of size N). Then, when the cam sends an alert, we'll add the azimuth to the detection table to find out the corresponding position. For statis cams, we'll have a list / tuple of size 1 that will always be equal to the value sent to the detection table.

Yes, I'm talking about the bounding box, which is called localization in the current table, but I agree that the name can be changed. I suggest you keep what we have at the moment, a string that allows you to send any form of points (bbox, keypoints etc ...)

Ok understood for the organization

MateoLostanlen commented 4 months ago

Yes, don't worry about adding the bbox in a next pr as long as it's present when you deploy it. It's essential information for firefighters to speed up treatment time.

codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 88.74296% with 60 lines in your changes missing coverage. Please review.

Project coverage is 88.00%. Comparing base (767be30) to head (44506bf).

Files Patch % Lines
src/app/crud/base.py 76.36% 13 Missing :warning:
src/app/db.py 59.37% 13 Missing :warning:
src/app/api/api_v1/endpoints/login.py 68.18% 7 Missing :warning:
src/app/main.py 76.00% 6 Missing :warning:
src/app/api/api_v1/endpoints/users.py 86.48% 5 Missing :warning:
src/app/services/storage.py 54.54% 5 Missing :warning:
src/app/api/api_v1/endpoints/detections.py 94.54% 3 Missing :warning:
src/app/core/config.py 94.44% 3 Missing :warning:
src/app/api/dependencies.py 95.45% 2 Missing :warning:
src/app/services/telemetry.py 60.00% 2 Missing :warning:
... and 1 more
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #322 +/- ## ========================================== - Coverage 94.54% 88.00% -6.54% ========================================== Files 63 28 -35 Lines 1594 642 -952 ========================================== - Hits 1507 565 -942 + Misses 87 77 -10 ``` | [Flag](https://app.codecov.io/gh/pyronear/pyro-api/pull/322/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pyronear) | Coverage Δ | | |---|---|---| | [backend](https://app.codecov.io/gh/pyronear/pyro-api/pull/322/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pyronear) | `87.47% <88.56%> (?)` | | | [client](https://app.codecov.io/gh/pyronear/pyro-api/pull/322/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pyronear) | `95.34% <94.11%> (?)` | | | [unittests](https://app.codecov.io/gh/pyronear/pyro-api/pull/322/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pyronear) | `?` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pyronear#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

frgfm commented 3 months ago

Here are the last edits:

The test suite is considerably faster than before :sweat_smile:

Suggestions for review considering the size of the PR (most of the diff is from the poetry.lock though):

Things to add to prevent feature reduction compared to the previous version:

frgfm commented 3 weeks ago

cf #304