GUNDI-4684: Vectronic migration script (v1.0)#392
Conversation
There was a problem hiding this comment.
Pull Request Overview
This pull request introduces a Django management command to migrate Vectronic v1 plugin data to Gundi v2 integration system. The script processes plugin and destination data from JSON files, handles collar records deduplication, and creates corresponding integrations, configurations, and routes in the database.
- Adds comprehensive migration logic for transforming v1 plugin data into v2 integration structures
- Implements command-line interface with options for site filtering and migration limits
- Includes error handling, logging, and migration summary reporting
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
|
||
| def handle(self, *args, **options): | ||
|
|
||
| # TODO: FOR LOCAL EXECUTION ONLY! Remove if running in pod | ||
| logging.getLogger('django.db.backends').setLevel(logging.WARNING) | ||
| logging.getLogger('activity_log.mixins').setLevel(logging.ERROR) | ||
| logging.getLogger('integrations.tasks').setLevel(logging.WARNING) |
There was a problem hiding this comment.
This TODO comment indicates temporary code that should be removed for production deployment. Consider making this configurable through command-line arguments or environment variables instead of hardcoding it.
| def handle(self, *args, **options): | |
| # TODO: FOR LOCAL EXECUTION ONLY! Remove if running in pod | |
| logging.getLogger('django.db.backends').setLevel(logging.WARNING) | |
| logging.getLogger('activity_log.mixins').setLevel(logging.ERROR) | |
| logging.getLogger('integrations.tasks').setLevel(logging.WARNING) | |
| parser.add_argument( | |
| "--set-logger-levels", | |
| action="store_true", | |
| default=False, | |
| help="If present, set local logger levels for development (not for production use)", | |
| ) | |
| def handle(self, *args, **options): | |
| if options.get("set_logger_levels"): | |
| logging.getLogger('django.db.backends').setLevel(logging.WARNING) | |
| logging.getLogger('activity_log.mixins').setLevel(logging.ERROR) | |
| logging.getLogger('integrations.tasks').setLevel(logging.WARNING) |
| with open('er-prod.gundi-tokens.json', 'r') as f: | ||
| destinations_data = json.load(f) |
There was a problem hiding this comment.
The hardcoded file path 'er-prod.gundi-tokens.json' reduces flexibility. Consider making this configurable through command-line arguments or environment variables.
cdip_admin/integrations/management/commands/vectronic_v1_migration_script.py
Outdated
Show resolved
Hide resolved
| with open('er-prod.vectronic.json', 'r') as f: | ||
| plugins_data = json.load(f) |
There was a problem hiding this comment.
The hardcoded file path 'er-prod.vectronic.json' reduces flexibility. Consider making this configurable through command-line arguments or environment variables.
cdip_admin/integrations/management/commands/vectronic_v1_migration_script.py
Outdated
Show resolved
Hide resolved
…tion_script.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…nto vectronic-v1-migration-script
chrisdoehring
left a comment
There was a problem hiding this comment.
@vgarcia13 it looks fine. I think it's good to add a cli option for providing the input file.
Relevant Link
https://allenai.atlassian.net/browse/GUNDI-4684
This pull request introduces a new Django management command script,
vectronic_v1_migration_script.py, to automate the migration of Vectronic v1 plugin data to the Gundi v2 integration system. The script reads plugin and destination data from JSON files, processes and deduplicates collar records, and creates or updates corresponding integrations, configurations, and routes in the database. It supports filtering by site, limiting the number of plugins migrated, and outputs a migration summary.Key changes include:
Migration Script Implementation:
vectronic_v1_migration_script.pythat migrates Vectronic v1 plugins to Gundi v2 by reading from JSON files, deduplicating collar data, and creating/updatingIntegration,IntegrationConfiguration,Route, andRouteConfigurationrecords. The script handles both plugin and destination integrations, sets up default routes, and manages field mappings for data providers.Command-line Interface and Options:
Error Handling and Logging: