Skip to main content

Python Clinet Library of AnnoFab API (https://annofab.com/docs/api/)

Project description

annofab-api-python-client

AnnoFab Web APIのPythonクライアントライブラリです。

注意

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

Features

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

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

Requirements

  • Python 3.6+

Install

$ pip install annofabapi

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

Usage

インスタンス生成

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

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


user_id = "XXXXXX"
password = "YYYYYY"

service = build(user_id, password)

.netrcに記載されたuser_id, passwordから生成

.netrcファイルに、AnnofabのユーザIDとパスワードを記載します。

machine annofab.com
login annofab_user_id
password annofab_password
from annofabapi import build_from_netrc
service = build_from_netrc()

For Linux

  • パスは$HOME/.netrc
  • $ chmod 600 $HOME/.netrcでパーミッションを変更する

For Windows

  • パスは%USERPROFILE%\.netrc

service.apiのサンプルコード

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

# simpleアノテーションzipのダウンロード用URLを取得する
content, response = service.api.get_annotation_archive(project_id)
url = response.headers['Location']

service.wrapperのサンプルコード

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

# `status`が`complete`のタスクすべてを取得する
tasks = service.wrapper.get_all_tasks(project_id, query_params={'status': 'complete'})
print(tasks)
# [{'project_id': ...

# 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')

src_project_id = "AAAAAA"
dest_project_id = "BBBBBB"

# プロジェクトメンバをコピー(誤って実行しないように注意すること)
service.wrapper.copy_project_members(src_project_id, dest_project_id)

# アノテーション仕様のコピー(誤って実行しないように注意すること)
service.wrapper.copy_annotation_specs(src_project_id, dest_project_id)

備考

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

import logging
logging_formatter = '%(levelname)s : %(asctime)s : %(filename)s : %(name)s : %(funcName)s : %(message)s'
logging.basicConfig(format=logging_formatter)
logging.getLogger("annofabapi").setLevel(level=logging.DEBUG)

Documentation

https://annofab-api-python-client.readthedocs.io/en/latest/

CLIツール

「タスクの一括差し戻し」や、「プロジェクト間の差分表示」など、AnnoFabの画面で実施するには時間がかかる操作を、CLIツールとして提供しています。 詳しくはexamples/README.mdを参照してください。

Usage for Develper

README_for_developer.mdを参照してください。

Project details


Release history Release notifications | RSS feed

This version

0.7.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

annofabapi-0.7.1.tar.gz (29.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

annofabapi-0.7.1-py3-none-any.whl (33.4 kB view details)

Uploaded Python 3

File details

Details for the file annofabapi-0.7.1.tar.gz.

File metadata

  • Download URL: annofabapi-0.7.1.tar.gz
  • Upload date:
  • Size: 29.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.6

File hashes

Hashes for annofabapi-0.7.1.tar.gz
Algorithm Hash digest
SHA256 650c8bdc039d0fbebf0c23fe7537e8f2b66915f7670c3fc021ea02f1ea13f960
MD5 351e75e5cfbc42867695310654c9b40b
BLAKE2b-256 08be01b300a061556a74748da1c00594e45c58a893db0da2b98377be0b14da7b

See more details on using hashes here.

File details

Details for the file annofabapi-0.7.1-py3-none-any.whl.

File metadata

  • Download URL: annofabapi-0.7.1-py3-none-any.whl
  • Upload date:
  • Size: 33.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.6

File hashes

Hashes for annofabapi-0.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 16aff5404c4c4239d5b38d2ce9b1a82e6fe57cf0af970c0b2938aa0da2f1c4c6
MD5 e831926a15d2028d1d15514cd847695c
BLAKE2b-256 c4e3166d59e8c6878b48e8013c1926c05e9816968ca3dc3ef429cf03f5830b54

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page