From be990ce6ea7ccf54b0c29e70a21c19740859545f Mon Sep 17 00:00:00 2001 From: Dave Parker Date: Sun, 26 Apr 2020 00:05:24 +0100 Subject: [PATCH] prism-auto: --filter-models works even if some model metadata is missing (e.g. states info for PTA benchmarks) --- prism/etc/scripts/prism-auto | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/prism/etc/scripts/prism-auto b/prism/etc/scripts/prism-auto index 30d774ee..5f1e396d 100755 --- a/prism/etc/scripts/prism-auto +++ b/prism/etc/scripts/prism-auto @@ -170,15 +170,19 @@ def filterModels(modelFiles, filterString, dir): for row in reader: # Evaluate the filter using eval() # Only provide access to the model type and number of states for now - # If any fields are missing, the filter evaluates to false - filterVarsAvailable = ['model_type', 'states'] - filterVarsMissing = [key for key in filterVarsAvailable if key in filterString and not row[key]] - if not filterVarsMissing: - if eval(filterString, {"__builtins__": {}}, {'model_type': row['model_type'], 'states': int(row['states'])}): + #filterVarsAvailable = ['model_type', 'states'] + #filterVarsMissing = [key for key in filterVarsAvailable if key in filterString and not row[key]] + eval_model_type = row['model_type'] if row['model_type'] else None + eval_states = int(row['states']) if row['states'] else None + try: + if eval(filterString, {"__builtins__": {}}, {'model_type': eval_model_type, 'states': eval_states}): model = row['model_file'] if 'model_consts' in row and row['model_consts']: model += ' -const ' + row['model_consts'] modelFilesFiltered.append(model) + # If there are any errors evaluating the exception, the filter is false + except (Exception): + pass # Restrict models list to ones in the list of filter matches for modelFile in modelFiles: if modelMatches(modelFile, modelFilesFiltered):