Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
NACSOS Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MCC APSIS
NACSOS
NACSOS Core
Commits
0c753c2a
Commit
0c753c2a
authored
2 years ago
by
Tim Repke
Browse files
Options
Downloads
Patches
Plain Diff
rename annotation task to scheme
parent
d334dc7d
No related branches found
No related tags found
No related merge requests found
Pipeline
#740
failed
2 years ago
Stage: build
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
server/api/routes/annotations.py
+32
-32
32 additions, 32 deletions
server/api/routes/annotations.py
with
32 additions
and
32 deletions
server/api/routes/annotations.py
+
32
−
32
View file @
0c753c2a
from
fastapi
import
APIRouter
,
Depends
,
HTTPException
,
status
as
http_status
from
fastapi
import
APIRouter
,
Depends
,
HTTPException
,
status
as
http_status
from
nacsos_data.models.annotations
import
Annotation
Task
Model
,
\
from
nacsos_data.models.annotations
import
Annotation
Scheme
Model
,
\
AssignmentScopeModel
,
\
AssignmentScopeModel
,
\
AssignmentModel
,
\
AssignmentModel
,
\
AssignmentStatus
,
\
AssignmentStatus
,
\
...
@@ -16,12 +16,12 @@ from nacsos_data.db.crud.annotations import \
...
@@ -16,12 +16,12 @@ from nacsos_data.db.crud.annotations import \
read_annotations_for_assignment
,
\
read_annotations_for_assignment
,
\
read_next_assignment_for_scope_for_user
,
\
read_next_assignment_for_scope_for_user
,
\
read_next_open_assignment_for_scope_for_user
,
\
read_next_open_assignment_for_scope_for_user
,
\
read_annotation_
task
,
\
read_annotation_
scheme
,
\
read_annotation_
task
s_for_project
,
\
read_annotation_
scheme
s_for_project
,
\
upsert_annotations
,
\
upsert_annotations
,
\
read_assignment_scope
,
\
read_assignment_scope
,
\
upsert_annotation_
task
,
\
upsert_annotation_
scheme
,
\
delete_annotation_
task
,
\
delete_annotation_
scheme
,
\
upsert_assignment_scope
,
\
upsert_assignment_scope
,
\
delete_assignment_scope
,
\
delete_assignment_scope
,
\
read_item_ids_with_assignment_count_for_project
,
\
read_item_ids_with_assignment_count_for_project
,
\
...
@@ -30,7 +30,7 @@ from nacsos_data.db.crud.annotations import \
...
@@ -30,7 +30,7 @@ from nacsos_data.db.crud.annotations import \
AssignmentCounts
,
\
AssignmentCounts
,
\
UserProjectAssignmentScope
,
\
UserProjectAssignmentScope
,
\
store_assignments
store_assignments
from
nacsos_data.util.annotations.validation
import
merge_
task
_and_annotations
,
annotated_
task
_to_annotations
from
nacsos_data.util.annotations.validation
import
merge_
scheme
_and_annotations
,
annotated_
scheme
_to_annotations
from
nacsos_data.util.annotations.assignments.random
import
random_assignments
from
nacsos_data.util.annotations.assignments.random
import
random_assignments
from
pydantic
import
BaseModel
from
pydantic
import
BaseModel
...
@@ -41,7 +41,7 @@ router = APIRouter()
...
@@ -41,7 +41,7 @@ router = APIRouter()
class
AnnotatedItem
(
BaseModel
):
class
AnnotatedItem
(
BaseModel
):
task
:
Annotation
Task
Model
scheme
:
Annotation
Scheme
Model
assignment
:
AssignmentModel
assignment
:
AssignmentModel
...
@@ -50,51 +50,51 @@ class AnnotationItem(AnnotatedItem):
...
@@ -50,51 +50,51 @@ class AnnotationItem(AnnotatedItem):
item
:
AnyItemModel
item
:
AnyItemModel
@router.get
(
'
/
task
s/definition/{
task
_id}
'
,
response_model
=
Annotation
Task
Model
)
@router.get
(
'
/
scheme
s/definition/{
annotation_scheme
_id}
'
,
response_model
=
Annotation
Scheme
Model
)
async
def
get_
task
_definition
(
task
_id
:
str
)
->
Annotation
Task
Model
:
async
def
get_
scheme
_definition
(
annotation_scheme
_id
:
str
)
->
Annotation
Scheme
Model
:
"""
"""
This endpoint returns the detailed definition of an annotation
task
.
This endpoint returns the detailed definition of an annotation
scheme
.
:param
task
_id: database id of the annotation
task
.
:param
annotation_scheme
_id: database id of the annotation
scheme
.
:return: a single annotation
task
:return: a single annotation
scheme
"""
"""
return
await
read_annotation_
task
(
annotation_
task_id
=
task
_id
,
engine
=
db_engine
)
return
await
read_annotation_
scheme
(
annotation_
scheme_id
=
annotation_scheme
_id
,
engine
=
db_engine
)
@router.put
(
'
/
task
s/definition/
'
,
response_model
=
str
)
@router.put
(
'
/
scheme
s/definition/
'
,
response_model
=
str
)
async
def
put_annotation_
task
(
annotation_
task
:
Annotation
Task
Model
,
async
def
put_annotation_
scheme
(
annotation_
scheme
:
Annotation
Scheme
Model
,
permissions
=
Depends
(
UserPermissionChecker
(
'
annotations_edit
'
)))
->
str
:
permissions
=
Depends
(
UserPermissionChecker
(
'
annotations_edit
'
)))
->
str
:
key
=
await
upsert_annotation_
task
(
annotation_
task
=
annotation_
task
,
engine
=
db_engine
)
key
=
await
upsert_annotation_
scheme
(
annotation_
scheme
=
annotation_
scheme
,
engine
=
db_engine
)
return
str
(
key
)
return
str
(
key
)
@router.delete
(
'
/
task
s/definition/{
task
_id}
'
)
@router.delete
(
'
/
scheme
s/definition/{
scheme
_id}
'
)
async
def
remove_annotation_
task
(
task
_id
:
str
)
->
None
:
async
def
remove_annotation_
scheme
(
annotation_scheme
_id
:
str
)
->
None
:
await
delete_annotation_
task
(
annotation_
task_id
=
task
_id
,
engine
=
db_engine
)
await
delete_annotation_
scheme
(
annotation_
scheme_id
=
annotation_scheme
_id
,
engine
=
db_engine
)
@router.get
(
'
/
task
s/list/{project_id}
'
,
response_model
=
list
[
Annotation
Task
Model
])
@router.get
(
'
/
scheme
s/list/{project_id}
'
,
response_model
=
list
[
Annotation
Scheme
Model
])
async
def
get_
task
_definitions_for_project
(
project_id
:
str
)
->
list
[
Annotation
Task
Model
]:
async
def
get_
scheme
_definitions_for_project
(
project_id
:
str
)
->
list
[
Annotation
Scheme
Model
]:
"""
"""
This endpoint returns the detailed definitions of all annotation
task
s associated with a project.
This endpoint returns the detailed definitions of all annotation
scheme
s associated with a project.
:param project_id: database id of the project
:param project_id: database id of the project
:return: list of annotation
task
s
:return: list of annotation
scheme
s
"""
"""
return
await
read_annotation_
task
s_for_project
(
project_id
=
project_id
,
engine
=
db_engine
)
return
await
read_annotation_
scheme
s_for_project
(
project_id
=
project_id
,
engine
=
db_engine
)
async
def
_construct_annotation_item
(
assignment
:
AssignmentModel
,
project_id
:
str
)
->
AnnotationItem
:
async
def
_construct_annotation_item
(
assignment
:
AssignmentModel
,
project_id
:
str
)
->
AnnotationItem
:
scope
=
await
read_assignment_scope
(
assignment_scope_id
=
assignment
.
assignment_scope_id
,
engine
=
db_engine
)
scope
=
await
read_assignment_scope
(
assignment_scope_id
=
assignment
.
assignment_scope_id
,
engine
=
db_engine
)
task
=
await
read_annotation_
task
(
annotation_
task
_id
=
assignment
.
task
_id
,
engine
=
db_engine
)
scheme
=
await
read_annotation_
scheme
(
annotation_
scheme
_id
=
assignment
.
annotation_scheme
_id
,
engine
=
db_engine
)
annotations
=
await
read_annotations_for_assignment
(
assignment_id
=
assignment
.
assignment_id
,
engine
=
db_engine
)
annotations
=
await
read_annotations_for_assignment
(
assignment_id
=
assignment
.
assignment_id
,
engine
=
db_engine
)
task
=
merge_
task
_and_annotations
(
annotation_
task
=
task
,
annotations
=
annotations
)
scheme
=
merge_
scheme
_and_annotations
(
annotation_
scheme
=
scheme
,
annotations
=
annotations
)
project
=
await
read_project_by_id
(
project_id
=
project_id
,
engine
=
db_engine
)
project
=
await
read_project_by_id
(
project_id
=
project_id
,
engine
=
db_engine
)
item
=
await
read_any_item_by_item_id
(
item_id
=
assignment
.
item_id
,
item_type
=
project
.
type
,
engine
=
db_engine
)
item
=
await
read_any_item_by_item_id
(
item_id
=
assignment
.
item_id
,
item_type
=
project
.
type
,
engine
=
db_engine
)
return
AnnotationItem
(
task
=
task
,
assignment
=
assignment
,
scope
=
scope
,
item
=
item
)
return
AnnotationItem
(
scheme
=
scheme
,
assignment
=
assignment
,
scope
=
scope
,
item
=
item
)
@router.get
(
'
/annotate/next/{assignment_scope_id}/{current_assignment_id}
'
,
response_model
=
AnnotationItem
)
@router.get
(
'
/annotate/next/{assignment_scope_id}/{current_assignment_id}
'
,
response_model
=
AnnotationItem
)
...
@@ -222,8 +222,8 @@ async def save_annotation(annotated_item: AnnotatedItem,
...
@@ -222,8 +222,8 @@ async def save_annotation(annotated_item: AnnotatedItem,
if
permissions
.
user
.
user_id
==
assignment_db
.
user_id
\
if
permissions
.
user
.
user_id
==
assignment_db
.
user_id
\
and
str
(
assignment_db
.
assignment_scope_id
)
==
annotated_item
.
assignment
.
assignment_scope_id
\
and
str
(
assignment_db
.
assignment_scope_id
)
==
annotated_item
.
assignment
.
assignment_scope_id
\
and
str
(
assignment_db
.
item_id
)
==
annotated_item
.
assignment
.
item_id
\
and
str
(
assignment_db
.
item_id
)
==
annotated_item
.
assignment
.
item_id
\
and
str
(
assignment_db
.
task
_id
)
==
annotated_item
.
assignment
.
task
_id
:
and
str
(
assignment_db
.
annotation_scheme
_id
)
==
annotated_item
.
assignment
.
annotation_scheme
_id
:
annotations
=
annotated_
task
_to_annotations
(
annotated_item
.
task
)
annotations
=
annotated_
scheme
_to_annotations
(
annotated_item
.
scheme
)
status
=
await
upsert_annotations
(
annotations
=
annotations
,
status
=
await
upsert_annotations
(
annotations
=
annotations
,
assignment_id
=
annotated_item
.
assignment
.
assignment_id
,
assignment_id
=
annotated_item
.
assignment
.
assignment_id
,
engine
=
db_engine
)
engine
=
db_engine
)
...
@@ -244,7 +244,7 @@ async def get_items_with_count(permissions=Depends(UserPermissionChecker('datase
...
@@ -244,7 +244,7 @@ async def get_items_with_count(permissions=Depends(UserPermissionChecker('datase
class
MakeAssignmentsRequestModel
(
BaseModel
):
class
MakeAssignmentsRequestModel
(
BaseModel
):
task
_id
:
str
annotation_scheme
_id
:
str
scope_id
:
str
scope_id
:
str
config
:
AssignmentScopeConfig
config
:
AssignmentScopeConfig
save
:
bool
=
False
save
:
bool
=
False
...
@@ -257,7 +257,7 @@ async def make_assignments(payload: MakeAssignmentsRequestModel,
...
@@ -257,7 +257,7 @@ async def make_assignments(payload: MakeAssignmentsRequestModel,
print
(
payload
.
config
)
print
(
payload
.
config
)
try
:
try
:
assignments
=
await
random_assignments
(
assignment_scope_id
=
payload
.
scope_id
,
assignments
=
await
random_assignments
(
assignment_scope_id
=
payload
.
scope_id
,
annotation_
task
_id
=
payload
.
task
_id
,
annotation_
scheme
_id
=
payload
.
annotation_scheme
_id
,
project_id
=
permissions
.
permissions
.
project_id
,
project_id
=
permissions
.
permissions
.
project_id
,
config
=
payload
.
config
,
config
=
payload
.
config
,
engine
=
db_engine
)
engine
=
db_engine
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment