Ejemplo n.º 1
0
def get_simulations_from_big_experiments(experiment_id):
    e = get_experiment_by_id(experiment_id)
    start_date = end_date = e.date_created
    import pytz
    limit_date = datetime.today().replace(tzinfo=pytz.utc)
    interval = 60
    stop_flag = False
    results = {}
    while start_date < limit_date:
        start_date = end_date + timedelta(minutes=interval)
        try:
            batch = Simulation.get(query_criteria=QueryCriteria()
                                   .select(['id', 'state', 'date_created']).select_children('tags')
                                   .where(["experiment_id={}".format(experiment_id),
                                           "date_created>={}".format(end_date.strftime('%Y-%m-%d %T')),
                                           "date_created<={}".format(start_date.strftime('%Y-%m-%d %T'))])
                                   )
        except:
            interval /= 2
            continue

        if not batch:
            if stop_flag:
                break
            else:
                interval = 120
                stop_flag = True
        else:
            stop_flag = False
            for s in batch:
                results[s.id] = s
        end_date = start_date
    return results.values()
Ejemplo n.º 2
0
    def query_simulation(sid, criteria=None, children=None):
        from COMPS.Data import Simulation
        from COMPS.Data import QueryCriteria
        if children:
            criteria = criteria or QueryCriteria()
            criteria.select_children(children)

        return Simulation.get(sid, query_criteria=criteria)
Ejemplo n.º 3
0
def sims_from_experiment_id(exp_id):
    return Simulation.get(query_criteria=QueryCriteria().select(
        ['id', 'state']).where('experiment_id=%s' % exp_id))
Ejemplo n.º 4
0
def get_simulation_by_id(sim_id, query_criteria=None):
    return Simulation.get(id=sim_id, query_criteria=query_criteria)
Ejemplo n.º 5
0
def get_asset_collection_id_for_simulation_id(sim_id):
    query_criteria = QueryCriteria().select_children('configuration')
    simulation = Simulation.get(id=sim_id, query_criteria=query_criteria)
    collection_id = simulation.configuration.asset_collection_id
    return collection_id