示例#1
0
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)
示例#2
0
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)
示例#3
0
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
示例#4
0
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
示例#5
0
文件: imports.py 项目: clkao/grano
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