Skip to content

feat: Implement import command with Auto-Pilot Mode#29

Merged
AliiiBenn merged 8 commits intomainfrom
feat/import-command
Jan 22, 2026
Merged

feat: Implement import command with Auto-Pilot Mode#29
AliiiBenn merged 8 commits intomainfrom
feat/import-command

Conversation

@AliiiBenn
Copy link
Member

Summary

Implements the import-data command with Auto-Pilot Mode for automatic Excel file analysis and data import into SQLite.

Features

  • [OK] Auto-Pilot Configuration: Automatically detects patterns (primary keys, foreign keys, value mappings)
  • [OK] French WMS Code Support: Translates 11 common French codes (ENTREE->inbound, SORTIE->outbound, etc.)
  • [OK] Direct Import: Uses pandas + sqlite3 for reliable data import
  • [OK] Status Command: Shows database status and table row counts
  • [OK] Value Mappings: Automatic code translation based on detected patterns

Implementation

New Module: data_import/

  • autopilot.py: PatternDetector integration for automatic configuration
  • config_refiner.py: Wareflow-specific business logic and French code mappings
  • importer.py: Simplified pandas + sqlite3 import (replaced complex SDK approach)

Updated:

  • cli.py: Added import-data and status commands
  • pyproject.toml: Added excel-to-sql>=0.3.0 and pyyaml dependencies

Usage

# 1. Initialize project
wareflow init my-warehouse

# 2. Place Excel files in data/ directory
cp *.xlsx my-warehouse/data/

# 3. Generate configuration with Auto-Pilot
cd my-warehouse
wareflow import-data --init

# 4. Import data
wareflow import-data

# 5. Check status
wareflow status

Test Results

Tested with sample data:

  • [OK] 2 Excel files analyzed (13 rows total)
  • [OK] Configuration generated automatically
  • [OK] Data imported successfully
  • [OK] Status command working

Technical Decisions

Simplified Approach: Chose direct pandas + sqlite3 over excel-to-sql SDK wrapper due to:

  1. Complex SDK API requiring project structure setup
  2. Simpler maintenance (200 lines vs 600+ lines)
  3. Better cross-platform compatibility
  4. Direct control over data transformations

Module Naming: Renamed import/ to data_import/ because import is a Python reserved keyword.

Character Encoding: Replaced emojis with ASCII for Windows console compatibility.

Co-Authored-By: Claude Sonnet 4.5 noreply@anthropic.com

AliiiBenn and others added 8 commits January 22, 2026 14:59
Updated all documentation to reflect the new Auto-Pilot Mode approach:
- ROADMAP.md: Added Option D (Auto-Pilot) as recommended approach
- Created autopilot-integration.md: Comprehensive integration guide
- features/import.md: Updated with Auto-Pilot approach
- excel-to-sql-integration.md: Added Auto-Pilot examples

Timeline improvement: 2-3 weeks to MVP (67% faster)
Code reduction: ~80% less code

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Add excel-to-sql>=0.3.0 for Auto-Pilot Mode support
- Add pyyaml for configuration file parsing

These dependencies are required for the new import command implementation.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Create the import/ module with public API exports:
- generate_autopilot_config
- run_import

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Implement autopilot.py module with:
- find_excel_files(): Discover Excel files in data directory
- analyze_excel_file(): Analyze single file with PatternDetector
- generate_autopilot_config(): Generate complete configuration
- display_quality_report(): Display quality scores and issues

Uses excel-to-sql's PatternDetector and QualityScorer for automatic
pattern detection and quality analysis.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Implement config_refiner.py module with:
- WAREFLOW_SPECIFIC_MAPPINGS: French WMS code translations
- WAREFLOW_VALIDATION_RULES: Domain-specific validations
- WAREFLOW_CALCULATED_COLUMNS: Split field combinations
- refine_config(): Apply wareflow-specific enhancements
- add_wareflow_value_mappings(): Add French code mappings
- add_wareflow_validations(): Add business validations
- add_wareflow_calculated_columns(): Add status combinations
- validate_config(): Validate configuration before import

Adds 11 French WMS mappings (ENTRÉE→inbound, SORTIE→outbound, etc.)
and business logic for movements, products, and orders.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Implement importer.py module with:
- run_import(): Execute import with progress reporting
- init_import_config(): Initialize config with Auto-Pilot
- get_import_status(): Query database status

Features:
- Batch import with per-table progress
- Error handling and rollback
- Performance metrics (duration, row counts)
- Integration with excel-to-sql SDK
- Comprehensive status reporting

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Update cli.py with:
- import command: Full Auto-Pilot integration
  * --init flag: Generate configuration automatically
  * --quiet/--verbose: Control output verbosity
  * Project validation
  * Error handling
- status command: Show database and table information

Usage:
  wareflow import --init    # Generate configuration
  wareflow import           # Import data
  wareflow status           # Show status

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Changes:
- Simplify importer.py to use pandas.read_excel() and df.to_sql() directly
- Remove dependency on excel-to-sql SDK (complex API)
- Fix module naming: import -> data_import (reserved keyword)
- Replace emojis with ASCII characters for Windows compatibility
- Update CLI help text to use 'import-data' command
- Add value mapping support (French codes translation)
- Implement status command with table row counts

Testing results:
- ✅ 2 tables imported (13 rows total)
- ✅ Status command working
- ✅ Auto-Pilot configuration generation working

This simplified approach is more maintainable and works reliably
across different environments without complex SDK dependencies.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant