Skip to content

AnnoFab v0.62.0対応 #60

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

Merged
merged 6 commits into from
Sep 20, 2019
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
2 changes: 1 addition & 1 deletion annofabapi/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.16.0'
__version__ = '0.17.0'
25 changes: 25 additions & 0 deletions annofabapi/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,3 +321,28 @@ def delete_labor_control(self, data_id: str) -> Tuple[Any, requests.Response]:
http_method = 'DELETE'
keyword_params: Dict[str, Any] = {}
return self._request_wrapper(http_method, url_path, **keyword_params)

def _get_annotations_for_annotation_editor(self, project_id: str, task_id: str,
input_data_id: str) -> Tuple[Any, requests.Response]:
"""【エディタ用】タスク/入力データのアノテーション一括取得

このAPIが返すアノテーションは、エディタ用です。 機械学習などで利用する成果物としてのアノテーションを取得するには、以下をご利用いただけます。
* getAnnotation: 特定のタスク - 入力データのアノテーション取得
* getAnnotationArchive: プロジェクト全体のアノテーション(ZIP)

Notes:
非公開のAPIのため、メソッド仕様が変わる可能性があります。

Args:
project_id:
task_id:
input_data_id:

Returns:
Tuple[Annotation, requests.Response]

"""
url_path = f'/projects/{project_id}/tasks/{task_id}/inputs/{input_data_id}/annotation'
http_method = 'GET'
keyword_params: Dict[str, Any] = {}
return self._request_wrapper(http_method, url_path, **keyword_params)
3 changes: 3 additions & 0 deletions annofabapi/dataclass/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ class SimpleAnnotation:

details: Optional[List[SimpleAnnotationDetail]]
""""""

