Skip to content
यह पृष्ठ अभी आपकी भाषा में उपलब्ध नहीं है। अंग्रेज़ी संस्करण दिखाया जा रहा है।

Fonti di Dati Remote

Carica i dati di annotazione da URL, archivi cloud, database e altro ancora.

Fonti di Dati Remote

Potato supporta il caricamento dei dati di annotazione da varie fonti remote oltre ai file locali, inclusi URL, servizi di archiviazione cloud, database e dataset Hugging Face.

Panoramica

Il sistema delle fonti di dati fornisce:

  • Più tipi di sorgente: URL, Google Drive, Dropbox, S3, Hugging Face, Google Sheets, database SQL
  • Caricamento parziale: Carica i dati in blocchi per i dataset di grandi dimensioni
  • Caricamento incrementale: Carica automaticamente più dati man mano che l'annotazione avanza
  • Caching: Memorizza nella cache i file remoti localmente per evitare download ripetuti
  • Credenziali sicure: Sostituzione di variabili d'ambiente per i segreti

Configurazione

Aggiungi data_sources al tuo config.yaml:

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

Tipi di Sorgente

File Locale

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    # Protezione SSRF

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

Richiede: pip install boto3

Google Drive

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

Per i file privati, usa credentials_file con un account di servizio. Richiede: 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"

Per i file privati, usa access_token: "${DROPBOX_TOKEN}". Richiede: pip install dropbox

Hugging Face Datasets

yaml
data_sources:
  - type: huggingface
    dataset: "squad"
    split: "train"
    token: "${HF_TOKEN}"        # Per i dataset privati
    id_field: "id"
    text_field: "context"

Richiede: pip install datasets

Google Sheets

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

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

Database SQL

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

Oppure con parametri individuali:

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

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

Caricamento Parziale/Incrementale

Per i dataset di grandi dimensioni, abilita il caricamento parziale:

yaml
partial_loading:
  enabled: true
  initial_count: 1000
  batch_size: 500
  auto_load_threshold: 0.8     # Carica automaticamente quando l'80% è annotato

Caching

Le sorgenti remote vengono memorizzate nella cache localmente:

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

Gestione delle Credenziali

Usa le variabili d'ambiente per i valori sensibili:

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

Sorgenti Multiple

Combina i dati da più sorgenti:

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"

Compatibilità con le Versioni Precedenti

La configurazione data_files continua a funzionare insieme a data_sources:

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

Sicurezza

  • Le sorgenti URL bloccano per impostazione predefinita gli indirizzi IP privati/interni (protezione SSRF)
  • Non committare mai le credenziali nel controllo versione
  • Usa la sintassi ${VAR_NAME} per i segreti
  • Memorizza i file .env fuori dal tuo repository

Ulteriori Letture

Per i dettagli di implementazione, consulta la documentazione sorgente.