Skip to content

Commit 90cf89d

Browse files
authored
Merge pull request #60 from kurusugawa-computer/feature/v0.17.0
AnnoFab v0.62.0対応
2 parents a4addf7 + 6970498 commit 90cf89d

22 files changed

+62
-21
lines changed

annofabapi/__version__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.16.0'
1+
__version__ = '0.17.0'

annofabapi/api.py

+25
Original file line numberDiff line numberDiff line change
@@ -321,3 +321,28 @@ def delete_labor_control(self, data_id: str) -> Tuple[Any, requests.Response]:
321321
http_method = 'DELETE'
322322
keyword_params: Dict[str, Any] = {}
323323
return self._request_wrapper(http_method, url_path, **keyword_params)
324+
325+
def _get_annotations_for_annotation_editor(self, project_id: str, task_id: str,
326+
input_data_id: str) -> Tuple[Any, requests.Response]:
327+
"""【エディタ用】タスク/入力データのアノテーション一括取得
328+
329+
このAPIが返すアノテーションは、エディタ用です。 機械学習などで利用する成果物としてのアノテーションを取得するには、以下をご利用いただけます。
330+
* getAnnotation: 特定のタスク - 入力データのアノテーション取得
331+
* getAnnotationArchive: プロジェクト全体のアノテーション(ZIP)
332+
333+
Notes:
334+
非公開のAPIのため、メソッド仕様が変わる可能性があります。
335+
336+
Args:
337+
project_id:
338+
task_id:
339+
input_data_id:
340+
341+
Returns:
342+
Tuple[Annotation, requests.Response]
343+
344+
"""
345+
url_path = f'/projects/{project_id}/tasks/{task_id}/inputs/{input_data_id}/annotation'
346+
http_method = 'GET'
347+
keyword_params: Dict[str, Any] = {}
348+
return self._request_wrapper(http_method, url_path, **keyword_params)

annofabapi/dataclass/annotation.py

+3
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,9 @@ class SimpleAnnotation:
191191

192192
details: Optional[List[SimpleAnnotationDetail]]
193193
""""""
194+
195+
updated_datetime: Optional[str]
196+
""""""
194197
@dataclass_json
195198
@dataclass
196199
class SingleAnnotationDetail:

