Skip to content

Fontes de Dados Remotas

Carregue dados de anotação dinamicamente no Potato a partir de URLs HTTP, buckets S3, Google Cloud Storage, bancos de dados PostgreSQL e HuggingFace Datasets, sem arquivos locais.

O Potato oferece suporte ao carregamento de dados de anotação a partir de várias fontes remotas além dos arquivos locais, incluindo URLs, serviços de armazenamento em nuvem, bancos de dados e datasets da Hugging Face.

Visão Geral

O sistema de fontes de dados oferece:

  • Vários tipos de fonte: URLs, Google Drive, Dropbox, S3, Hugging Face, Google Sheets, bancos de dados SQL
  • Carregamento parcial: Carrega dados em blocos para grandes datasets
  • Carregamento incremental: Carrega mais dados automaticamente conforme a anotação avança
  • Cache: Mantém arquivos remotos em cache local para evitar downloads repetidos
  • Credenciais seguras: Substituição por variáveis de ambiente para segredos

Configuração

Adicione data_sources ao seu config.yaml:

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

Tipos de Fonte

Arquivo Local

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

URL HTTP/HTTPS

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}"

Requer: pip install boto3

Google Drive

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

Para arquivos privados, use credentials_file com uma conta de serviço. Requer: 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"

Para arquivos privados, use access_token: "${DROPBOX_TOKEN}". Requer: pip install dropbox

Datasets da Hugging Face

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

Requer: pip install datasets

Google Sheets

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

Requer: pip install google-api-python-client google-auth

Banco de Dados SQL

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

Ou com parâmetros individuais:

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

Requer: pip install sqlalchemy psycopg2-binary (PostgreSQL) ou pymysql (MySQL)

Carregamento Parcial/Incremental

Para grandes datasets, ative o carregamento parcial:

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

Cache

As fontes remotas são mantidas em cache local:

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

Gerenciamento de Credenciais

Use variáveis de ambiente para valores sensíveis:

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

Múltiplas Fontes

Combine dados de várias fontes:

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"

Compatibilidade Retroativa

A configuração data_files continua funcionando junto com data_sources:

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

Segurança

  • As fontes de URL bloqueiam endereços IP privados/internos por padrão (proteção contra SSRF)
  • Nunca faça commit de credenciais no controle de versão
  • Use a sintaxe ${VAR_NAME} para segredos
  • Armazene arquivos .env fora do seu repositório

Leitura Adicional

Para detalhes de implementação, consulte a documentação de origem.