diff --git a/pyglance/glance/compare.py b/pyglance/glance/compare.py index db4400a35868f6e71a93e4a88e72c9867f0c9eee..3fbdeb0ea098245b2485a77af73360b5b50ec98c 100644 --- a/pyglance/glance/compare.py +++ b/pyglance/glance/compare.py @@ -907,7 +907,7 @@ def reportGen_library_call (a_path, b_path, var_list=None, attributeInfo[B_FILE_TITLE_KEY] = bFile.file_object.get_variable_attributes(b_variable_technical_name) # pre-check if this data should be plotted and if it should be compared to the longitude and latitude - include_images_for_this_variable = ((not(DO_MAKE_IMAGES_KEY in runInfo)) or (runInfo[DO_MAKE_IMAGES_KEY])) + include_images_for_this_variable = ((DO_MAKE_IMAGES_KEY not in runInfo) or (runInfo[DO_MAKE_IMAGES_KEY])) if DO_MAKE_IMAGES_KEY in varRunInfo : include_images_for_this_variable = varRunInfo[DO_MAKE_IMAGES_KEY] do_not_test_with_lon_lat = (not include_images_for_this_variable) or (len(lon_lat_data) <= 0) @@ -965,11 +965,13 @@ def reportGen_library_call (a_path, b_path, var_list=None, varRunInfo[DID_VARIABLE_PASS_KEY] = didPass # update the overall pass status if didPass is not None : - didPassAll = didPassAll & didPass + didPassAll = didPassAll and didPass # based on the settings and whether the variable passed or failed, # should we include images for this variable? - if (DO_IMAGES_ONLY_ON_FAIL_KEY in varRunInfo) and varRunInfo[DO_IMAGES_ONLY_ON_FAIL_KEY] : + temp_images_only_on_fail = runInfo[DO_IMAGES_ONLY_ON_FAIL_KEY] if DO_IMAGES_ONLY_ON_FAIL_KEY in runInfo else False + temp_images_only_on_fail = varRunInfo[DO_IMAGES_ONLY_ON_FAIL_KEY] if DO_IMAGES_ONLY_ON_FAIL_KEY in varRunInfo else temp_images_only_on_fail + if temp_images_only_on_fail : include_images_for_this_variable = include_images_for_this_variable and (not didPass) varRunInfo[DO_MAKE_IMAGES_KEY] = include_images_for_this_variable diff --git a/pyglance/glance/config_organizer.py b/pyglance/glance/config_organizer.py index 8847504efb45eb6e2ebb990e41638aedc19d0777..0eb529de8db4fdb55ab9d30a6af53298d7bd57ab 100644 --- a/pyglance/glance/config_organizer.py +++ b/pyglance/glance/config_organizer.py @@ -415,6 +415,7 @@ def load_config_or_options(aPath, bPath, optionsSet, requestedVars = [ ]) : # so get everything from the options directly runInfo[DO_MAKE_REPORT_KEY] = not optionsSet[OPTIONS_NO_REPORT_KEY] runInfo[DO_MAKE_IMAGES_KEY] = not optionsSet[OPTIONS_NO_IMAGES_KEY] + runInfo[DO_IMAGES_ONLY_ON_FAIL_KEY] = optionsSet[OPTIONS_IMAGES_ON_FAIL_KEY] runInfo[DO_MAKE_FORKS_KEY] = optionsSet[DO_MAKE_FORKS_KEY] # only record these if we are using lon/lat @@ -430,6 +431,7 @@ def load_config_or_options(aPath, bPath, optionsSet, requestedVars = [ ]) : # user selected defaults defaultsToUse[EPSILON_KEY] = optionsSet[EPSILON_KEY] if EPSILON_KEY in optionsSet else None defaultsToUse[FILL_VALUE_KEY] = optionsSet[OPTIONS_FILL_VALUE_KEY] + defaultsToUse[DO_IMAGES_ONLY_ON_FAIL_KEY] = optionsSet[DO_IMAGES_ONLY_ON_FAIL_KEY] # note: there is no way to set the tolerances from the command line @@ -530,12 +532,15 @@ def parse_arguments (version_string, commands_list, commands_help_text, ) : # output generation related options parser.add_argument('-p', '--outputpath', dest=OPTIONS_OUTPUT_PATH_KEY, type=str, default='./', help="set path to the output directory (default: %(default)s)") - parser.add_argument('-i', '--imagesonly', dest=OPTIONS_NO_REPORT_KEY, - action="store_true", default=False, - help="generate only the images (no html report)") parser.add_argument('-r', '--reportonly', dest=OPTIONS_NO_IMAGES_KEY, action="store_true", default=False, help="generate only the html report (no images)") + parser.add_argument('-i', '--imagesonly', dest=OPTIONS_NO_REPORT_KEY, + action="store_true", default=False, + help="generate only the images (no html report)") + parser.add_argument('-u', '--imagesonlyonfailure', dest=OPTIONS_IMAGES_ON_FAIL_KEY, + action="store_true", default=False, + help="generate images only when a variable fails comparison (no images for passing variables)") parser.add_argument('-c', '--configfile', dest=OPTIONS_CONFIG_FILE_KEY, type=str, default=None, help="set a configuration file to load (default: %(default)s)") parser.add_argument('--stripfromname', default=[], dest=OPTIONS_RE_TO_STRIP_KEY, action='append', @@ -605,6 +610,7 @@ def convert_options_to_dict (options) : tempOptions[OPTIONS_CONFIG_FILE_KEY] = clean_path(options.configFile) tempOptions[OPTIONS_NO_REPORT_KEY] = options.imagesOnly tempOptions[OPTIONS_NO_IMAGES_KEY] = options.htmlOnly + tempOptions[OPTIONS_IMAGES_ON_FAIL_KEY] = options.only_plot_on_fail tempOptions[OPTIONS_RE_TO_STRIP_KEY] = options.regularExpressionsToStrip # whether or not to do pass fail testing diff --git a/pyglance/glance/constants.py b/pyglance/glance/constants.py index 0cbb45126eded5bd412862e63ede085713a83141..57285bb7590edf4682f9d1d8fd58805ef55dbd51 100644 --- a/pyglance/glance/constants.py +++ b/pyglance/glance/constants.py @@ -221,6 +221,7 @@ OPTIONS_OUTPUT_PATH_KEY = 'outputpath' OPTIONS_CONFIG_FILE_KEY = 'configFile' OPTIONS_NO_REPORT_KEY = 'imagesOnly' OPTIONS_NO_IMAGES_KEY = 'htmlOnly' +OPTIONS_IMAGES_ON_FAIL_KEY = 'only_plot_on_fail' OPTIONS_LAT_VAR_NAME_KEY = 'latitudeVar' OPTIONS_LON_VAR_NAME_KEY = 'longitudeVar' OPTIONS_LONLAT_EPSILON_KEY = 'lonlatepsilon'