Import/Export by command line
The export/import command-line functions enable you to:
- Export: Export specific traces, spans, datasets, prompts, and experiments from a project to local JSON or CSV files
- Import: Import data from local JSON files into a project
- Migrate: Move data between projects or environments, including experiments and prompts
- Backup: Create local backups of specific project data
opik export WORKSPACE TYPE NAME
Exports specific data types from the specified workspace to local files.
Arguments:
WORKSPACE: The workspace name to export fromTYPE: The type of data to export (dataset,project,experiment, orprompt)NAME: Exact name of the item to export
Options:
--path, -p: Directory to save exported data (default:opik_exports)--max-results: Maximum number of items to export per data type (default: 1000)--filter: Filter string using Opik Query Language (OQL) to narrow down the search (for projects only)--force: Re-download items even if they already exist locally--format: Format for exporting data (jsonorcsv, default:json)--debug: Enable debug output to show detailed information about the export process
Experiment-specific options:
--dataset NAME: Filter experiments by dataset name (only experiments using this dataset will be exported)--max-traces INTEGER: Maximum number of traces to export (limits total traces downloaded)
Examples:
opik import WORKSPACE TYPE NAME
Imports specific data types from local files to the specified workspace.
Arguments:
WORKSPACE: The workspace name to import toTYPE: The type of data to import (dataset,project,experiment, orprompt)NAME: Name pattern to match items (case-insensitive substring matching)
Options:
--path, -p: Directory containing exported data (default:opik_exports)--dry-run: Show what would be imported without actually importing--debug: Enable debug output to show detailed information about the import process
Note: Experiment imports automatically recreate experiments where possible. No additional flags are needed.
Examples:
File Format
JSON Format (Default)
The exported data is stored in JSON files with the following structure:
Each trace file contains:
Each evaluation rule file contains:
Each experiment file contains:
Each prompt file contains:
CSV Format
When using --format csv, data is exported as CSV files with flattened data structure. This format is ideal for:
- Data Analysis: Easy to import into Excel, Google Sheets, or data analysis tools
- Large Datasets: More efficient storage for large numbers of traces
- Spreadsheet Integration: Direct compatibility with business intelligence tools
CSV File Structure:
CSV Format Benefits:
- Single File: All data combined into one CSV file per data type
- Flattened Structure: Nested JSON data is flattened with dot notation
- Column Headers: Clear column names for easy analysis
- Compatible: Works with Excel, Google Sheets, pandas, etc.
- Universal Format: All data types (datasets, projects, experiments, prompts) support CSV export
Example CSV Structure:
Use Cases
1. Project Migration
2. Data Backup
3. Environment Sync
4. Data Analysis
5. Dataset Management
6. Data Analysis with CSV
7. Prompt Management
8. Experiment Migration
Troubleshooting
Common Issues
-
āNo traces foundā
- Check if the project name is correct
- Verify you have access to the project
- Try without filters first
-
āProject directory not foundā
- Make sure youāve exported data first
- Check the input directory path
- Verify the project name matches
-
āOpik SDK not availableā
- Ensure Opik is properly installed
- Check your Python environment
- Verify the installation with
opik healthcheck
-
āDataset/Project/Experiment/Prompt not foundā
- Check that the exact name is correct
- Verify you have access to the item
- Use
--debugfor more detailed error information
-
āNo datasets/projects foundā
- The system will show available items to help you choose the right name
- Check spelling and case sensitivity
- Ensure the item exists in the workspace
-
āDataset not foundā
- The system will show datasets used by matching experiments
- Verify the dataset name is correct
- Use
--debugto see detailed search information
Getting Help
Example Workflow
Hereās a complete example of exporting and importing trace data:
JSON Format Workflow
CSV Format Workflow
This workflow ensures you can safely migrate all data including experiments and prompts between workspaces while maintaining data integrity and providing visibility into the process. The CSV format is particularly useful for data analysis and reporting, while the JSON format preserves the complete structure needed for experiment and prompt recreation. The new command structure provides better organization with separate commands for datasets, projects, experiments, and prompts, making it easier to manage specific data types.