Harvester Moduleο
The harvester module provides classes and functions for incremental multi-standard metadata synchronization, global repository statistics inspection, error classification, and token management.
ServerHarvesterο
- class dartfx.dataverse.ServerHarvester(host, repo_root)[source]ο
Bases:
objectManages harvesting, diff detection, and file persistence for a single Dataverse server.
- sync(query=None, since_date=None, dry_run=False, limit=None, metadata_formats='croissant', verbose=False, target_doi=None, refresh_catalog=False, cache_ttl_hours=24.0, retry_errors=False, force_verify=False, tabular_only=True, api_token=None, progress_callback=None)[source]ο
Perform intelligent incremental sync (Additions, Updates, Deletions).
Functionsο
Dataset Catalog & Fetchingο
- dartfx.dataverse.fetch_active_datasets(host, query=None, since_date=None, limit=None, target_doi=None, server_dir=None, refresh_catalog=False, cache_ttl_hours=24.0, per_page=100, verbose=False, tabular_only=True, api_token=None)[source]ο
Search for active datasets using Search API or DOI target with local 24h catalog caching.
Repository Statistics & Profilingο
Error Classification & Diagnosticsο
- dartfx.dataverse.classify_harvest_error(reason)[source]ο
Categorize an error message string into a standardized, descriptive error category.
- dartfx.dataverse.analyze_harvest_errors(repo_dir=None, server=None)[source]ο
Scan repository storage directories for .manifest.json files and aggregate error statistics.
- Parameters:
- Returns:
total_errors: Total number of failed record attempts
total_datasets: Number of distinct datasets affected
servers_with_errors: Number of server repositories with recorded errors
by_type: dict mapping error type to count
by_format: dict mapping metadata format to count
by_server: dict mapping server hostname to count
matrix: dict mapping error type to {format: count}
records: list of individual error dicts with details
- Return type:
Structured dictionary containing
Token & Configuration Managementο
- dartfx.dataverse.resolve_server_token(host=None, repo_root=None, explicit_token=None)[source]ο
Resolve API token for a Dataverse server by searching in order: 1. Explicitly supplied CLI token (βapi-token / -k) 2. Server-specific directory token file (<repo_root>/<host>/.api_token or ./<host>/.api_token) 3. Central repository root tokens mapping (<repo_root>/.dataverse_tokens.json) 4. Current working directory tokens (.dataverse_tokens.json or .tokens.json) 5. Server-specific environment variable (e.g. DATAVERSE_API_TOKEN_DATAVERSE_UNC_EDU) 6. Global environment variable (DATAVERSE_API_TOKEN or DATAVERSE_KEY)
Utility Functionsο
- dartfx.dataverse.harvester.sanitize_pid(identifier)[source]ο
Convert DOI or Handle PID to safe directory name.