mr.migrator is a transmogrifier pipeline runner, either via the commandline or as a Plone add-on.
- Code repository: http://github.com/collective/mr.migrator
- Questions and comments to http://github.com/collective/mr.migrator/issues
- Report bugs at http://github.com/collective/mr.migrator/issues
Contents
Transmogrifier is a powerful tool for creating transformation processes called "pipelines". Transmogrifier gives you the tools to create and share these pipelines but doesn't provide an easy way to run the pipeline. Mr.migrator aims to bridge that gap.
Mr.Migrator provides the following:
- A buildout recipe with which you can override a given pipeline.
- A commandline script (with help) which lets you run pipelines and see their progress. This is useful when used in conjunction with transmogrify.ploneremote or other blueprints which are not expected to be run inside the Plone process.
- A Plone plugin that once installed lets you pick which pipeline you want to run, provides a form to override the pipeline options and then provides progress on the running pipeline. This is useful when you want to use plone.app.transmogrifier blueprints that should be run inside the Plone process.
A pipeline is a concept from collective.transmogrifier where dictionary items pass through a series of steps, each adding, removing or uploading information to an external source. A pipeline is configured in configuration file using the INI style syntax. Mr.Migrator lets you run either pipelines you built yourself, or
see collective.transmogrifer pipelines for more details.
Once you've created your pipeline .cfg you can use it on the commandline via
migrate --pipeline=mypipeline.cfg
or if installing via buildout
[migrate] recipe = mr.migrator pipeline = mypipeline.cfg
If you're using blueprints in your pipeline you will need to ensure that zcml configuration that registers them is executed. If you are using buildout you can use the following
[buildout] parts += mr.migrator [migrator] recipe = mr.migrator pipeline = mypipeline.cfg eggs = transmogrify.sqlalchemy zcml = transmogrify.sqlalchemy
This will ensure that the package that contains the blueprints is downloaded and the zcml for it is run before the pipeline is run so that the blueprints are registered.
If you aren't using buildout you can will need to tell the runner which packages to load zcml in via
migrate --zcml=transmogrify.sqlalchemy,transmogrify.other
If you the blueprint package includes the following entry_point you can skip the zcml settings above
entry-points = {"z3c.autoinclude.plugin":['target = transmogrify']}
There currently isn't a way to run a custom pipeline if using the Plone plugin. You will have to register it as below.
If a pipeline has been registered inside another package via zcml such as
<configure xmlns="http://namespaces.zope.org/zope" xmlns:transmogrifier="http://namespaces.plone.org/transmogrifier" i18n_domain="collective.transmogrifier"> <transmogrifier:registerConfig name="exampleconfig" title="Example pipeline configuration" description="This is an example pipeline configuration" configuration="example.cfg" /> </configure>
and the package has an entry point that will enable the zcml to be loaded such as
entry_points = {"z3c.autoinclude.plugin":['target = transmogrify']}
Then you can get mr.migrator to run that pipeline via
migrate --pipeline=exampleconfig
or
[migrate] recipe = mr.migrator pipeline = exampleconfig
An example of a package which declares a pipeline designed to be overridden is funnelweb.
Pipelines are organised as a series of steps through which crawled items pass before eventually being uploaded. Each step as one or more configuration options so you can customise import process for your needs. Almost all imports will require some level of configurations.
The first part of each configuration key is the step e.g. crawler. The second part is the particular configuration option for that particular step. e.g. url. This is then followed by = and value or values.
The configuration options can either be given as part of the buildout part e.g.
[buildout] parts += mr.migrator [mr.migrator] recipe = mr.migrator crawler-url=http://www.whitehouse.gov
or the same option can be overridden via the command line
$> bin/migrate --crawler:url=http://www.whitehouse.gov
some options require multiple lines within a buildout part. These can be overridden via the commandline by repeating the same argument e.g.
$> bin/migrate --crawler:ignore=\.mp3 --crawler:ignore=\.pdf
You use the commandline help to view the list of available options
$> bin/migrate --help
You can show additional debug output on any particular set by setting a debug commandline switch. For instance to see see additional details about template matching failures
$> bin/mr.migrator --template1:debug
You might need to insert further transformation steps for your particular conversion usecase. To do this, you can extend a plugins underlying transmogrifier pipeline. mr.migrator uses a transmogrifier pipeline to perform the needed transformations and all commandline and recipe options refer to options in the pipeline.
You can view pipeline and all its options via the following command
$> bin/mr.migrator --show-pipeline
You can also save this pipeline and customise it for your own needs
$> bin/mr.migrator --show-pipeline > pipeline.cfg $> {edit} pipeline.cfg $> bin/mr.migrator --pipeline=pipeline.cfg
Customising the pipeline allows you add your own personal transformations which haven't been pre-considered by the standard mr.migrator tool.
See transmogrifier documentation to see how to add your own blueprints or add blueprints that already exist to your custom pipeline.
If you have decided you need to customise your pipeline and you want to install transformation
steps that use blueprints not already included in mr.migrator or transmogrifier, you can include
them using the eggs
option in a mr.migrator buildout part
[mr.migrator] recipe = mr.migrator eggs = myblueprintpackage pipeline = mypipeline.cfg
However, this only works if your blueprint package includes the following setuptools entrypoint
in its setup.py
entry_points=""" [z3c.autoinclude.plugin] target = transmogrify """, )
Note
Some transmogrifier blueprints assume they are running inside a Plone
process such as those in plone.app.transmogrifier (see http://pypi.python.org/pypi/plone.app.transmogrifier). mr.migrator
doesn't run inside a Plone process so these blueprints won't work. If
you want upload content into Plone, you can instead use
transmogrify.ploneremote which provides alternative implementations
which will upload content remotely via XML-RPC.
transmogrify.ploneremote
is already included in funnelweb as it is
what funnelweb's default pipeline uses.
TODO
*under development*
Mr.Migrator needs to be combined with a package providing a registered pipeline.
- Install mr.migrator into your buildout
- Install a package providing your pipeline such as funnelweb or collective.jsonmigrator
- Go to the place in your site where you want to import content and select Actions > Mr.Migrate here (alternatively, open the URL
@@mr.migrator
) - Pick the pipeline you want from the drop down list
- A form for filling in extra configuration for your pipeline will displayed (either autogenerated from the .cfg or a form designed by the pipeline author)
- Click run
- Popup a progress feedback dialog with a log of activity
- Finish autoform so works in all cases
- combine argsparse and autoform code
- do progress dialog
- hook point for packages to register form along with pipeline
- when no pipelines found: display help on where to find them and how to install them
- Code repository: http://github.com/collective/mr.migrator
- Questions and comments to http://github.com/collective/mr.migrator/issues
- Report bugs at http://github.com/collective/mr.migrator/issues
- Alex Clark - for the name
- Rok Garbas - the original code for the z3cform
- Dylan Jay - the original code of the commandline runner