annofabapi


Nameannofabapi JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://github.com/kurusugawa-computer/annofab-api-python-client
SummaryPython Clinet Library of Annofab WebAPI (https://annofab.com/docs/api/)
upload_time2024-09-11 14:40:31
maintainerNone
docs_urlNone
authorKurusugawa Computer Inc.
requires_python<4.0,>=3.8
licenseMIT
keywords annofab api
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # annofab-api-python-client
[Annofab Web API](https://annofab.com/docs/api/) のPythonクライアントライブラリです。

[![Build Status](https://app.travis-ci.com/kurusugawa-computer/annofab-api-python-client.svg?branch=main)](https://app.travis-ci.com/kurusugawa-computer/annofab-api-python-client)
[![CodeQL](https://github.com/kurusugawa-computer/annofab-api-python-client/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/kurusugawa-computer/annofab-api-python-client/actions/workflows/codeql-analysis.yml)
[![PyPI version](https://badge.fury.io/py/annofabapi.svg)](https://badge.fury.io/py/annofabapi)
[![Python Versions](https://img.shields.io/pypi/pyversions/annofabapi.svg)](https://pypi.org/project/annofabapi/)
[![Documentation Status](https://readthedocs.org/projects/annofab-api-python-client/badge/?version=latest)](https://annofab-api-python-client.readthedocs.io/en/latest/?badge=latest)




* **Annofab Web API Documentation:** https://annofab.com/docs/api/
* **Reference Documentation:** https://annofab-api-python-client.readthedocs.io/en/latest/
* **annofab-cli** https://github.com/kurusugawa-computer/annofab-cli
    * 「タスクの一括差し戻し」や、「プロジェクト間の差分表示」など、Annofabの画面で実施するには時間がかかる操作を、CLIツールとして提供しています。
* **開発者用ドキュメント**: [README_for_developer.md](https://github.com/kurusugawa-computer/annofab-api-python-client/blob/main/README_for_developer.md)




# 注意
* 作者または著作権者は、ソフトウェアに関してなんら責任を負いません。
* 現在、APIは開発途上版です。予告なく互換性のない変更がある可能性をご了承ください。
* put, post, delete系のメソッドを間違えて実行してしまわないよう、注意してください。特に「プロジェクト削除」や「アノテーション仕様更新」のAPIには十分注意してください。
 
# 廃止予定
現在ありません。


# Features
cURLやPostmanなどよりも簡単にAnnofab Web APIにアクセスできます。

* ログインを意識せずに、APIを利用できます。
* アクセス過多などで失敗した場合は、リトライされます。
* 「画像を入力データとして登録する」機能など、APIを組み合わせた機能も利用できます。



# Requirements
* Python 3.8+ 

# Install

```
$ pip install annofabapi
```

https://pypi.org/project/annofabapi/

# Usage

## インスタンス生成

### user_id, passwordをコンストラクタ引数に渡す場合

```python
# APIアクセス用のインスタンスを生成
from annofabapi import build


user_id = "XXXXXX"
password = "YYYYYY"

service = build(user_id, password)
```

### PersonalAccessTokenをコンストラクタ引数に渡す場合

```python
# APIアクセス用のインスタンスを生成
from annofabapi import build


pat = "XXXXXX"

service = build(pat = pat)
```


### `.netrc`に認証情報を記載する場合
`.netrc`ファイルに、AnnofabのユーザIDとパスワードを記載します。

```plain:.netrc
machine annofab.com
login annofab_user_id
password annofab_password
```

```python
from annofabapi import build_from_netrc
service = build_from_netrc()
```


#### For Linux
* パスは`$HOME/.netrc`
* `$ chmod 600 $HOME/.netrc`でパーミッションを変更する



#### For Windows
* パスは`%USERPROFILE%\.netrc`


### 環境変数に認証情報を設定する場合


* IDとパスワードで認証する場合
    * 環境変数`ANNOFAB_USER_ID`、`ANNOFAB_PASSWORD`にユーザIDとパスワードを設定します。
* パーソナルアクセストークンで認証する場合
    * 環境変数`ANNOFAB_PAT`にトークンを設定します。
    * `ANNOFAB_PAT`が設定されている場合、`ANNOFAB_USER_ID`、`ANNOFAB_PASSWORD`は無視されます。

```python
from annofabapi import build_from_env
service = build_from_env()
```


### `.netrc`または環境変数に認証情報を設定する場合
``build()`` を実行すると、環境変数または `.netrc` ファイルから認証情報を読み込みます。

```python
from annofabapi import build
service = build()
```

優先順位は以下の通りです。
1. 環境変数
    1. `ANNOFAB_PAT`
    2. `ANNOFAB_USER_ID`及び`ANNOFAB_PASSWORD`
2. `.netrc`


## `service.api`のサンプルコード

* `service.api`には、Web APIに対応するメソッドが定義されています。
* メソッド名は、[Annofab Web APIのOpenAPI specification](https://annofab.com/docs/api/swagger.yaml)に記載されている`operationId`を、スネークケースに変換したものです。
* 各メソッドの戻り値の型は`Tupple[Content, Response]`です。
Responseは[requestsモジュールのReponseオブジェクト](https://2.python-requests.org/en/master/api/#requests.Response)です。
ContentはReponseの中身です。

```python
project_id = "ZZZZZZ"
# `status`が`complete`のタスクを取得する
content, response = service.api.get_tasks(project_id, query_params={"status": "complete"})

print(type(content))
# <class 'dict'>
print(content)
# {'list': [{'project_id': 'ZZZZZZ', 'task_id': '20190317_2', 'phase': 'acceptance', ...

print(type(response))
# <class 'requests.models.Response'>
print(response.headers["Content-Type"])
# application/json
```

## `service.wrapper`のサンプルコード

`service.wrapper`には、`server.api`を組み合わせたメソッドが定義されています。


```python
# `status`が`complete`のタスクすべてを取得する
tasks = service.wrapper.get_all_tasks(project_id, query_params={"status": "complete"})
print(type(tasks))
# <class 'list'>
print(tasks)
# [{'project_id': 'ZZZZZZ', 'task_id': '20190317_2', 'phase': 'acceptance', ...


# simpleアノテーションzipのダウンロード
service.wrapper.download_annotation_archive(project_id, 'output_dir')

# 画像ファイルを入力データとして登録する
service.wrapper.put_input_data_from_file(project_id, 'sample_input_data_id', f'sample.png')
```

## アノテーションzipの読み込み
ダウンロードしたアノテーションzipを、JSONファイルごとに読み込みます。
zipファイルを展開したディレクトリも読み込み可能です。

```python
import zipfile
from pathlib import Path
from annofabapi.parser import lazy_parse_simple_annotation_dir, lazy_parse_simple_annotation_zip, SimpleAnnotationZipParser, SimpleAnnotationDirParser, lazy_parse_simple_annotation_zip_by_task


# Simpleアノテーションzipの読み込み
iter_parser = lazy_parse_simple_annotation_zip(Path("simple-annotation.zip"))
for parser in iter_parser:
    simple_annotation = parser.parse()
    print(simple_annotation)

# Simpleアノテーションzipを展開したディレクトリの読み込み
iter_parser = lazy_parse_simple_annotation_dir(Path("simple-annotation-dir"))
for parser in iter_parser:
    simple_annotation = parser.parse()
    print(simple_annotation)

# Simpleアノテーションzipをタスク単位で読み込む
task_iter_parser = lazy_parse_simple_annotation_zip_by_task(Path("simple-annotation.zip"))
for task_parser in task_iter_parser:
    print(task_parser.task_id)
    for parser in task_parser.lazy_parse():
        simple_annotation = parser.parse()
        print(simple_annotation)
        

# Simpleアノテーションzip内の1個のJSONファイルを読み込み
with zipfile.ZipFile('simple-annotation.zip', 'r') as zip_file:
    parser = SimpleAnnotationZipParser(zip_file, "task01/12345678-abcd-1234-abcd-1234abcd5678.json")
    simple_annotation = parser.parse()
    print(simple_annotation)

# Simpleアノテーションzip内を展開したディレクトリ内の1個のJSONファイルを読み込み
parser = SimpleAnnotationDirParser(Path("task01/12345678-abcd-1234-abcd-1234abcd5678.json"))
simple_annotation = parser.parse()
print(simple_annotation)


```

### 塗りつぶし画像の読み込み
`annofabapi.segmentation` には、アノテーションZIPに格納されている塗りつぶし画像を扱うための関数が用意されています。
利用する場合は、以下のコマンドを実行してください。

```
$ pip install annofabapi[segmentation]
```



## DataClass
`annofabapi.dataclass`に、データ構造用のクラスがあります。
これらのクラスを利用すれば、属性で各値にアクセスできます。

```python
from annofabapi.dataclass.task import Task
dict_task, _ = service.api.get_task(project_id, task_id)
task = Task.from_dict(dict_task)

print(task.task_id)
print(task.status)

```




## 備考

### `annofabapi`のログを出力する方法(サンプル)

```python
import logging
logging_formatter = '%(levelname)-8s : %(asctime)s : %(name)s : %(message)s'
logging.basicConfig(format=logging_formatter)
logging.getLogger("annofabapi").setLevel(level=logging.DEBUG)
```


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/kurusugawa-computer/annofab-api-python-client",
    "name": "annofabapi",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.8",
    "maintainer_email": null,
    "keywords": "annofab, api",
    "author": "Kurusugawa Computer Inc.",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/4c/29/be3ceab00e7df6d471ec1e6a3470b6a6bcc0f3084dcd167d4236bbdb25d1/annofabapi-1.0.0.tar.gz",
    "platform": null,
    "description": "# annofab-api-python-client\n[Annofab Web API](https://annofab.com/docs/api/) \u306ePython\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u3059\u3002\n\n[![Build Status](https://app.travis-ci.com/kurusugawa-computer/annofab-api-python-client.svg?branch=main)](https://app.travis-ci.com/kurusugawa-computer/annofab-api-python-client)\n[![CodeQL](https://github.com/kurusugawa-computer/annofab-api-python-client/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/kurusugawa-computer/annofab-api-python-client/actions/workflows/codeql-analysis.yml)\n[![PyPI version](https://badge.fury.io/py/annofabapi.svg)](https://badge.fury.io/py/annofabapi)\n[![Python Versions](https://img.shields.io/pypi/pyversions/annofabapi.svg)](https://pypi.org/project/annofabapi/)\n[![Documentation Status](https://readthedocs.org/projects/annofab-api-python-client/badge/?version=latest)](https://annofab-api-python-client.readthedocs.io/en/latest/?badge=latest)\n\n\n\n\n* **Annofab Web API Documentation:** https://annofab.com/docs/api/\n* **Reference Documentation:** https://annofab-api-python-client.readthedocs.io/en/latest/\n* **annofab-cli** https://github.com/kurusugawa-computer/annofab-cli\n    * \u300c\u30bf\u30b9\u30af\u306e\u4e00\u62ec\u5dee\u3057\u623b\u3057\u300d\u3084\u3001\u300c\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u9593\u306e\u5dee\u5206\u8868\u793a\u300d\u306a\u3069\u3001Annofab\u306e\u753b\u9762\u3067\u5b9f\u65bd\u3059\u308b\u306b\u306f\u6642\u9593\u304c\u304b\u304b\u308b\u64cd\u4f5c\u3092\u3001CLI\u30c4\u30fc\u30eb\u3068\u3057\u3066\u63d0\u4f9b\u3057\u3066\u3044\u307e\u3059\u3002\n* **\u958b\u767a\u8005\u7528\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8**: [README_for_developer.md](https://github.com/kurusugawa-computer/annofab-api-python-client/blob/main/README_for_developer.md)\n\n\n\n\n# \u6ce8\u610f\n* \u4f5c\u8005\u307e\u305f\u306f\u8457\u4f5c\u6a29\u8005\u306f\u3001\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u306b\u95a2\u3057\u3066\u306a\u3093\u3089\u8cac\u4efb\u3092\u8ca0\u3044\u307e\u305b\u3093\u3002\n* \u73fe\u5728\u3001API\u306f\u958b\u767a\u9014\u4e0a\u7248\u3067\u3059\u3002\u4e88\u544a\u306a\u304f\u4e92\u63db\u6027\u306e\u306a\u3044\u5909\u66f4\u304c\u3042\u308b\u53ef\u80fd\u6027\u3092\u3054\u4e86\u627f\u304f\u3060\u3055\u3044\u3002\n* put, post, delete\u7cfb\u306e\u30e1\u30bd\u30c3\u30c9\u3092\u9593\u9055\u3048\u3066\u5b9f\u884c\u3057\u3066\u3057\u307e\u308f\u306a\u3044\u3088\u3046\u3001\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u7279\u306b\u300c\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u524a\u9664\u300d\u3084\u300c\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u4ed5\u69d8\u66f4\u65b0\u300d\u306eAPI\u306b\u306f\u5341\u5206\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n \n# \u5ec3\u6b62\u4e88\u5b9a\n\u73fe\u5728\u3042\u308a\u307e\u305b\u3093\u3002\n\n\n# Features\ncURL\u3084Postman\u306a\u3069\u3088\u308a\u3082\u7c21\u5358\u306bAnnofab Web API\u306b\u30a2\u30af\u30bb\u30b9\u3067\u304d\u307e\u3059\u3002\n\n* \u30ed\u30b0\u30a4\u30f3\u3092\u610f\u8b58\u305b\u305a\u306b\u3001API\u3092\u5229\u7528\u3067\u304d\u307e\u3059\u3002\n* \u30a2\u30af\u30bb\u30b9\u904e\u591a\u306a\u3069\u3067\u5931\u6557\u3057\u305f\u5834\u5408\u306f\u3001\u30ea\u30c8\u30e9\u30a4\u3055\u308c\u307e\u3059\u3002\n* \u300c\u753b\u50cf\u3092\u5165\u529b\u30c7\u30fc\u30bf\u3068\u3057\u3066\u767b\u9332\u3059\u308b\u300d\u6a5f\u80fd\u306a\u3069\u3001API\u3092\u7d44\u307f\u5408\u308f\u305b\u305f\u6a5f\u80fd\u3082\u5229\u7528\u3067\u304d\u307e\u3059\u3002\n\n\n\n# Requirements\n* Python 3.8+ \n\n# Install\n\n```\n$ pip install annofabapi\n```\n\nhttps://pypi.org/project/annofabapi/\n\n# Usage\n\n## \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u751f\u6210\n\n### user_id, password\u3092\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u5f15\u6570\u306b\u6e21\u3059\u5834\u5408\n\n```python\n# API\u30a2\u30af\u30bb\u30b9\u7528\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u751f\u6210\nfrom annofabapi import build\n\n\nuser_id = \"XXXXXX\"\npassword = \"YYYYYY\"\n\nservice = build(user_id, password)\n```\n\n### PersonalAccessToken\u3092\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u5f15\u6570\u306b\u6e21\u3059\u5834\u5408\n\n```python\n# API\u30a2\u30af\u30bb\u30b9\u7528\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u751f\u6210\nfrom annofabapi import build\n\n\npat = \"XXXXXX\"\n\nservice = build(pat = pat)\n```\n\n\n### `.netrc`\u306b\u8a8d\u8a3c\u60c5\u5831\u3092\u8a18\u8f09\u3059\u308b\u5834\u5408\n`.netrc`\u30d5\u30a1\u30a4\u30eb\u306b\u3001Annofab\u306e\u30e6\u30fc\u30b6ID\u3068\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u8a18\u8f09\u3057\u307e\u3059\u3002\n\n```plain:.netrc\nmachine annofab.com\nlogin annofab_user_id\npassword annofab_password\n```\n\n```python\nfrom annofabapi import build_from_netrc\nservice = build_from_netrc()\n```\n\n\n#### For Linux\n* \u30d1\u30b9\u306f`$HOME/.netrc`\n* `$ chmod 600 $HOME/.netrc`\u3067\u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3\u3092\u5909\u66f4\u3059\u308b\n\n\n\n#### For Windows\n* \u30d1\u30b9\u306f`%USERPROFILE%\\.netrc`\n\n\n### \u74b0\u5883\u5909\u6570\u306b\u8a8d\u8a3c\u60c5\u5831\u3092\u8a2d\u5b9a\u3059\u308b\u5834\u5408\n\n\n* ID\u3068\u30d1\u30b9\u30ef\u30fc\u30c9\u3067\u8a8d\u8a3c\u3059\u308b\u5834\u5408\n    * \u74b0\u5883\u5909\u6570`ANNOFAB_USER_ID`\u3001`ANNOFAB_PASSWORD`\u306b\u30e6\u30fc\u30b6ID\u3068\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002\n* \u30d1\u30fc\u30bd\u30ca\u30eb\u30a2\u30af\u30bb\u30b9\u30c8\u30fc\u30af\u30f3\u3067\u8a8d\u8a3c\u3059\u308b\u5834\u5408\n    * \u74b0\u5883\u5909\u6570`ANNOFAB_PAT`\u306b\u30c8\u30fc\u30af\u30f3\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002\n    * `ANNOFAB_PAT`\u304c\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u308b\u5834\u5408\u3001`ANNOFAB_USER_ID`\u3001`ANNOFAB_PASSWORD`\u306f\u7121\u8996\u3055\u308c\u307e\u3059\u3002\n\n```python\nfrom annofabapi import build_from_env\nservice = build_from_env()\n```\n\n\n### `.netrc`\u307e\u305f\u306f\u74b0\u5883\u5909\u6570\u306b\u8a8d\u8a3c\u60c5\u5831\u3092\u8a2d\u5b9a\u3059\u308b\u5834\u5408\n``build()`` \u3092\u5b9f\u884c\u3059\u308b\u3068\u3001\u74b0\u5883\u5909\u6570\u307e\u305f\u306f `.netrc` \u30d5\u30a1\u30a4\u30eb\u304b\u3089\u8a8d\u8a3c\u60c5\u5831\u3092\u8aad\u307f\u8fbc\u307f\u307e\u3059\u3002\n\n```python\nfrom annofabapi import build\nservice = build()\n```\n\n\u512a\u5148\u9806\u4f4d\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002\n1. \u74b0\u5883\u5909\u6570\n    1. `ANNOFAB_PAT`\n    2. `ANNOFAB_USER_ID`\u53ca\u3073`ANNOFAB_PASSWORD`\n2. `.netrc`\n\n\n## `service.api`\u306e\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\n\n* `service.api`\u306b\u306f\u3001Web API\u306b\u5bfe\u5fdc\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u304c\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u307e\u3059\u3002\n* \u30e1\u30bd\u30c3\u30c9\u540d\u306f\u3001[Annofab Web API\u306eOpenAPI specification](https://annofab.com/docs/api/swagger.yaml)\u306b\u8a18\u8f09\u3055\u308c\u3066\u3044\u308b`operationId`\u3092\u3001\u30b9\u30cd\u30fc\u30af\u30b1\u30fc\u30b9\u306b\u5909\u63db\u3057\u305f\u3082\u306e\u3067\u3059\u3002\n* \u5404\u30e1\u30bd\u30c3\u30c9\u306e\u623b\u308a\u5024\u306e\u578b\u306f`Tupple[Content, Response]`\u3067\u3059\u3002\nResponse\u306f[requests\u30e2\u30b8\u30e5\u30fc\u30eb\u306eReponse\u30aa\u30d6\u30b8\u30a7\u30af\u30c8](https://2.python-requests.org/en/master/api/#requests.Response)\u3067\u3059\u3002\nContent\u306fReponse\u306e\u4e2d\u8eab\u3067\u3059\u3002\n\n```python\nproject_id = \"ZZZZZZ\"\n# `status`\u304c`complete`\u306e\u30bf\u30b9\u30af\u3092\u53d6\u5f97\u3059\u308b\ncontent, response = service.api.get_tasks(project_id, query_params={\"status\": \"complete\"})\n\nprint(type(content))\n# <class 'dict'>\nprint(content)\n# {'list': [{'project_id': 'ZZZZZZ', 'task_id': '20190317_2', 'phase': 'acceptance', ...\n\nprint(type(response))\n# <class 'requests.models.Response'>\nprint(response.headers[\"Content-Type\"])\n# application/json\n```\n\n## `service.wrapper`\u306e\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\n\n`service.wrapper`\u306b\u306f\u3001`server.api`\u3092\u7d44\u307f\u5408\u308f\u305b\u305f\u30e1\u30bd\u30c3\u30c9\u304c\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u307e\u3059\u3002\n\n\n```python\n# `status`\u304c`complete`\u306e\u30bf\u30b9\u30af\u3059\u3079\u3066\u3092\u53d6\u5f97\u3059\u308b\ntasks = service.wrapper.get_all_tasks(project_id, query_params={\"status\": \"complete\"})\nprint(type(tasks))\n# <class 'list'>\nprint(tasks)\n# [{'project_id': 'ZZZZZZ', 'task_id': '20190317_2', 'phase': 'acceptance', ...\n\n\n# simple\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3zip\u306e\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\nservice.wrapper.download_annotation_archive(project_id, 'output_dir')\n\n# \u753b\u50cf\u30d5\u30a1\u30a4\u30eb\u3092\u5165\u529b\u30c7\u30fc\u30bf\u3068\u3057\u3066\u767b\u9332\u3059\u308b\nservice.wrapper.put_input_data_from_file(project_id, 'sample_input_data_id', f'sample.png')\n```\n\n## \u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3zip\u306e\u8aad\u307f\u8fbc\u307f\n\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u305f\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3zip\u3092\u3001JSON\u30d5\u30a1\u30a4\u30eb\u3054\u3068\u306b\u8aad\u307f\u8fbc\u307f\u307e\u3059\u3002\nzip\u30d5\u30a1\u30a4\u30eb\u3092\u5c55\u958b\u3057\u305f\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3082\u8aad\u307f\u8fbc\u307f\u53ef\u80fd\u3067\u3059\u3002\n\n```python\nimport zipfile\nfrom pathlib import Path\nfrom annofabapi.parser import lazy_parse_simple_annotation_dir, lazy_parse_simple_annotation_zip, SimpleAnnotationZipParser, SimpleAnnotationDirParser, lazy_parse_simple_annotation_zip_by_task\n\n\n# Simple\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3zip\u306e\u8aad\u307f\u8fbc\u307f\niter_parser = lazy_parse_simple_annotation_zip(Path(\"simple-annotation.zip\"))\nfor parser in iter_parser:\n    simple_annotation = parser.parse()\n    print(simple_annotation)\n\n# Simple\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3zip\u3092\u5c55\u958b\u3057\u305f\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u8aad\u307f\u8fbc\u307f\niter_parser = lazy_parse_simple_annotation_dir(Path(\"simple-annotation-dir\"))\nfor parser in iter_parser:\n    simple_annotation = parser.parse()\n    print(simple_annotation)\n\n# Simple\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3zip\u3092\u30bf\u30b9\u30af\u5358\u4f4d\u3067\u8aad\u307f\u8fbc\u3080\ntask_iter_parser = lazy_parse_simple_annotation_zip_by_task(Path(\"simple-annotation.zip\"))\nfor task_parser in task_iter_parser:\n    print(task_parser.task_id)\n    for parser in task_parser.lazy_parse():\n        simple_annotation = parser.parse()\n        print(simple_annotation)\n        \n\n# Simple\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3zip\u5185\u306e1\u500b\u306eJSON\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u307f\nwith zipfile.ZipFile('simple-annotation.zip', 'r') as zip_file:\n    parser = SimpleAnnotationZipParser(zip_file, \"task01/12345678-abcd-1234-abcd-1234abcd5678.json\")\n    simple_annotation = parser.parse()\n    print(simple_annotation)\n\n# Simple\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3zip\u5185\u3092\u5c55\u958b\u3057\u305f\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u5185\u306e1\u500b\u306eJSON\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u307f\nparser = SimpleAnnotationDirParser(Path(\"task01/12345678-abcd-1234-abcd-1234abcd5678.json\"))\nsimple_annotation = parser.parse()\nprint(simple_annotation)\n\n\n```\n\n### \u5857\u308a\u3064\u3076\u3057\u753b\u50cf\u306e\u8aad\u307f\u8fbc\u307f\n`annofabapi.segmentation` \u306b\u306f\u3001\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3ZIP\u306b\u683c\u7d0d\u3055\u308c\u3066\u3044\u308b\u5857\u308a\u3064\u3076\u3057\u753b\u50cf\u3092\u6271\u3046\u305f\u3081\u306e\u95a2\u6570\u304c\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u3059\u3002\n\u5229\u7528\u3059\u308b\u5834\u5408\u306f\u3001\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n\n```\n$ pip install annofabapi[segmentation]\n```\n\n\n\n## DataClass\n`annofabapi.dataclass`\u306b\u3001\u30c7\u30fc\u30bf\u69cb\u9020\u7528\u306e\u30af\u30e9\u30b9\u304c\u3042\u308a\u307e\u3059\u3002\n\u3053\u308c\u3089\u306e\u30af\u30e9\u30b9\u3092\u5229\u7528\u3059\u308c\u3070\u3001\u5c5e\u6027\u3067\u5404\u5024\u306b\u30a2\u30af\u30bb\u30b9\u3067\u304d\u307e\u3059\u3002\n\n```python\nfrom annofabapi.dataclass.task import Task\ndict_task, _ = service.api.get_task(project_id, task_id)\ntask = Task.from_dict(dict_task)\n\nprint(task.task_id)\nprint(task.status)\n\n```\n\n\n\n\n## \u5099\u8003\n\n### `annofabapi`\u306e\u30ed\u30b0\u3092\u51fa\u529b\u3059\u308b\u65b9\u6cd5\uff08\u30b5\u30f3\u30d7\u30eb\uff09\n\n```python\nimport logging\nlogging_formatter = '%(levelname)-8s : %(asctime)s : %(name)s : %(message)s'\nlogging.basicConfig(format=logging_formatter)\nlogging.getLogger(\"annofabapi\").setLevel(level=logging.DEBUG)\n```\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python Clinet Library of Annofab WebAPI (https://annofab.com/docs/api/)",
    "version": "1.0.0",
    "project_urls": {
        "Homepage": "https://github.com/kurusugawa-computer/annofab-api-python-client",
        "Repository": "https://github.com/kurusugawa-computer/annofab-api-python-client"
    },
    "split_keywords": [
        "annofab",
        " api"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c6082fcd8723c94ac4718018bffc39d4f7ffa00de9789f4c780608a8f95b539d",
                "md5": "c766094a189232ed00ee09ac530ba771",
                "sha256": "07fc091ffb467d7f4ac77368031426000515c1c84de5162df572f41372c8e615"
            },
            "downloads": -1,
            "filename": "annofabapi-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c766094a189232ed00ee09ac530ba771",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8",
            "size": 127035,
            "upload_time": "2024-09-11T14:40:29",
            "upload_time_iso_8601": "2024-09-11T14:40:29.646783Z",
            "url": "https://files.pythonhosted.org/packages/c6/08/2fcd8723c94ac4718018bffc39d4f7ffa00de9789f4c780608a8f95b539d/annofabapi-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4c29be3ceab00e7df6d471ec1e6a3470b6a6bcc0f3084dcd167d4236bbdb25d1",
                "md5": "e2df80704461ad243b8f316d3ac092d7",
                "sha256": "3941943859c1bff81d1d26452a280b877dfb2b932283b52b7dbe8e96aec5ec83"
            },
            "downloads": -1,
            "filename": "annofabapi-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "e2df80704461ad243b8f316d3ac092d7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8",
            "size": 112585,
            "upload_time": "2024-09-11T14:40:31",
            "upload_time_iso_8601": "2024-09-11T14:40:31.382739Z",
            "url": "https://files.pythonhosted.org/packages/4c/29/be3ceab00e7df6d471ec1e6a3470b6a6bcc0f3084dcd167d4236bbdb25d1/annofabapi-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-11 14:40:31",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "kurusugawa-computer",
    "github_project": "annofab-api-python-client",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "annofabapi"
}
        
Elapsed time: 1.17486s