-
Notifications
You must be signed in to change notification settings - Fork 0
GUNDI-4618: Gundi v1 migration script MK1 #377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
cdip_admin/integrations/management/commands/awt_v1_migration_script.py
Outdated
Show resolved
Hide resolved
cdip_admin/integrations/management/commands/awt_v1_migration_script.py
Outdated
Show resolved
Hide resolved
cdip_admin/integrations/management/commands/awt_v1_migration_script.py
Outdated
Show resolved
Hide resolved
cdip_admin/integrations/management/commands/awt_v1_migration_script.py
Outdated
Show resolved
Hide resolved
cdip_admin/integrations/management/commands/awt_v1_migration_script.py
Outdated
Show resolved
Hide resolved
cdip_admin/integrations/management/commands/awt_v1_migration_script.py
Outdated
Show resolved
Hide resolved
| ) | ||
|
|
||
| def handle(self, *args, **options): | ||
| if inbounds_to_migrate := self._get_awt_inbounds(options=options): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idea: If we accept an integration-type param and use it for querying the inbounds, then this command could be made more generic and be used in the future to migrate inbounds of any type to v2 (it may need some other tweaks too). This could be left for a second iteration of course, but what do you think @vgarcia13 @victorlujanearthranger @chrisdoehring?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, I would need to add support for defining the action to populate and the required field mappings
cdip_admin/integrations/management/commands/awt_v1_migration_script.py
Outdated
Show resolved
Hide resolved
cdip_admin/integrations/management/commands/awt_v1_migration_script.py
Outdated
Show resolved
Hide resolved
|
Great progress @vgarcia13! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a Django management command to automate the migration of Gundi v1 inbound integrations to the Gundi v2 system. The script provides comprehensive migration functionality with options for filtering and limiting the inbounds to migrate.
Key changes:
- Added a new management command with CLI arguments for inbound type, integration type, action, specific inbounds, and migration limits
- Implemented migration logic that creates or retrieves related objects (organizations, integration types, integrations, actions, routes, configurations)
- Defined JSON schemas for Earth Ranger authentication configuration and field mapping defaults
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
cdip_admin/integrations/management/commands/gundi_v1_migration_script.py
Outdated
Show resolved
Hide resolved
| self.stdout.write(f" -- ERROR: {inbound_slug.capitalize()} Integrations with IDs {options['inbounds']} not found -- \n") | ||
| return [] | ||
|
|
||
| if options['max']: |
Copilot
AI
Sep 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition if options['max']: will fail when --max is set to 0, as 0 is falsy in Python. This should be if options['max'] is not None: or check for non-negative values explicitly.
| if options['max']: | |
| if options['max'] is not None: |
…_script.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Relevant Link
https://allenai.atlassian.net/browse/GUNDI-4618
This pull request introduces a new Django management command in
gundi_v1_migration_script.pyto automate the migration of Gundi v1 inbound integrations to the Gundi v2 system. The script provides options for selecting specific inbounds, integration types, and actions, and handles the creation of necessary related objects (integrations, actions, organizations, routes, and configurations) during migration. It also includes custom JSON schema definitions for authentication and field mappings, and provides detailed output and error handling throughout the migration process.Key additions and features:
Migration Command Implementation
gundi_v1_migration_script.pythat migrates inbound integrations from Gundi v1 to Gundi v2, with arguments for inbound type, integration type, action, specific inbounds, and migration limits.Schema and Field Mapping Definitions
ER_DESTINATION_JSON_SCHEMAandER_DESTINATION_UI_SCHEMAfor defining authentication configuration structure for migrated integrations.