Skip to content

Fuentes de Datos Remotas

Carga datos de anotación desde URLs, almacenamiento en la nube, bases de datos y más.

Fuentes de Datos Remotas

Potato admite la carga de datos de anotación desde diversas fuentes remotas más allá de archivos locales, incluyendo URLs, servicios de almacenamiento en la nube, bases de datos y conjuntos de datos de Hugging Face.

Descripción General

El sistema de fuentes de datos proporciona:

  • Múltiples tipos de fuentes: URLs, Google Drive, Dropbox, S3, Hugging Face, Google Sheets, bases de datos SQL
  • Carga parcial: Carga datos en fragmentos para conjuntos de datos grandes
  • Carga incremental: Carga automática de más datos a medida que avanza la anotación
  • Caché: Almacena archivos remotos localmente para evitar descargas repetidas
  • Credenciales seguras: Sustitución de variables de entorno para secretos

Configuración

Agrega data_sources a tu config.yaml:

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

Tipos de Fuentes

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

Requiere: pip install boto3

Google Drive

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

Para archivos privados, usa credentials_file con una cuenta de servicio. Requiere: 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 archivos privados, usa access_token: "${DROPBOX_TOKEN}". Requiere: pip install dropbox

Conjuntos de Datos de Hugging Face

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

Requiere: pip install datasets

Google Sheets

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

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

Base de Datos SQL

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

O con parámetros individuales:

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

Requiere: pip install sqlalchemy psycopg2-binary (PostgreSQL) o pymysql (MySQL)

Carga Parcial/Incremental

Para conjuntos de datos grandes, habilita la carga parcial:

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

Caché

Las fuentes remotas se almacenan en caché localmente:

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

Gestión de Credenciales

Usa variables de entorno para valores sensibles:

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

Múltiples Fuentes

Combina datos de múltiples fuentes:

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"

Compatibilidad con Versiones Anteriores

La configuración data_files continúa funcionando junto con data_sources:

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

Seguridad

  • Las fuentes URL bloquean direcciones IP privadas/internas por defecto (protección SSRF)
  • Nunca incluyas credenciales en el control de versiones
  • Usa la sintaxis ${VAR_NAME} para secretos
  • Almacena los archivos .env fuera de tu repositorio

Lectura Adicional

Para detalles de implementación, consulta la documentación fuente.