Beispiel #1
0
def newExperiment(_explog_path, _plan_json=''):
    '''Create Experiment record'''
    folder = os.path.dirname(_explog_path)

    # Test if Experiment object already exists
    try:
        _newExp = models.Experiment.objects.get(unique=folder)
        print("DEBUG: Experiment exists in database: %s" % folder)
    except:
        print("DEBUG: Experiment does not exist in database")
        _newExp = None

    if _newExp is None:
        # Parse the explog.txt file
        text = load_log_path(_explog_path)
        explog = parse_log(text)
        explog[
            "planned_run_short_id"] = ''  # don't allow getting plan by shortId - other plans may exist with that id
        try:
            ret_val = generate_updateruninfo_post(folder, logger)
            if ret_val == "Generated POST":
                # Get experiment object
                exp_set = models.Experiment.objects.filter(unique=folder)
                if exp_set:
                    # Experiment object exists in database
                    _newExp = exp_set[0]
            else:
                print(
                    "ERROR: Could not update/generate new Experiment record in database"
                )
                print(ret_val)
                return None

            # Append to expName to indicate imported dataset.
            _newExp.expName += "_foreign"
            chefLog_parsed = isChefInfoAvailable(folder)
            if chefLog_parsed:
                update_chefSummary(_newExp, chefLog_parsed)
            _newExp.save()
            if _plan_json:
                planObj = _newExp.plan
                easObj = _newExp.get_EAS()
                update_plan_info(_plan_json, planObj, easObj)
        except:
            print("DEBUG: There was an error adding the experiment")
            _newExp = None
            print(traceback.format_exc())

    return _newExp
Beispiel #2
0
def newExperiment(_explog_path, _plan_json=''):
    '''Create Experiment record'''
    folder = os.path.dirname(_explog_path)

    # Test if Experiment object already exists
    try:
        _newExp = models.Experiment.objects.get(unique=folder)
        print("DEBUG: Experiment exists in database: %s" % folder)
    except:
        print("DEBUG: Experiment does not exist in database")
        _newExp = None

    if _newExp is None:
        # Parse the explog.txt file
        text = load_log_path(_explog_path)
        explog = parse_log(text)
        explog[
            "planned_run_short_id"] = ''  # don't allow getting plan by shortId - other plans may exist with that id
        try:
            ret_val = generate_updateruninfo_post(folder, logger)
            if ret_val == "Generated POST":
                # Get experiment object
                exp_set = models.Experiment.objects.filter(unique=folder)
                if exp_set:
                    # Experiment object exists in database
                    _newExp = exp_set[0]
            else:
                print("ERROR: Could not update/generate new Experiment record in database")
                print(ret_val)
                return None

            # Append to expName to indicate imported dataset.
            _newExp.expName += "_foreign"
            chefLog_parsed = isChefInfoAvailable(folder)
            if chefLog_parsed:
                update_chefSummary(_newExp, chefLog_parsed)
            _newExp.save()
        except:
            print("DEBUG: There was an error adding the experiment")
            _newExp = None
            print(traceback.format_exc())

    if _plan_json:
        update_plan_info(_plan_json, _newExp.plan, _newExp.get_EAS())

    return _newExp
def newExperiment(_explog_path, _plan_json=""):
    """Create Experiment record"""
    folder = os.path.dirname(_explog_path)

    # Test if Experiment object already exists
    try:
        _newExp = models.Experiment.objects.get(unique=folder)
        print "DEBUG: Experiment exists in database: %s" % (folder)
    except:
        print "DEBUG: Experiment does not exist in database"
        _newExp = None

    if _newExp is None:
        # Parse the explog.txt file
        text = load_log_path(_explog_path)
        explog = parse_log(text)
        explog["planned_run_short_id"] = ""  # don't allow getting plan by shortId - other plans may exist with that id
        try:
            ret_val = generate_updateruninfo_post(folder, logger)
            if ret_val == "Generated POST":
                # Get experiment object
                exp_set = models.Experiment.objects.filter(unique=folder)
                if exp_set:
                    # Experiment object exists in database
                    _newExp = exp_set[0]
            else:
                print "ERROR: Could not update/generate new Experiment record in database"
                print ret_val
                return None

            # Append to expName to indicate imported dataset.
            _newExp.expName += "_foreign"
            _newExp.save()
            if _plan_json:
                planObj = _newExp.plan
                easObj = _newExp.get_EAS()
                update_plan_info(_plan_json, planObj, easObj)
        except:
            print "DEBUG: There was an error adding the experiment"
            _newExp = None
            print traceback.format_exc()

    return _newExp