Bin
2025-12-17 05a69820e0c402b0b33c063d3b922f0a0571cbbb
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
---
test_name: change_model_version_and_get_next_task
strict: false
marks:
- usefixtures:
  - django_live_url
stages:
- id: signup
  type: ref
- id: create_project
  type: ref
 
- name: create_task_with_2_predictions
  request:
    files:
      json_file: tests/test_suites/samples/text_with_2_predictions.json
    headers:
      content-type: multipart/form-data
    method: POST
    url: '{django_live_url}/api/projects/{project_pk}/import'
  response:
    json:
      annotation_count: 0
      prediction_count: 2
      task_count: 1
    status_code: 201
 
- name: get_available_model_versions
  request:
    method: GET
    url: '{django_live_url}/api/projects/{project_pk}/model-versions'
  response:
    json:
      model_version_B: 1
      model_version_A: 1
 
- name: get_next_task
  request:
    method: GET
    url: '{django_live_url}/api/projects/{project_pk}/next'
  response:
    json:
      data:
        text: Test example phrase
      predictions:  # last taken model version is activated
        - result:
          - from_name: label
            to_name: text
            type: choices
            value:
              choices:
                - neg
          model_version: model_version_B
 
- name: change_project_model_version
  request:
    method: PATCH
    url: '{django_live_url}/api/projects/{project_pk}'
    headers:
      content-type: application/json
    json:
      model_version: model_version_A
 
- name: get_next_task
  request:
    method: GET
    url: '{django_live_url}/api/projects/{project_pk}/next'
  response:
    json:
      data:
        text: Test example phrase
      is_labeled: false
      predictions:
        - result:
          - from_name: label
            to_name: text
            type: choices
            value:
              choices:
                - pos
          model_version: model_version_A
 
- name: change_project_model_version
  request:
    method: PATCH
    url: '{django_live_url}/api/projects/{project_pk}'
    headers:
      content-type: application/json
    json:
      model_version: null
 
- name: get_next_task
  request:
    method: GET
    url: '{django_live_url}/api/projects/{project_pk}/next'
  response:
    json:
      data:
        text: Test example phrase
 
 
---
test_name: check_task_lock_with_data_manager_queue
# task lock shouldn't affect the sequence any way
strict: false
marks:
- usefixtures:
  - django_live_url
stages:
- id: signup
  type: ref
- id: create_project
  type: ref
 
- name: create_2_tasks
  request:
    files:
      json_file: tests/test_suites/samples/text_with_2_tasks.json
    headers:
      content-type: multipart/form-data
    method: POST
    url: '{django_live_url}/api/projects/{project_pk}/import'
  response:
    json:
      annotation_count: 0
      prediction_count: 0
      task_count: 2
    status_code: 201
 
# 1st next task api with filter/ordering payload works as data manager queue mode
- name: get_next_task
  request:
    method: POST
    url: '{django_live_url}/api/dm/actions?project={project_pk}&id=next_task'
    json:
      ordering:
        - -tasks:id
      selectedItems:
        all: true
        excluded: []
      filters:
        conjunction: and
        items: []
  response:
    json:
      data:
        text: Example 2
 
# 2nd api call must return the same task in data manager queue mode
- name: get_next_task
  request:
    method: POST
    url: '{django_live_url}/api/dm/actions?project={project_pk}&id=next_task'
    json:
      ordering:
        - -tasks:id
      selectedItems:
        all: true
        excluded: []
      filters:
        conjunction: and
        items: []
  response:
    json:
      data:
        text: Example 2
 
# 3rd - user direct ordering
- name: get_next_task
  request:
    method: POST
    url: '{django_live_url}/api/dm/actions?project={project_pk}&id=next_task'
    json:
      ordering:
        - tasks:id
      selectedItems:
        all: true
        excluded: []
      filters:
        conjunction: and
        items: []
  response:
    json:
      data:
        text: Example 1
 
# 4th - disable data manager queue, use label stream as is
- name: get_next_task
  request:
    method: POST
    url: '{django_live_url}/api/dm/actions?project={project_pk}&id=next_task'
  response:
    status_code: 200
    save:
      json:
        task_id: id
 
# 5th - label stream again must return previously locked task
- name: get_next_task
  request:
    method: POST
    url: '{django_live_url}/api/dm/actions?project={project_pk}&id=next_task'
  response:
    status_code: 200
    json:
      id: !int "{task_id}"