Script a blueprint migration#
Dataiku Govern requires a Python script to define the conditions for blueprint migrations. Blueprint migration scripts allow you to control how an artifact’s information is mapped from one blueprint version to another. This page provides some guidance about how to script a blueprint migration.
Note
The migration script cannot edit the structure of blueprint versions. It can only map the information of an artifact within the framework of existing blueprint versions.
See also
If you are only interested in applying blueprint migrations, check out How-to | Switch artifact templates (blueprint versions).
Pre-populated lines#
The pre-populated lines in the script establish the source and target blueprints.
from govern.core.migration_handler import get_migration_handler
handler = get_migration_handler()
### Get the artifact to migrate
target_artifact = handler.target_artifact
### Get the source enriched artifact
source_enriched_artifact = handler.source_enriched_artifact
### Get the target blueprint version definition
target_blueprint_version = handler.target_blueprint_version
There are also a few lines that are commented out that may help you do things like rename the target artifact, create default target fields, etcetera.
Managing fields and workflow steps#
The most important part of the migration script involves managing fields and workflow steps. Here is a short list of potential field manipulations.
Note
In the examples below, fields
is a python dictionary.
Action |
Code |
---|---|
Define a default value for a new field |
|
Remove values from a deleted field |
|
Move the data from one field to another |
|
Change the current workflow step |
|
If you want a new field to appear empty in the target blueprint, you don’t need to define anything in the blueprint migration script. There are no values to migrate.