updated_datetime: Optional[str]
""""""
@dataclass_json
@dataclass
class SingleAnnotationDetail:
Expand Down
2 changes: 1 addition & 1 deletion annofabapi/generated_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ def get_annotation_list(
page (int): 検索結果のうち、取得したいページの番号(1始まり)
limit (int): 1ページあたりの取得するデータ件数
aggregate_by_task_and_input (bool): trueを指定した場合に「タスクIDと入力IDの組」ごとに検索結果を集計するようにする。
query (AnnotationQuery): 絞り込み条件。[AnnotationQuery](#/components/schemas/AnnotationQuery)** をURIエンコードしたもの
query (AnnotationQuery): 絞り込み条件をJSON形式で表したもの
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のいずれかです。降順指定時は先頭に-(ハイフン)を付与します。 複数指定時は,(カンマ)区切りで列挙します。複数キーを列挙した場合は、先頭から優先順位を割り振られます。

Returns:
Expand Down
2 changes: 2 additions & 0 deletions annofabapi/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2643,6 +2643,8 @@ class ProjectStatus(Enum):

* details: List[SimpleAnnotationDetail]

* updated_datetime: str


"""

Expand Down
4 changes: 2 additions & 2 deletions annofabapi/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import annofabapi.utils
from annofabapi import AnnofabApi
from annofabapi.exceptions import AnnofabApiException
from annofabapi.models import (AnnotationSpecs, InputData, Inspection, JobInfo, MyOrganization, OrganizationMember,
Project, ProjectMember, SupplementaryData, Task, JobType)
from annofabapi.models import (AnnotationSpecs, InputData, Inspection, JobInfo, JobType, MyOrganization,
OrganizationMember, Project, ProjectMember, SupplementaryData, Task)

logger = logging.getLogger(__name__)

Expand Down
5 changes: 4 additions & 1 deletion generate/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ FLAG_DOWNLOAD=false
FLAG_DOCKER_PULL=false

if [ $# -gt 0 ]; then
case ${1} in
for OPT in "$@"
do
case ${OPT} in
--download)
FLAG_DOWNLOAD=true
;;
Expand All @@ -24,6 +26,7 @@ if [ $# -gt 0 ]; then
usage_exit
;;
esac
done
fi

# このスクリプトの存在するディレクトリに移動する
Expand Down
3 changes: 3 additions & 0 deletions generate/swagger/swagger-api-components.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2457,6 +2457,9 @@
type: array
items:
$ref: "#/components/schemas/SimpleAnnotationDetail"
updated_datetime:
type: string
format: date-time
BatchAnnotation:
type: object
properties:
Expand Down
5 changes: 4 additions & 1 deletion generate/swagger/swagger.v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ info:
検査ID | プロジェクト内で一意
WebhookID | プロジェクト内で一意

version: 0.61.2
version: 0.62.0
title: AnnoFab Web API
x-logo:
url: "https://annofab.com/images/logo_landscape.png"
Expand Down Expand Up @@ -3016,6 +3016,9 @@ components:
type: array
items:
$ref: "#/components/schemas/SimpleAnnotationDetail"
updated_datetime:
type: string
format: date-time
BatchAnnotation:
type: object
properties:
Expand Down
8 changes: 6 additions & 2 deletions generate/swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ info:
検査ID | プロジェクト内で一意
WebhookID | プロジェクト内で一意

version: 0.61.2
version: 0.62.0
title: AnnoFab Web API
x-logo:
url: "https://annofab.com/images/logo_landscape.png"
Expand Down Expand Up @@ -3141,8 +3141,9 @@ paths:
- name: query
in: query
description: |
絞り込み条件。[AnnotationQuery](#/components/schemas/AnnotationQuery)** をURIエンコードしたもの
絞り込み条件をJSON形式で表したもの
required: false
example: {"label_id":"b048c6b3-b36f-4c8d-97ea-96828a50a44c"}
schema:
$ref: "#/components/schemas/AnnotationQuery"
- name: sort
Expand Down Expand Up @@ -6899,6 +6900,9 @@ components:
type: array
items:
$ref: "#/components/schemas/SimpleAnnotationDetail"
updated_datetime:
type: string
format: date-time
BatchAnnotation:
type: object
properties:
Expand Down
3 changes: 2 additions & 1 deletion tests/data/dataclass/simple-annotation.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,5 +138,6 @@
"weather": "sunny"
}
}
]
],
"updated_datetime": "2019-08-22T12:02:40.392+09:00"
}
Binary file modified tests/data/simple-annotation.zip
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -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"}}]}
{"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 number Diff line number Diff line change
@@ -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"}}]}
{"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"}
5 changes: 1 addition & 4 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@

import annofabapi
import annofabapi.utils
from tests.utils_for_test import WrapperForTest, create_csv_for_task, set_logging_from_inifile

from annofabapi.models import JobType


from tests.utils_for_test import WrapperForTest, create_csv_for_task, set_logging_from_inifile

# プロジェクトトップに移動する
os.chdir(os.path.dirname(os.path.abspath(__file__)) + "/../")
Expand Down
12 changes: 6 additions & 6 deletions tests/test_local_dataclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,42 +140,42 @@ def test_project_member(self):

class TestStatistics:
def test_statistics_get_task_statistics(self):
statistics_json = test_dir / "task_statistics.json"
statistics_json = test_dir / "task-statistics.json"
with statistics_json.open(encoding="utf-8") as f:
dict_stat = json.load(f)
stat = ProjectTaskStatisticsHistory.from_dict(dict_stat)
assert type(stat) == ProjectTaskStatisticsHistory

def test_statistics_get_account_statistics(self):
statistics_json = test_dir / "account_statistics.json"
statistics_json = test_dir / "account-statistics.json"
with statistics_json.open(encoding="utf-8") as f:
dict_stat = json.load(f)
stat = ProjectAccountStatistics.from_dict(dict_stat)
assert type(stat) == ProjectAccountStatistics

def test_statistics_get_inspection_statistics(self):
statistics_json = test_dir / "inspection_statistics.json"
statistics_json = test_dir / "inspection-statistics.json"
with statistics_json.open(encoding="utf-8") as f:
dict_stat = json.load(f)
stat = InspectionStatistics.from_dict(dict_stat)
assert type(stat) == InspectionStatistics

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

def test_statistics_get_label_statistics(self):
statistics_json = test_dir / "label_statistics.json"
statistics_json = test_dir / "label-statistics.json"
with statistics_json.open(encoding="utf-8") as f:
dict_stat = json.load(f)
stat = LabelStatistics.from_dict(dict_stat)
assert type(stat) == LabelStatistics

def test_statistics_get_worktime_statistics(self):
statistics_json = test_dir / "worktime_statistics.json"
statistics_json = test_dir / "worktime-statistics.json"
with statistics_json.open(encoding="utf-8") as f:
dict_stat = json.load(f)
stat = WorktimeStatistics.from_dict(dict_stat)
Expand Down