예제 #1
0
파일: util.py 프로젝트: LayerManager/layman
def patch_after_feature_change(workspace,
                               publication_type,
                               publication,
                               *,
                               queue=None,
                               **kwargs):
    try:
        redis.create_lock(workspace, publication_type, publication,
                          common.PUBLICATION_LOCK_FEATURE_CHANGE)
    except LaymanError as exc:
        if exc.code == 49 and exc.private_data.get('can_run_later', False):
            celery_util.push_step_to_run_after_chain(
                workspace, publication_type, publication,
                'layman.util::patch_after_feature_change')
            return
        raise exc
    task_methods = tasks_util.get_source_task_methods(
        get_publication_types()[publication_type],
        'patch_after_feature_change')
    patch_chain = tasks_util.get_chain_of_methods(workspace,
                                                  publication,
                                                  task_methods,
                                                  kwargs,
                                                  'layername',
                                                  queue=queue)
    res = patch_chain()
    celery_util.set_publication_chain_info(workspace, publication_type,
                                           publication, task_methods, res)
예제 #2
0
def patch_map(workspace, mapname, task_options, start_at):
    # sync processing
    sources = get_sources()
    call_modules_fn(sources, 'patch_map', [workspace, mapname], kwargs=task_options)

    # async processing
    patch_tasks = tasks_util.get_task_methods(get_map_type_def(), workspace, mapname, task_options, start_at)
    patch_chain = tasks_util.get_chain_of_methods(workspace, mapname, patch_tasks, task_options, 'mapname')
    # res = patch_chain.apply_async()
    res = patch_chain()

    celery_util.set_publication_chain_info(workspace, MAP_TYPE, mapname, patch_tasks, res)
예제 #3
0
파일: util.py 프로젝트: index-git/layman
def post_layer(workspace, layername, task_options, start_async_at):
    # sync processing
    sources = get_sources()
    call_modules_fn(sources,
                    'post_layer', [workspace, layername],
                    kwargs=task_options)

    post_tasks = tasks_util.get_task_methods(get_layer_type_def(), workspace,
                                             layername, task_options,
                                             start_async_at)
    post_chain = tasks_util.get_chain_of_methods(workspace, layername,
                                                 post_tasks, task_options,
                                                 'layername')
    # res = post_chain.apply_async()
    res = post_chain()

    celery_util.set_publication_chain_info(workspace, LAYER_TYPE, layername,
                                           post_tasks, res)
예제 #4
0
파일: util.py 프로젝트: index-git/layman
def patch_layer(workspace, layername, task_options, stop_sync_at,
                start_async_at):
    # sync processing
    sources = get_sources()
    stop_idx = next(
        (idx for idx, s in enumerate(sources) if s.__name__ == stop_sync_at),
        len(sources))
    sources = sources[:stop_idx]
    call_modules_fn(sources,
                    'patch_layer', [workspace, layername],
                    kwargs=task_options)

    patch_tasks = tasks_util.get_task_methods(get_layer_type_def(), workspace,
                                              layername, task_options,
                                              start_async_at)
    patch_chain = tasks_util.get_chain_of_methods(workspace, layername,
                                                  patch_tasks, task_options,
                                                  'layername')
    # res = patch_chain.apply_async()
    res = patch_chain()

    celery_util.set_publication_chain_info(workspace, LAYER_TYPE, layername,
                                           patch_tasks, res)