Beispiel #1
0
def load_task_group(db, options, task_names=None):
    if task_names is None:
        task_names = options['tasks'].keys()
    task_options = { task: options["tasks"][task] for task in task_names }

    jobs = load_jobs(db, options['experiment-name'])

    task_group = TaskGroup(task_options, options['variables'])

    if jobs:
        task_group.inputs  = np.array([task_group.vectorify(job['params'])
                for job in jobs if job['status'] == 'complete'])

        task_group.pending = np.array([task_group.vectorify(job['params'])
                for job in jobs if job['status'] == 'pending'])

        task_group.values  = {task : np.array([job['values'][task]
                for job in jobs if job['status'] == 'complete'])
                    for task in task_names}

        task_group.add_nan_task_if_nans()

        # TODO: record costs

    return task_group
Beispiel #2
0
def load_task_group(db, options, task_names=None):
    if task_names is None:
        task_names = options['tasks'].keys()
    task_options = { task: options["tasks"][task] for task in task_names }

    jobs = load_jobs(db, options['experiment-name'])

    task_group = TaskGroup(task_options, options['variables'])

    if jobs:
        task_group.inputs  = np.array([task_group.vectorify(job['params'])
                for job in jobs if job['status'] == 'complete'])

        task_group.pending = np.array([task_group.vectorify(job['params'])
                for job in jobs if job['status'] == 'pending'])

        task_group.values  = {task : np.array([job['values'][task]
                for job in jobs if job['status'] == 'complete'])
                    for task in task_names}

        task_group.add_nan_task_if_nans()

        # TODO: record costs

    return task_group
Beispiel #3
0
def load_task_group(db, options, task_names=None, data_connector=None):
    if task_names is None:
        task_names = options['tasks'].keys()
    task_options = {task: options["tasks"][task] for task in task_names}

    jobs = load_jobs(db, options['experiment-name'])

    task_group = TaskGroup(task_options, options['variables'])

    if jobs:
        task_group.inputs = np.array([
            task_group.vectorify(job['params']) for job in jobs
            if job['status'] == 'complete'
        ])

        task_group.pending = np.array([
            task_group.vectorify(job['params']) for job in jobs
            if job['status'] == 'pending'
        ])

        task_group.values = {
            task: np.array([
                job['values'][task] for job in jobs
                if job['status'] == 'complete'
            ])
            for task in task_names
        }

        task_group.add_nan_task_if_nans()

        # TODO: record costs

    # [KZ]
    # Appending the offline collected data to the suggested data.
    if data_connector is not None:
        if len(task_group.inputs) == 0:
            task_group.inputs = data_connector.inputs_
        else:
            task_group.inputs = np.vstack(
                [data_connector.inputs_, task_group.inputs])

        inkeys = []
        for task_key in data_connector.values_:
            if task_key in task_group.values:
                inkeys.append(task_key)

        # We need to create a new dictionary and feed it to taskgroup.values
        # because this is a property...
        newvalues = {}
        for task_key in inkeys:
            if len(task_group.values[task_key]) > 0:
                newvalues[task_key] = np.concatenate([
                    data_connector.values_[task_key],
                    task_group.values[task_key]
                ])
            else:
                newvalues[task_key] = data_connector.values_[task_key]

        for task_key in task_group.values:
            if task_key not in newvalues:
                newvalues[task_key] = task_key

        task_group.values = newvalues

    return task_group