This system provides comprehensive tool synchronization between TipQA and Ion environments. It consists of several scripts designed for different purposes:
- Daily Tool Sync: Handles ongoing synchronization between TipQA and Ion V1 environments
- V2 Population: One-time population script for V2 Sandbox and V2 Production environments
- Ion Tool Library Builder: Creates tool parts (without inventory) in V2 Sandbox and V2 Production (Ion Reloaded)
The system supports the following Ion environments:
-
V1 Sandbox: Testing environment for V1 Ion API (
staging-api.buildwithion.com)- Credentials:
V1SANDBOX_CLIENT/V1SANDBOX_SECRET
- Credentials:
-
V1 Production (One Ion): Production environment for V1 Ion API (
api.buildwithion.com)- Credentials:
V1CLIENT/V1SECRET - Used for: Daily tool synchronization in production
- Credentials:
-
V2 Sandbox: Testing environment for V2 Ion API (
staging-api.buildwithion.com)- Credentials:
V2SANDBOX_CLIENT/V2SANDBOX_SECRET
- Credentials:
-
V2 Production (Ion Reloaded): Production environment for V2 Ion API (
api-jobyaero.buildwithion.com)- Credentials:
V2CLIENT/V2SECRET - Used for: Joby Aviation's custom Ion instance
- Credentials:
-
V2 Staging (Ion Reloaded Staging): Staging environment for V2 Ion API (
staging-api.buildwithion.com)- Credentials:
V2STAGINGCLIENT/V2STAGINGSECRET
- Credentials:
- Tool Synchronization: Syncs tools between TipQA and Ion systems
- Tool Creation: Creates new tools in Ion that don't exist
- Tool Updates: Updates existing tools based on TipQA data
- Orphaned Tool Management: Identifies and marks tools as unavailable that exist in Ion but not in TipQA
- Status Management: Handles tool statuses (available/unavailable) based on TipQA maintenance status
- Comprehensive Error Handling: Detailed error reporting and diagnostic output
- Diagnostic Reports: Markdown reports with field-level analysis and service interval changes
- Python 3.8+
- Access to TipQA SQL Server
- Ion API credentials (sandbox and production)
- Docker (for containerized deployment)
Copy the environment template and fill in your credentials:
cp env_template.txt .envEdit .env with your actual credentials. See env_template.txt for all required environment variables and their descriptions.
Edit config.yaml to match your environment. The file includes:
- Database connection settings for TipQA
- Ion API endpoints for all environments
- Protected part numbers configuration
- Other system settings
See config.yaml in the repository for the complete configuration template.
Purpose: Ongoing synchronization between TipQA and Ion V1 environments Usage: Run daily for production tool management
Supported Environments:
- V1 Sandbox: Use for testing changes before production
- V1 Production (One Ion): Use for daily production synchronization
Features:
- Syncs tools from TipQA to Ion V1 Sandbox or V1 Production
- Handles orphaned tools (tools in Ion but not in TipQA)
- Comprehensive error handling and logging
- Diagnostic reports for analysis
Documentation:
- Master Data Flow:
queries/master_data_flow.md- Complete documentation of master dataframe creation and analysis logic - Execution Flow:
tests/test_logic_flow.md- Complete documentation of how scripts execute updates
Usage:
# Specify environment when running (v1_sandbox or v1_production)
# Check script for environment parameter usagePurpose: One-time population of V2 Sandbox and V2 Production environments Usage: Run once to initially populate V2 environments, then archive
Features:
- Populates V2 Sandbox from TipQA
- Populates V2 Production from TipQA
- Skips obsolete format tools (XXXX-XXXX)
- Comprehensive validation and error handling
Purpose: Creates tool parts (without inventory) in V2 Sandbox or V2 Production (Ion Reloaded) Usage: Run to build the tool library before creating inventory items
Features:
- Creates tool parts without serial numbers (library parts only)
- Supports both V2 Sandbox and V2 Production (Ion Reloaded) environments
- Excludes inactive tools (maintenance_status = 'I' or revision_status = 'I')
- Filters out protected part numbers and their associated serial numbers
- Maps TipQA fields: partNumber, revision, description, maintenanceIntervalSeconds, and Asset Type attribute
- Multiple safety checks to prevent protected parts from being created
- Dry run mode for analysis
Usage:
# Dry run for V2 Sandbox (default)
python utilities/ion_tool_library_builder.py --dry-run
# Dry run for V2 Production (Ion Reloaded)
python utilities/ion_tool_library_builder.py --environment v2_production --dry-run
# Actual execution for V2 Production
python utilities/ion_tool_library_builder.py --environment v2_production
# Generate invalid revision report
python utilities/ion_tool_library_builder.py --invalid-revision-reportField Mappings: See queries/master_data_flow.md for complete field mapping documentation.
-
Install dependencies:
make install
-
Set up environment:
make setup # Edit .env with your credentials -
Run daily sync (dry run):
make daily-sync
-
Run V2 population (dry run):
make populate-v2
-
Daily sync in production:
make daily-sync-prod
-
V2 population in production:
make populate-v2-prod
-
Build and run:
make run
-
Clean up:
make clean
This script is designed to run daily from a cloud server. You can:
-
Set up a cron job:
# Run daily at 2 AM 0 2 * * * cd /path/to/ion_tool_population && make run
-
Use cloud schedulers like AWS EventBridge, Azure Logic Apps, or Google Cloud Scheduler
-
Deploy as a container using Docker
The system follows a structured process:
- Master Dataframe Creation - Combines TipQA and Ion data into unified dataset
- Analysis Logic - Determines actions (SKIP, CREATE, UPDATE, etc.) for each tool
- Execution - Performs Ion mutations based on determined actions
For complete details, see:
queries/master_data_flow.md- Master dataframe creation and analysis logictests/test_logic_flow.md- Execution details and testing methodology
The scripts generate:
- Terminal Output: Real-time progress and summary statistics
- Diagnostic Reports: Markdown files in
tests/directory with detailed analysis - CSV Reports: For dry-run analysis (when applicable)
- Error Reports: Detailed error information for failed operations
After each run, check tests/update_diagnostic_YYYYMMDD_HHMMSS.md for:
- Summary statistics
- Update reasons breakdown
- Field-level mismatch analysis
- Service interval changes (for calibration team review)
- Sample comparisons
-
Database Connection Failed
- Check SQL Server credentials in
.env - Verify network connectivity to TipQA server
- Check SQL Server credentials in
-
Ion API Authentication Failed
- Verify API credentials in
.env - Check if credentials are for correct environment
- Verify API credentials in
-
GraphQL Errors
- Check diagnostic reports in
tests/directory - Review error details in
update_diagnostic_YYYYMMDD_HHMMSS.md - Verify GraphQL queries in
queries/folder
- Check diagnostic reports in
-
High Update Counts
- Review diagnostic report for field-level mismatch breakdown
- Check service interval changes section
- Verify comparison logic in
queries/master_data_flow.md
ion_tool_population/
├── daily_tool_sync.py # Main daily synchronization script
├── config.yaml # Configuration file
├── requirements.txt # Python dependencies
├── Dockerfile # Container configuration
├── docker-compose.yml # Docker compose setup
├── Makefile # Build commands
├── env_template.txt # Environment variables template
├── utilities/ # Utility scripts
│ ├── database_utils.py # Database connection utilities
│ ├── graphql_utils.py # GraphQL query utilities
│ ├── shared_sync_utils.py # Core synchronization logic
│ └── tool_processing_utils.py # Tool creation/update functions
├── tests/ # Test scripts and diagnostic reports
│ └── test_logic_flow.md # Execution flow documentation
├── queries/ # All queries (GraphQL and SQL)
│ ├── *.graphql # GraphQL queries
│ ├── *.sql # SQL queries
│ └── master_data_flow.md # Master dataframe creation documentation
└── README.md # This file (setup and usage)
Key Documentation:
- Setup/Usage:
README.md(this file) - Master Dataframe:
queries/master_data_flow.md- How master dataframe is created - Execution:
tests/test_logic_flow.md- How scripts execute updates
For detailed information:
- Master Dataframe Creation:
queries/master_data_flow.md- How TipQA and Ion data are combined and analyzed - Execution Details:
tests/test_logic_flow.md- How scripts perform updates, mutations, and error handling - Tool Sync Logic:
utilities/tool_sync_logic_flow.md- Additional synchronization details
- Store credentials securely (use environment variables or secret management)
- Use sandbox environment for testing
- Monitor logs for unauthorized access attempts
- Regularly rotate API credentials
- Use least-privilege access for database connections
For issues or questions:
- Check the logs in
ion_tool_population.log - Verify configuration files
- Test in sandbox environment first
- Review Ion API documentation for any changes
Certain part numbers are protected from being created or converted to tools. These are defined in config.yaml under sync_exceptions.protected_part_numbers. See queries/master_data_flow.md for details on how protected parts are handled.
- v2.0 (2025-01-XX): Added V2 Production (Ion Reloaded) support, Ion Tool Library Builder, protected parts filtering
- v1.0 (2025-01-27): Initial release with full population capabilities