Exemplo n.º 1
0
def import_last_dataset(instance_name,
                        background=False,
                        reload_kraken=False,
                        custom_output_dir=None):
    """
    reimport the last dataset of a instance
    By default the kraken is not reloaded, the '-r' switch can activate it

    the custom_output_dir parameter is a subdirectory for the nav file created.
    If not given, the instance default one is taken
    """
    instance = models.Instance.query.filter_by(name=instance_name).first()

    if not instance:
        raise Exception("cannot find instance {}".format(instance_name))

    files = [d.name for d in instance.last_datasets(1)]
    logger = get_instance_logger(instance)
    logger.info('we reimport the last dataset of %s, composed of: %s',
                instance.name, files)
    tasks.import_data(files,
                      instance,
                      backup_file=False,
                      async=background,
                      reload=reload_kraken,
                      custom_output_dir=custom_output_dir)
Exemplo n.º 2
0
def import_last_dataset(
    instance_name, background=False, reload_kraken=False, custom_output_dir=None, nowait=False
):
    """
    reimport the last dataset of a instance
    By default the kraken is not reloaded, the '-r' switch can activate it

    the custom_output_dir parameter is a subdirectory for the nav file created.
    If not given, the instance default one is taken
    By default job is not run on the workers, you need to pass --background for use them, in that case you can
    also pass --nowait for not waiting the end of the job

    """
    instance = models.Instance.query_existing().filter_by(name=instance_name).first()

    if not instance:
        raise Exception("cannot find instance {}".format(instance_name))

    files = [d.name for d in instance.last_datasets(1)]
    logger = get_instance_logger(instance)
    logger.info('we reimport the last dataset of %s, composed of: %s', instance.name, files)
    future = tasks.import_data(
        files,
        instance,
        backup_file=False,
        async=background,
        reload=reload_kraken,
        custom_output_dir=custom_output_dir,
    )
    if not nowait and future:
        future.wait()