This repository was archived by the owner on Aug 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpecification.yaml
More file actions
1438 lines (1330 loc) · 40.6 KB
/
Specification.yaml
File metadata and controls
1438 lines (1330 loc) · 40.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
openapi: 3.0.0
info:
title: Annotatron
description: >-
Annotatron describes, displays, processes, visualizes, and allows humans to annotate machine learning corpora.
## Definitions
These terms have special meaning for Annotatron:
_Application-global ID_:
> Any user can access a resource using this identifier and get the same ID. This ID is used for most system objects used by _Staff_ and _Administrator_ users.
_User-specific ID_:
> Only the user who received the identifier can retrieve the resource. This is used for objects accessed by _Annotator_ and _Reviewer_ useres. You can translate these to an _Application-global ID_ using the `/auth/id` end-point.
version: 0.1.0
servers:
- url: http://api.example.com/v1
description: Optional server description, e.g. Main (production) server
- url: http://staging-api.example.com
description: Optional server description, e.g. Internal staging server for testing
tags:
- name: annotation
description: >-
Annotations are what we're trying to derive from Annotatron.
- name: asset
description: >-
`Asset`s are indivisable, immutable pieces of content which you can annotate as part of a corpus.
Each `Asset` can be part of more than one corpus, for example a database of photos can be annotated
with age in one `Corpus`, and expression in another.
- name: assignment
description: >-
`Assignments` are `Question`s about `Asset`s delivered to humans, and approved by `Reviewer`.
- name: auth
description: >-
This tag collects API methods which are used for authentication, authorization, and anything to do with logging in, logging out, general security stuff.
- name: conf
description: >-
This tag collects endpoints which are used to control the system.
- name: corpus
description: >-
`Asset`s are stored in `Corpus` collections, which are used to organize datasets for annotation and training.
Corpora collect and organize Assets to create a dataset used for annotation and training.
- name: question
description: >-
`Question`s in Annotatron are prompts given to a human. Humans give the response, and it's recorded for later aggreation. Typically,
multiple Annotators will respond and the resulting Annotation will be summarized for export.
- name: needsImplementation
description: >-
These are endpoints which are defined, but not implemented.
- name: needsTesting
description: >-
These are endpoints which need test coverage
paths:
/conf/initialUser:
get:
tags:
- conf
- auth
description: >-
Checks whether this Annotatron instances requires initial set-up or not. Returns false if everything's normal. No Authorization is needed.
operationId: checkNeedsSetup
responses:
200:
description: Successful
content:
application/json:
schema:
$ref: "#/components/schemas/ConfigurationResponse"
402:
description: Internal error
post:
operationId: createInitialUser
tags:
- conf
- auth
description: >-
Creates the initial, primary user that will administer the system.
* The `role` field will be automatically set to `Administrator`.
No authorization key is needed.
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/NewUserRequest'
responses:
200:
description: "Successful."
content:
application/json:
schema:
$ref: '#/components/schemas/LoginResponse'
/auth/token:
delete:
operationId: deleteAuthToken
tags:
- auth
- needsTesting
description: >-
Signs the current user out.
responses:
202:
description: "Deleted"
post:
operationId: createAuthToken
tags:
- auth
description: >-
Logs the active `User` in (if possible), and returns an authentication token.
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/LoginRequest'
responses:
200:
description: "Successful."
content:
application/json:
schema:
$ref: '#/components/schemas/LoginResponse'
403:
description: "Login unsuccessful."
/auth/whoAmI:
get:
tags:
- auth
operationId: getWhoIAm
description: >-
Redirects to a resource that describes the currently signed in user.
Returns an object with the currently-signed in User details.
responses:
302:
description: "Successful."
content:
application/json:
schema:
$ref: '#/components/schemas/User'
202:
description: "Not logged in."
/auth/users/{userId}:
get:
tags:
- auth
operationId: getUserDetails
summary: Retrieve information about an Annotatron user.
description: >-
If called by an Administrator or Staff user, returns information about a specified user.
If called by any other user, information about their account will be presented, so long as `userId` matches the current user.
parameters:
- name: userId
in: path
schema:
type: integer
format: int64
required: true
description: >-
Application-global identifier for the user.
responses:
200:
description: "Successful"
content:
application/json:
schema:
$ref: '#/components/schemas/User'
/auth/users/{userId}/password:
put:
tags:
- auth
operationId: changeUserPassword
summary: Change or reset a password on an account
description: >-
* If called by an Administrator, resets the current password on a User's account.
The account holder will be asked to set a new password the next time they log in.
* If called by a user, `oldPassword` must be present and match the existing password
set for the account.
* All current login tokens will be invalidated.
parameters:
- name: userId
in: path
schema:
type: integer
format: int64
required: true
description: >-
Application-global identifier for the current user (if changing their password) or the target user (if an administrator is doing it).
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/PasswordResetRequest'
responses:
202:
description: "Accepted"
403:
description: "Password could not be changed due to mismatch"
/auth/users:
get:
tags:
- auth
operationId: listUsers
description: >-
Retrieves all application-global user identifiers. Can be done by a `Staff` or higher.
responses:
200:
description: "Successful"
content:
application/json:
schema:
type: array
items:
type: integer
format: int64
post:
operationId: createUser
tags:
- conf
- auth
description: >-
Creates a new user. This can only be done by an `Administrator`.
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/NewUserRequest'
responses:
201:
description: "Successful."
/assignments/{corpusName}:
post:
operationId: createAssignment
parameters:
- name: corpusName
in: path
schema:
type: string
required: true
description: >-
Which Corpus we're inserting into.
tags:
- assignment
- needsTesting
description: >-
Adds an `Assignment` to Annotatron, which links a `Question` about an `Asset` in a given `Corpus` to a `User`
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/Assignment'
responses:
201:
description: "Successful"
content:
application/json:
schema:
$ref: '#/components/schemas/SuccessfulInsert'
/assignments/{assignmentId}/{action}:
patch:
tags:
- assignment
- needsImplementation
- needsTesting
operationId: submitAssignment
description: >-
This endpoint mutates an `Assignment`, causing it to change state. This can be to approve, reject, annotate or review it.
When called by the user who's in the `assignedAnnotatorId` field, saves and validates the `response` field and sends it for review.
When called by the user who's in the `assignedReviewerId` field, completes review.
parameters:
- name: assignmentId
in: path
schema:
type: integer
format: int64
required: true
- name: action
in: path
schema:
type: string
enum:
- submit
- approve
- reject
required: true
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/AssignmentResponse'
responses:
202:
description: "Updated successfully"
422:
description: "Validation error"
content:
application/json:
schema:
$ref: '#/components/schemas/ValidationError'
/assignments/{assignmentId}:
get:
operationId: getAssignment
tags:
- assignment
- needsImplementation
- needsTesting
operationId: retrieveAssignmentHistory
description: >-
This endpoint retrieves the history and current state for an Assignment.
parameters:
- name: assignmentId
in: path
schema:
type: integer
format: in64
required: true
responses:
200:
description: "Successful"
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/AssignmentHistory"
/assignments/{assignmentId}:
get:
operationId: getAssignment
tags:
- assignment
- needsImplementation
- needsTesting
description: >-
Retrieve the details of an `Assignment`.
parameters:
- name: assignmentId
in: path
schema:
type: integer
format: int64
required: true
responses:
200:
description: "Successful."
content:
application/json:
schema:
$ref: "#/components/schemas/Assignment"
/assignments/byUser/{userId}:
get:
tags:
- assignment
- needsTesting
operationId: listAssignmentsByUser
description: >-
Retrieve the `Assignments` assigned to a user.
parameters:
- name: userId
in: path
schema:
type: integer
format: int64
required: true
responses:
200:
description: "Available assignments."
content:
application/json:
schema:
$ref: "#/components/schemas/UserAssignments"
/assignments/byCorpus/{corpusId}:
get:
tags:
- assignment
- needsTesting
operationId: listAssignmentsByUser
description: >-
Retrieve the `Assignments` assigned to a user.
parameters:
- name: corpusId
in: path
schema:
type: string
required: true
responses:
200:
description: "Available assignments."
content:
application/json:
schema:
$ref: "#/components/schemas/UserAssignments"
/corpus/{corpusName}/assets/{assetName}:
put:
tags:
- asset
operationId: createAsset
summary: Adds an `Asset` to a `Corpus`
description: >-
Inserts an `Asset` into Annotatron. No de-duplication is provided (use the `HEAD` method to check.) The `id` field is ignored.
parameters:
- in: path
name: corpusName
schema:
type: string
required: true
description: The unique name of the `Corpus` that's being modified.
- in: path
name: assetName
schema:
type: string
required: true
description: The unique name of the `Asset` that's being deleted.
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/BinaryAssetUpload'
responses:
'201':
description: Successfully created
delete:
tags:
- asset
summary: Deletes an `Asset` from a `Corpus`.
operationId: deleteAssetWithId
description: >-
Deletes an asset, if possible, from Annotatron's database.
* The Asset will only be deleted if it's not referenced by any Corpus objects.
* The Asset's metadata and content may persist in storage, but will not be accessible.
parameters:
- in: path
name: corpusName
schema:
type: string
required: true
description: The unique name of the `Corpus` that's being modified.
- in: path
name: assetName
schema:
type: string
required: true
description: The unique name of the `Asset` that's being deleted inside the `Corpus`.
responses:
202:
description: Successfully deleted.
422:
description: Can't delete
content:
application/json:
schema:
$ref: '#/components/schemas/DataLossReason'
get:
tags:
- asset
summary: Retrieve information about an Asset
operationId: getAssetInfoWithId
description: >-
Retrieves some metadata about the Asset, such as when it was uploaded.
parameters:
- in: path
name: corpusName
schema:
type: string
required: true
description: The `id` of the `Corpus` that's being accessed.
- in: path
name: assetName
schema:
type: string
required: true
description: The unique name of the `Asset` inside the `Corpus`.
responses:
200:
description: Asset details successfully retrieved.
content:
application/json:
schema:
$ref: '#/components/schemas/BinaryAssetDescription'
/assets/{assetId}/content:
get:
tags:
- asset
- needsImplementation
operationId: getAssetContentWithId
description: >-
Retrieves the bytes that make up an `Asset`.
parameters:
- in: path
name: assetId
schema:
type: integer
format: int64
required: true
description: The obfuscated id of the `Asset`. Retrieved from `BinaryAssetDescription.id`
responses:
200:
description: Asset content successfully retrieved.
content:
application/octet-stream:
schema:
type: string
format: binary
/corpus/{corpusName}/assets:
get:
tags:
- corpus
- asset
operationId: getAssetsByCorpusId
description: >-
Retrieves the `Asset`s that make up a `Corpus`.
parameters:
- name: corpusName
in: path
required: true
description: The identifier of the `Corpus` to look in.
schema:
type: string
responses:
200:
description: Successful response
content:
application/json:
schema:
$ref: "#/components/schemas/Corpus"
/corpus/{corpusName}/questions:
post:
operationId: createQuestion
tags:
- question
description: >-
Attaches a `Question` object to a an `Asset` in a `Corpus` for human
annotation.
parameters:
- name: corpusName
in: path
required: true
description: The identifier of the `Corpus` containing the `Asset`
schema:
type: string
- name: assetName
in: path
required: true
description: The identifier of the `Asset` to add the `Question` to.
schema:
type: string
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/Question"
responses:
201:
description: "Successfully created."
content:
application/json:
schema:
$ref: "#/components/schemas/SuccessfulInsert"
get:
operationId: getQuestions
tags:
- question
description: >-
This retrieves a list of identifiers which map to `Questions` via the `questions/{id}` endpoint.
parameters:
- name: corpusName
in: path
required: true
description: The identifier of the `Corpus` to link with.
schema:
type: string
responses:
200:
description: A list of application-global question identifiers.
content:
application/json:
schema:
type: integer
format: int64
/corpus/{corpusName}/questions/{questionId}:
get:
operationId: getQuestion
tags:
- question
description: >-
This retrieves the full content of a `Question` associated with a corpus.
parameters:
- name: corpusName
in: path
required: true
description: The identifier of the `Corpus` to link with.
schema:
type: string
- name: questionId
in: path
required: true
description: The application-global identifier of the `Question`.
schema:
type: integer
format: int64
responses:
200:
description: Success
content:
application/json:
schema:
$ref: "#/components/schemas/Question"
delete:
operationId: deleteQuestion
tags:
- question
parameters:
- name: corpusName
in: path
required: true
description: The identifier of the `Corpus` to link with.
schema:
type: string
- name: questionId
in: path
required: true
description: The application-global identifier of the `Question`.
schema:
type: integer
format: int64
responses:
202:
description: "Accepted for deletion"
/corpus/{corpusName}:
get:
tags:
- corpus
operationId: getCorpusById
description: >-
Retrieves details about a Corpus
parameters:
- name: corpusName
in: path
required: true
description: The identifier of the `Corpus` to link with.
schema:
type: string
responses:
200:
description: Successful response
content:
application/json:
schema:
$ref: "#/components/schemas/Corpus"
/corpus:
get:
tags:
- corpus
description: >-
Retrieves a list of identifiers that correspond to current `Corpus` objects.
These can be resolved into Corpus objects later via the `/corpus/{id}` endpoint.
operationId: listAllCorpora
parameters:
- name: name
schema:
type: string
in: query
description: "Partially match corpora which contain this name."
responses:
200:
description: A JSON array of `Corpus` identifiers.
content:
application/json:
schema:
type: array
items:
type: string
post:
tags:
- corpus
operationId: createCorpus
description: >-
Adds a new `Corpus` to the database.
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/Corpus'
responses:
201:
description: "Successfully created"
content:
application/json:
schema:
$ref: "#/components/schemas/SuccessfulInsert"
components:
securitySchemes:
bearerAuth: # arbitrary name for the security scheme
type: http
scheme: bearer
schemas:
AbstractAnnotation:
type: object
required:
- kind
- source
- summaryCode
properties:
created:
type: string
format: datetime
kind:
type: string
enum:
- TimeSeriesSegmentationAnnotation
- TimeSeriesRangeAnnotation
- MultipleChoiceAnnotation
- GenericJSONAnnotation
- TextAnnotation
source:
type: string
enum:
- Reference
- SystemGenerated
- Human
- Aggregated
summaryCode:
type: string
AbstractQuestion:
type: object
required:
- humanPrompt
- kind
- summaryCode
- created
properties:
id:
type: integer
format: int64
description: Ignored on upload.
summaryCode:
type: string
description: >-
This is a short string which is used by Annotatron to group responses for a given Asset, often from different Annotators.
example: TRANSCRIPT
humanPrompt:
type: string
description: >-
This is the text presented to the user, e.g. if this field is set to
> Is this transcription accurate?
Then that is what will be presented to the user
example: "Select all the animals in this picture."
created:
type: string
format: datetime
detailedAnnotationInstructions:
description: >-
Contains detailed annotation instructions, in CommonMark format.
type: string
annotationInstructions:
description: >-
Contains head-line annotation instructions, in CommonMark format.
type: string
kind:
description: >-
This must be set to the type of `Question` that this is.
Valid values are:
* `TimeSeriesSegmentationQuestion`
* `TimeSeriesRangeQuestion`
* `MultipleChoiceQuestion`
type: string
assets:
description: >-
This is a list of user-specific IDs which describe the `Asset`s which are going to be displayed for this question.
type: array
items:
type: integer
format: int64
Annotation:
oneOf:
- $ref: "#/components/schemas/TimeSeriesSegmentationAnnotation"
- $ref: "#/components/schemas/TimeSeriesRangeAnnotation"
- $ref: "#/components/schemas/GenericJSONAnnotation"
- $ref: "#/components/schemas/MultipleChoiceAnnotation"
- $ref: "#/components/schemas/TextAnnotation"
discriminator:
propertyName: kind
required:
- kind
- source
example:
kind: "TimeSeriesSegmentationAnnotation"
source: "Human"
segments:
- 0.1
- 0.3
- 0.7
annotations:
- "click"
- "click"
- "rattle"
AssetCorpusLink:
type: object
required:
- uniqueName
- assetName
- corpusName
description: >-
Represents a link between an `Asset` and a `Corpus`.
`assetName` and `corpusName` are not mandatory on upload.
properties:
uniqueName:
type: string
description: User-provided name that uniquely identifies this Asset in the target corpus.
assetName:
type: integer
format: int64
corpusName:
type: integer
format: int64
AssignmentResponse:
properties:
response:
$ref: "$components/schema/Annotation"
notes:
type: string
AssignmentHistory:
description: >-
This object captures the ongoing work needed to complete an `Assignment`.
The `response` field is required when moving from the `Created` to the `Annotated` state. It can also be given when moving from the `Annotated` state to the `Reviewed` state.
required:
- state
- assignedToUser
- dateEntered
properties:
annotation:
$ref: '#/components/schemas/Annotation'
notes:
type: string
description: "Free-form notes"
state:
description: >
Created implies that the `Assignment` is waiting for `Assignment.annotatorId` to annotate it.
`Annotated` implies that the `Assignment` is waiting for `Assignment.reviewerId` to review it.
`Approved` or `Rejected` implies that the `Assignment` has been sent back to `Assignment.annotatorId` for further changes.
`Superseded` implies that the underlying `Asset`s' content has been updated, meaning that the `Assignment` needs to be re-annotated by `Assignment.annotatorId`.
`Deleted` implies that `currentUser` has removed the `Assignment` and that its results should no longer appear.
type: string
enum:
- Created
- Annotated
- Approved
- Rejected
- Superseded
- Deleted
updatedByUser:
description: >-
Ignored on upload, records the application-global identifier of the user who generated this state change.
type: integer
format: int64
assignedToUser:
description: >-
Records which user should progress this to the next state. If state is `Approved`, this can be blank.
type: integer
format: int64
dateEntered:
description: >-
Ignored on upload, this records the UTC time that this update happened.
type: string
format: datetime
Assignment:
required:
- question
- created
- assets
- assignedAnnotatorId
properties:
assets:
type: array
items:
type: integer
format: int64
description: "The Assets that will be displayed for this Assignment."
annotatorId:
type: integer
format: int64
description: "The user who will complete the question"
question:
$ref: "$/components/schemas/Question"
reviewerId:
type: integer
format: int64
description: >-
Who will review this `Assignment`. If unset, or set to 0,
the assignment will be automatically approved.
created:
type: string
format: datetime
BinaryAssetDescription:
title: BinaryAsset
type: object
description: >-
An `Asset` is an indivisable blob of data that can be annotated.
required:
- copyrightAndUsageRestrictions
- checksum
- mimeType
- typeDescription
- content
- userIdWhoUploaded
- dateUploaded
- id
properties:
id:
type: integer
format: int64
description: Ignored on upload.
userIdWhoUploaded:
type: integer
format: int64
description: Ignored on upload.
default: 0
content:
type: string
description: Base64-encoded byte array that makes up the `Asset`.
metadata:
type: object
description: User-provided metadata to identify this object.
dateUploaded:
type: string
format: dateTime
description: When this asset was uploaded. Ignored on upload.
default: now
copyrightAndUsageRestrictions:
type: string
description: Contains user-provided information about Copyright, source, and redistribution.
checksum:
type: string