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

Small tweaks based on feedback #380

Merged
merged 5 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions ami/main/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ class Meta:
"classifications",
]

def get_classifications(self, obj):
def get_classifications(self, obj) -> str:
"""
Return URL to the classifications endpoint filtered by this detection.
"""
Expand Down Expand Up @@ -949,7 +949,7 @@ class Meta:
"updated_at",
]

def get_source_images(self, obj):
def get_source_images(self, obj) -> str:
"""
Return URL to the captures endpoint filtered by this collection.
"""
Expand Down
9 changes: 8 additions & 1 deletion ami/main/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
from rest_framework import viewsets
from rest_framework.decorators import action
from rest_framework.filters import SearchFilter
from rest_framework.generics import GenericAPIView
from rest_framework.response import Response
from rest_framework.views import APIView

from ami import tasks
from ami.base.filters import NullsLastOrderingFilter
from ami.base.pagination import LimitOffsetPaginationWithPermissions
from ami.base.permissions import IsActiveStaffOrReadOnly
from ami.utils.requests import get_active_classification_threshold

Expand Down Expand Up @@ -98,13 +100,18 @@ class DefaultReadOnlyViewSet(DefaultViewSetMixin, viewsets.ReadOnlyModelViewSet)
pass


class ProjectPagination(LimitOffsetPaginationWithPermissions):
default_limit = 20


class ProjectViewSet(DefaultViewSet):
"""
API endpoint that allows projects to be viewed or edited.
"""

queryset = Project.objects.filter(active=True).prefetch_related("deployments").all()
serializer_class = ProjectSerializer
pagination_class = ProjectPagination

