Skip to content

リモートデータソース

URL、クラウドストレージ、データベースなどからアノテーションデータを読み込む。

リモートデータソース

Potatoは、ローカルファイル以外のさまざまなリモートソースからアノテーションデータを読み込むことをサポートしています。URL、クラウドストレージサービス、データベース、Hugging Faceデータセットなどに対応しています。

概要

データソースシステムは以下を提供します:

  • 複数のソースタイプ:URL、Google Drive、Dropbox、S3、Hugging Face、Google Sheets、SQLデータベース
  • 部分読み込み:大規模データセットをチャンクで読み込む
  • 増分読み込み:アノテーションの進行に応じてデータを自動追加読み込み
  • キャッシュ:リモートファイルをローカルにキャッシュして繰り返しダウンロードを回避
  • 安全な認証情報:シークレットの環境変数置換

設定

config.yamlにdata_sourcesを追加します:

yaml
data_sources:
  - type: file
    path: "data/annotations.jsonl"
 
  - type: url
    url: "https://example.com/data.jsonl"

ソースタイプ

ローカルファイル

yaml
data_sources:
  - type: file
    path: "data/annotations.jsonl"

HTTP/HTTPS URL

yaml
data_sources:
  - type: url
    url: "https://example.com/data.jsonl"
    headers:
      Authorization: "Bearer ${API_TOKEN}"
    max_size_mb: 100
    timeout_seconds: 30
    block_private_ips: true    # SSRF protection

Amazon S3

yaml
data_sources:
  - type: s3
    bucket: "my-annotation-data"
    key: "datasets/items.jsonl"
    region: "us-east-1"
    access_key_id: "${AWS_ACCESS_KEY_ID}"
    secret_access_key: "${AWS_SECRET_ACCESS_KEY}"

必要なパッケージ:pip install boto3

Google Drive

yaml
data_sources:
  - type: google_drive
    url: "https://drive.google.com/file/d/xxx/view?usp=sharing"

プライベートファイルの場合は、サービスアカウントでcredentials_fileを使用します。必要なパッケージ:pip install google-api-python-client google-auth

Dropbox

yaml
data_sources:
  - type: dropbox
    url: "https://www.dropbox.com/s/xxx/file.jsonl?dl=0"

プライベートファイルの場合は、access_token: "${DROPBOX_TOKEN}"を使用します。必要なパッケージ:pip install dropbox

Hugging Faceデータセット

yaml
data_sources:
  - type: huggingface
    dataset: "squad"
    split: "train"
    token: "${HF_TOKEN}"        # For private datasets
    id_field: "id"
    text_field: "context"

必要なパッケージ:pip install datasets

Google Sheets

yaml
data_sources:
  - type: google_sheets
    spreadsheet_id: "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"
    sheet_name: "Sheet1"
    credentials_file: "credentials/service_account.json"

必要なパッケージ:pip install google-api-python-client google-auth

SQLデータベース

yaml
data_sources:
  - type: database
    connection_string: "${DATABASE_URL}"
    query: "SELECT id, text, metadata FROM items WHERE status = 'pending'"

または個別のパラメータで:

yaml
data_sources:
  - type: database
    dialect: postgresql
    host: "localhost"
    port: 5432
    database: "annotations"
    username: "${DB_USER}"
    password: "${DB_PASSWORD}"
    table: "items"

必要なパッケージ:pip install sqlalchemy psycopg2-binary(PostgreSQL)またはpymysql(MySQL)

部分/増分読み込み

大規模データセットの場合、部分読み込みを有効にします:

yaml
partial_loading:
  enabled: true
  initial_count: 1000
  batch_size: 500
  auto_load_threshold: 0.8     # Auto-load when 80% annotated

キャッシュ

リモートソースはローカルにキャッシュされます:

yaml
data_cache:
  enabled: true
  cache_dir: ".potato_cache"
  ttl_seconds: 3600            # 1 hour
  max_size_mb: 500

認証情報管理

機密値には環境変数を使用します:

yaml
data_sources:
  - type: url
    url: "https://api.example.com/data"
    headers:
      Authorization: "Bearer ${API_TOKEN}"
 
credentials:
  env_substitution: true
  env_file: ".env"

複数ソース

複数のソースからデータを組み合わせます:

yaml
data_sources:
  - type: file
    path: "data/base.jsonl"
 
  - type: url
    url: "https://example.com/extra.jsonl"
 
  - type: s3
    bucket: "my-bucket"
    key: "annotations/batch1.jsonl"

後方互換性

data_files設定はdata_sourcesと並行して引き続き動作します:

yaml
data_files:
  - "data/existing.jsonl"
 
data_sources:
  - type: url
    url: "https://example.com/additional.jsonl"

セキュリティ

  • URLソースはデフォルトでプライベート/内部IPアドレスをブロックします(SSRF対策)
  • 認証情報をバージョン管理にコミットしないでください
  • シークレットには${VAR_NAME}構文を使用してください
  • .envファイルはリポジトリ外に保存してください

関連情報

実装の詳細については、ソースドキュメントを参照してください。