annofabapi/generated_api.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ def get_annotation_list(
382382
page (int): 検索結果のうち、取得したいページの番号(1始まり)
383383
limit (int): 1ページあたりの取得するデータ件数
384384
aggregate_by_task_and_input (bool): trueを指定した場合に「タスクIDと入力IDの組」ごとに検索結果を集計するようにする。
385-
query (AnnotationQuery): 絞り込み条件。[AnnotationQuery](#/components/schemas/AnnotationQuery)** をURIエンコードしたもの
385+
query (AnnotationQuery): 絞り込み条件をJSON形式で表したもの
386386
sort (str): ソート順の指定。 使用可能キーはtask_id, input_data_id, detail.annotation_id, detail.account_id, detail.label_id, detail.data_holding_type, detail.created_datetime, detail.updated_datetimeのいずれかです。降順指定時は先頭に-(ハイフン)を付与します。 複数指定時は,(カンマ)区切りで列挙します。複数キーを列挙した場合は、先頭から優先順位を割り振られます。
387387
388388
Returns:

annofabapi/models.py

+2
Original file line numberDiff line numberDiff line change
@@ -2643,6 +2643,8 @@ class ProjectStatus(Enum):
26432643
26442644
* details: List[SimpleAnnotationDetail]
26452645
2646+
* updated_datetime: str
2647+
26462648
26472649
"""
26482650

annofabapi/wrapper.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
import annofabapi.utils
1212
from annofabapi import AnnofabApi
1313
from annofabapi.exceptions import AnnofabApiException
14-
from annofabapi.models import (AnnotationSpecs, InputData, Inspection, JobInfo, MyOrganization, OrganizationMember,
15-
Project, ProjectMember, SupplementaryData, Task, JobType)
14+
from annofabapi.models import (AnnotationSpecs, InputData, Inspection, JobInfo, JobType, MyOrganization,
15+
OrganizationMember, Project, ProjectMember, SupplementaryData, Task)
1616

1717
logger = logging.getLogger(__name__)
1818

generate/generate.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ FLAG_DOWNLOAD=false
99
FLAG_DOCKER_PULL=false
1010

1111
if [ $# -gt 0 ]; then
12-
case ${1} in
12+
for OPT in "$@"
13+
do
14+
case ${OPT} in
1315
--download)
1416
FLAG_DOWNLOAD=true
1517
;;
@@ -24,6 +26,7 @@ if [ $# -gt 0 ]; then
2426
usage_exit
2527
;;
2628
esac
29+
done
2730
fi
2831

2932
# このスクリプトの存在するディレクトリに移動する

generate/swagger/swagger-api-components.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -2457,6 +2457,9 @@
24572457
type: array
24582458
items:
24592459
$ref: "#/components/schemas/SimpleAnnotationDetail"
2460+
updated_datetime:
2461+
type: string
2462+
format: date-time
24602463
BatchAnnotation:
24612464
type: object
24622465
properties:

generate/swagger/swagger.v2.yaml

+4-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ info:
7575
検査ID | プロジェクト内で一意
7676
WebhookID | プロジェクト内で一意
7777
78-
version: 0.61.2
78+
version: 0.62.0
7979
title: AnnoFab Web API
8080
x-logo:
8181
url: "https://annofab.com/images/logo_landscape.png"
@@ -3016,6 +3016,9 @@ components:
30163016
type: array
30173017
items:
30183018
$ref: "#/components/schemas/SimpleAnnotationDetail"
3019+
updated_datetime:
3020+
type: string
3021+
format: date-time
30193022
BatchAnnotation:
30203023
type: object
30213024
properties:

generate/swagger/swagger.yaml

+6-2
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ info:
7575
検査ID | プロジェクト内で一意
7676
WebhookID | プロジェクト内で一意
7777
78-
version: 0.61.2
78+
version: 0.62.0
7979
title: AnnoFab Web API
8080
x-logo:
8181
url: "https://annofab.com/images/logo_landscape.png"
@@ -3141,8 +3141,9 @@ paths:
31413141
- name: query
31423142
in: query
31433143
description: |
3144-
絞り込み条件。[AnnotationQuery](#/components/schemas/AnnotationQuery)** をURIエンコードしたもの
3144+
絞り込み条件をJSON形式で表したもの
31453145
required: false
3146+
example: {"label_id":"b048c6b3-b36f-4c8d-97ea-96828a50a44c"}
31463147
schema:
31473148
$ref: "#/components/schemas/AnnotationQuery"
31483149
- name: sort
@@ -6899,6 +6900,9 @@ components:
68996900
type: array
69006901
items:
69016902
$ref: "#/components/schemas/SimpleAnnotationDetail"
6903+
updated_datetime:
6904+
type: string
6905+
format: date-time
69026906
BatchAnnotation:
69036907
type: object
69046908
properties:

tests/data/dataclass/simple-annotation.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -138,5 +138,6 @@
138138
"weather": "sunny"
139139
}
140140
}
141-
]
141+
],
142+
"updated_datetime": "2019-08-22T12:02:40.392+09:00"
142143
}

tests/data/simple-annotation.zip

29 Bytes
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"project_id":"1186bb00-16e6-4d20-8e24-310322911850","annotation_format_version":"1.1.0","task_id":"sample_0","task_phase":"acceptance","task_phase_stage":1,"task_status":"not_started","input_data_id":"a3281975-e632-47a7-a71f-08013fad5604","input_data_name":"./tests/data/lenna.png","details":[{"label":"climatic","annotation_id":"5ac0d7d5-6738-4c4b-a69a-cd583ff458e1","data":null,"attributes":{"temparature":"20","weather":"sunny"}}]}
1+
{"project_id":"1186bb00-16e6-4d20-8e24-310322911850","annotation_format_version":"1.2.0","task_id":"sample_0","task_phase":"acceptance","task_phase_stage":1,"task_status":"not_started","input_data_id":"0733d1e1-ef85-455e-aec0-ff05c499b711","input_data_name":"./tests/data/lenna.png","details":[{"label":"climatic","annotation_id":"5ac0d7d5-6738-4c4b-a69a-cd583ff458e1","data":null,"attributes":{"temparature":"20","weather":"sunny"}}],"updated_datetime":"2019-08-22T12:36:10.25+09:00"}
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"project_id":"1186bb00-16e6-4d20-8e24-310322911850","annotation_format_version":"1.1.0","task_id":"sample_1","task_phase":"acceptance","task_phase_stage":1,"task_status":"complete","input_data_id":"c86205d1-bdd4-4110-ae46-194e661d622b","input_data_name":"./tests/data/lenna.png","details":[{"label":"bird","annotation_id":"02a9eab8-264b-4b92-b3b7-6e6c377a10ee","data":{"points":[{"x":55,"y":18},{"x":58,"y":27},{"x":57,"y":33},{"x":57,"y":35},{"x":53,"y":60},{"x":50,"y":60},{"x":40,"y":61},{"x":38,"y":34},{"x":47,"y":33},{"x":39,"y":30}],"_type":"Points"},"attributes":{}},{"label":"human","annotation_id":"e2a1fbe3-fa8e-413c-be31-882f12ef62b9","data":{"data_uri":"e2a1fbe3-fa8e-413c-be31-882f12ef62b9","_type":"SegmentationV2"},"attributes":{}},{"label":"eye","annotation_id":"2280a89f-986c-4184-82df-feaec37a9149","data":{"point":{"x":25,"y":18},"_type":"SinglePoint"},"attributes":{}},{"label":"Cat","annotation_id":"226b49a4-c8ef-4016-9e90-99107d8a623b","data":{"left_top":{"x":10,"y":7},"right_bottom":{"x":36,"y":36},"_type":"BoundingBox"},"attributes":{"weight":3,"name":"lena","link-eye":"2280a89f-986c-4184-82df-feaec37a9149","occluded":true,"object id":"6602c86c-5e22-42b9-b5a4-8a77c7bade01","memo":"テスト"}},{"label":"leg","annotation_id":"60a18a10-5d8a-4c1a-90b3-aa67226249c6","data":{"points":[{"x":22,"y":29},{"x":33,"y":41}],"_type":"Points"},"attributes":{}},{"label":"dog","annotation_id":"ee83756f-074d-4aab-8bfc-6ab6e754c2b8","data":{"data_uri":"ee83756f-074d-4aab-8bfc-6ab6e754c2b8","_type":"Segmentation"},"attributes":{}},{"label":"climatic","annotation_id":"5ac0d7d5-6738-4c4b-a69a-cd583ff458e1","data":null,"attributes":{"temparature":"20","weather":"sunny"}}]}
1+
{"project_id":"1186bb00-16e6-4d20-8e24-310322911850","annotation_format_version":"1.2.0","task_id":"sample_1","task_phase":"acceptance","task_phase_stage":1,"task_status":"complete","input_data_id":"c6e1c2ec-6c7c-41c6-9639-4244c2ed2839","input_data_name":"./tests/data/lenna.png","details":[{"label":"bird","annotation_id":"9a15fac0-736f-454f-a50d-7da094bc133d","data":{"points":[{"x":15,"y":55},{"x":12,"y":49},{"x":9,"y":43},{"x":16,"y":36},{"x":21,"y":39},{"x":24,"y":53}],"_type":"Points"},"attributes":{}},{"label":"human","annotation_id":"762f113a-5e17-4b49-861e-dfbea1dda09d","data":{"data_uri":"762f113a-5e17-4b49-861e-dfbea1dda09d","_type":"SegmentationV2"},"attributes":{}},{"label":"dog","annotation_id":"1e2931d2-de34-4956-ab75-81f710dc0108","data":{"data_uri":"1e2931d2-de34-4956-ab75-81f710dc0108","_type":"Segmentation"},"attributes":{}},{"label":"eye","annotation_id":"a05019fd-6e23-456b-9971-641a45979d98","data":{"point":{"x":25,"y":18},"_type":"SinglePoint"},"attributes":{}},{"label":"leg","annotation_id":"c9c688d1-6c05-4118-94c7-308185cdb60a","data":{"points":[{"x":22,"y":29},{"x":33,"y":41}],"_type":"Points"},"attributes":{}},{"label":"Cat","annotation_id":"6602c86c-5e22-42b9-b5a4-8a77c7bade01","data":{"left_top":{"x":10,"y":7},"right_bottom":{"x":36,"y":36},"_type":"BoundingBox"},"attributes":{"weight":3,"name":"lena","link-eye":"a05019fd-6e23-456b-9971-641a45979d98","occluded":true,"object id":"6602c86c-5e22-42b9-b5a4-8a77c7bade01","memo":"テスト"}},{"label":"climatic","annotation_id":"5ac0d7d5-6738-4c4b-a69a-cd583ff458e1","data":null,"attributes":{"temparature":"20","weather":"sunny"}}],"updated_datetime":"2019-08-22T14:10:14.758+09:00"}

tests/test_api.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,8 @@
1515

1616
import annofabapi
1717
import annofabapi.utils
18-
from tests.utils_for_test import WrapperForTest, create_csv_for_task, set_logging_from_inifile
19-
2018
from annofabapi.models import JobType
21-
22-
19+
from tests.utils_for_test import WrapperForTest, create_csv_for_task, set_logging_from_inifile
2320

2421
# プロジェクトトップに移動する
2522
os.chdir(os.path.dirname(os.path.abspath(__file__)) + "/../")

tests/test_local_dataclass.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -140,42 +140,42 @@ def test_project_member(self):
140140

141141
class TestStatistics:
142142
def test_statistics_get_task_statistics(self):
143-
statistics_json = test_dir / "task_statistics.json"
143+
statistics_json = test_dir / "task-statistics.json"
144144
with statistics_json.open(encoding="utf-8") as f:
145145
dict_stat = json.load(f)
146146
stat = ProjectTaskStatisticsHistory.from_dict(dict_stat)
147147
assert type(stat) == ProjectTaskStatisticsHistory
148148

149149
def test_statistics_get_account_statistics(self):
150-
statistics_json = test_dir / "account_statistics.json"
150+
statistics_json = test_dir / "account-statistics.json"
151151
with statistics_json.open(encoding="utf-8") as f:
152152
dict_stat = json.load(f)
153153
stat = ProjectAccountStatistics.from_dict(dict_stat)
154154
assert type(stat) == ProjectAccountStatistics
155155

156156
def test_statistics_get_inspection_statistics(self):
157-
statistics_json = test_dir / "inspection_statistics.json"
157+
statistics_json = test_dir / "inspection-statistics.json"
158158
with statistics_json.open(encoding="utf-8") as f:
159159
dict_stat = json.load(f)
160160
stat = InspectionStatistics.from_dict(dict_stat)
161161
assert type(stat) == InspectionStatistics
162162

163163
def test_statistics_get_task_phase_statistics(self):
164-
statistics_json = test_dir / "task_phase_statistics.json"
164+
statistics_json = test_dir / "task-phase-statistics.json"
165165
with statistics_json.open(encoding="utf-8") as f:
166166
dict_stat = json.load(f)
167167
stat = TaskPhaseStatistics.from_dict(dict_stat)
168168
assert type(stat) == TaskPhaseStatistics
169169

170170
def test_statistics_get_label_statistics(self):
171-
statistics_json = test_dir / "label_statistics.json"
171+
statistics_json = test_dir / "label-statistics.json"
172172
with statistics_json.open(encoding="utf-8") as f:
173173
dict_stat = json.load(f)
174174
stat = LabelStatistics.from_dict(dict_stat)
175175
assert type(stat) == LabelStatistics
176176

177177
def test_statistics_get_worktime_statistics(self):
178-
statistics_json = test_dir / "worktime_statistics.json"
178+
statistics_json = test_dir / "worktime-statistics.json"
179179
with statistics_json.open(encoding="utf-8") as f:
180180
dict_stat = json.load(f)
181181
stat = WorktimeStatistics.from_dict(dict_stat)

0 commit comments

Comments
 (0)