def import_aliases(project, author, path): """ Set up a data pipeline and execute it. """ with open(path, 'r') as fh: config = {'mapping': { 'canonical': {'attribute': 'canonical'}, 'alias': {'attribute': 'alias'} }} name = os.path.basename(path) pipeline = pipelines.create(project, 'import', name, config, author) pipelines.start(pipeline) imports.import_aliases(pipeline, fh) pipelines.finish(pipeline)
def make_importer(project, account, data): """ Create an importer pipeline to represent the data import process which will be executed. """ validator = ImportBaseValidator() sane = validator.deserialize(data) # TODO: validate mapping. config = { "mode": sane.get("mode"), "file": sane.get("file").id, "source_url": sane.get("source_url"), "mapping": data.get("mapping"), "relation_schema": data.get("relation_schema"), } pipeline = pipelines.create(project, "import", sane.get("file").file_name, config, account) run_importer.delay(pipeline.id) return pipeline
def make_importer(project, account, data): """ Create an importer pipeline to represent the data import process which will be executed. """ validator = ImportBaseValidator() sane = validator.deserialize(data) # TODO: validate mapping. config = { 'mode': sane.get('mode'), 'file': sane.get('file').id, 'source_url': sane.get('source_url'), 'mapping': data.get('mapping'), 'relation_schema': data.get('relation_schema') } pipeline = pipelines.create(project, 'import', sane.get('file').file_name, config, account) run_importer.delay(pipeline.id) return pipeline