def get_serializer_class(self):
"""
Expand Down Expand Up @@ -694,7 +701,7 @@ class ClassificationViewSet(DefaultViewSet):
]


class SummaryView(APIView):
class SummaryView(GenericAPIView):
permission_classes = [IsActiveStaffOrReadOnly]
filterset_fields = ["project"]

Expand Down
2 changes: 1 addition & 1 deletion ami/main/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2182,7 +2182,7 @@ class SourceImageCollection(BaseModel):
default=dict,
)

def source_image_count(self):
def source_image_count(self) -> int:
# This should always be pre-populated using queryset annotations
return self.images.count()

Expand Down
4 changes: 2 additions & 2 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,8 @@
"TITLE": "Automated Monitoring of Insects ML Platform API",
"DESCRIPTION": "Documentation of API endpoints of Automated Monitoring of Insects ML Platform",
"VERSION": "1.0.0",
"SERVE_PERMISSIONS": ["rest_framework.permissions.IsAdminUser"],
# "SERVE_PERMISSIONS": ["rest_framework.permissions.AllowAny"],
# "SERVE_PERMISSIONS": ["rest_framework.permissions.IsAdminUser"],
"SERVE_PERMISSIONS": ["rest_framework.permissions.AllowAny"],
}
# Your stuff...
# ------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# API base url
path("api/v2/", include("config.api_router", namespace="api")),
# OpenAPI Docs
path("api/v2/schema/", SpectacularAPIView.as_view(), name="api-schema"),
path("api/v2/schema/", SpectacularAPIView.as_view(api_version="api"), name="api-schema"),
path(
"api/v2/docs/",
SpectacularSwaggerView.as_view(url_name="api-schema"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const config: FormConfig = {
label: translate(STRING.FIELD_LABEL_NAME),
},
image: {
label: translate(STRING.FIELD_LABEL_IMAGE),
label: translate(STRING.FIELD_LABEL_ICON),
description: [
translate(STRING.MESSAGE_IMAGE_SIZE, {
value: bytesToMB(API_MAX_UPLOAD_SIZE),
Expand Down
2 changes: 1 addition & 1 deletion ui/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ export const APP_ROUTES = {
`/projects/${params.projectId}/collections/${params.collectionId}`,
}

export const API_MAX_UPLOAD_SIZE = 1024 * 1024 * 10 // 10MB
export const API_MAX_UPLOAD_SIZE = 1024 * 1024 * 30 // 30MB
18 changes: 10 additions & 8 deletions ui/src/utils/language.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export enum STRING {
FIELD_LABEL_GENERAL,
FIELD_LABEL_ID,
FIELD_LABEL_IMAGE,
FIELD_LABEL_ICON,
FIELD_LABEL_LATITUDE,
FIELD_LABEL_LOCATION,
FIELD_LABEL_LOGS,
Expand Down Expand Up @@ -220,17 +221,18 @@ const ENGLISH_STRINGS: { [key in STRING]: string } = {
[STRING.FIELD_LABEL_CREATED_AT]: 'Created at',
[STRING.FIELD_LABEL_DATE]: 'Date',
[STRING.FIELD_LABEL_DELAY]: 'Delay',
[STRING.FIELD_LABEL_DEVICE]: 'Device',
[STRING.FIELD_LABEL_DEVICE]: 'Device Type',
[STRING.FIELD_LABEL_DEPLOYMENT]: 'Deployment',
[STRING.FIELD_LABEL_DESCRIPTION]: 'Description',
[STRING.FIELD_LABEL_DETECTIONS]: 'Detections',
[STRING.FIELD_LABEL_DURATION]: 'Duration',
[STRING.FIELD_LABEL_EMAIL]: 'Email',
[STRING.FIELD_LABEL_ERRORS]: 'Errors',
[STRING.FIELD_LABEL_FINISHED_AT]: 'Finished at',
[STRING.FIELD_LABEL_GENERAL]: 'General',
[STRING.FIELD_LABEL_GENERAL]: 'General configuration',
[STRING.FIELD_LABEL_ID]: 'ID',
[STRING.FIELD_LABEL_IMAGE]: 'Image',
[STRING.FIELD_LABEL_IMAGE]: 'Cover Image',
[STRING.FIELD_LABEL_ICON]: 'Icon',
[STRING.FIELD_LABEL_LATITUDE]: 'Latitude',
[STRING.FIELD_LABEL_LOCATION]: 'Location',
[STRING.FIELD_LABEL_LOGS]: 'Logs',
Expand All @@ -255,13 +257,13 @@ const ENGLISH_STRINGS: { [key in STRING]: string } = {
[STRING.FIELD_LABEL_STATUS]: 'Status',
[STRING.FIELD_LABEL_TAXON]: 'Taxon',
[STRING.FIELD_LABEL_THUMBNAIL]: 'Thumbnail',
[STRING.FIELD_LABEL_TIME]: 'Time',
[STRING.FIELD_LABEL_TIME]: 'Local Time',
[STRING.FIELD_LABEL_TIMESTAMP]: 'Timestamp',
[STRING.FIELD_LABEL_TRAINING_IMAGES]: 'Reference images',
[STRING.FIELD_LABEL_FIRST_DATE]: 'First date',
[STRING.FIELD_LABEL_LAST_DATE]: 'Last date',
[STRING.FIELD_LABEL_UPDATED_AT]: 'Updated at',
[STRING.FIELD_LABEL_UPLOADED_CAPTURES]: 'Manually uploaded captures',
[STRING.FIELD_LABEL_UPLOADED_CAPTURES]: 'Sample captures',
[STRING.FIELD_LABEL_VERSION]: 'Version',
[STRING.FIELD_LABEL_VERSION_NAME]: 'Version',

Expand All @@ -270,7 +272,7 @@ const ENGLISH_STRINGS: { [key in STRING]: string } = {
[STRING.ENTITY_DELETE]: 'Delete {{type}}',
[STRING.ENTITY_DETAILS]: '{{type}} details',
[STRING.ENTITY_EDIT]: 'Edit {{type}}',
[STRING.ENTITY_TYPE_CAPTURE]: 'dapture',
[STRING.ENTITY_TYPE_CAPTURE]: 'capture',
[STRING.ENTITY_TYPE_DEPLOYMENT]: 'deployment',
[STRING.ENTITY_TYPE_IDENTIFICATION]: 'identification',
[STRING.ENTITY_TYPE_PIPELINE]: 'pipeline',
Expand All @@ -282,7 +284,7 @@ const ENGLISH_STRINGS: { [key in STRING]: string } = {
[STRING.MESSAGE_CAPTURE_FILENAME]:
'Image filename must contain a timestamp in the format YYYYMMDDHHMMSS (e.g. 20210101120000-snapshot.jpg).',
[STRING.MESSAGE_CAPTURE_LIMIT]:
'A maximum of {{numCaptures}} captures can be uploaded.',
'A maximum of {{numCaptures}} example captures can be uploaded through the web browser. Configure a data source to upload data in bulk.',
[STRING.MESSAGE_CAPTURE_TOO_MANY]:
'To upload more than {{numCaptures}} images you must configure a data source.',
[STRING.MESSAGE_CAPTURE_UPLOAD_HIDDEN]:
Expand Down Expand Up @@ -323,7 +325,7 @@ const ENGLISH_STRINGS: { [key in STRING]: string } = {

/* TAB_ITEM */
[STRING.TAB_ITEM_COLLECTIONS]: 'Collections',
[STRING.TAB_ITEM_DEVICES]: 'Devices',
[STRING.TAB_ITEM_DEVICES]: 'Device Types',
[STRING.TAB_ITEM_FIELDS]: 'Fields',
[STRING.TAB_ITEM_GALLERY]: 'Gallery',
[STRING.TAB_ITEM_IDENTIFICATION]: 'Identification',
Expand Down