diff --git a/changes/1433.ramp_fitting.rst b/changes/1433.ramp_fitting.rst new file mode 100644 index 000000000..f65d5b185 --- /dev/null +++ b/changes/1433.ramp_fitting.rst @@ -0,0 +1 @@ +Remove custom log messages for dms requirements (which are now mapped by the json file). diff --git a/romancal/lib/dms.py b/romancal/lib/dms.py deleted file mode 100644 index 20ecaaa06..000000000 --- a/romancal/lib/dms.py +++ /dev/null @@ -1,27 +0,0 @@ -"""Functionality required by DMS outside of core functionality of the package - -Example: Certain tests are required by DMS to log in a specific way. The -decorator for this is defined in this module. -""" - -from stpipe import log as stpipe_log - - -def log_result(requirement, message, result): - """Log individual test results that relate to a requirement - - Parameters - ---------- - requirement : str - The requirement being logged. I.e "DMS363" - - message : str - Message describing what is being tested - - result : bool - The result of the test - """ - logger = stpipe_log.delegator.log - result_text = "PASS" if result else "FAIL" - log_msg = f"{requirement} MSG: {message}.......{result_text}" - logger.info(log_msg) diff --git a/romancal/regtest/test_ramp_fitting.py b/romancal/regtest/test_ramp_fitting.py index 1eb8dbec3..2669b54d6 100644 --- a/romancal/regtest/test_ramp_fitting.py +++ b/romancal/regtest/test_ramp_fitting.py @@ -1,9 +1,4 @@ """ Module to test rampfit with optional output - -Notes ------ -A requirement for the larger mission verification project is to have -tests tied to reqirements. """ from pathlib import Path @@ -11,7 +6,6 @@ import pytest import roman_datamodels as rdm -from romancal.lib.dms import log_result from romancal.lib.suffix import replace_suffix from romancal.ramp_fitting import RampFitStep @@ -21,64 +15,53 @@ # ########## # Conditions # ########## -def cond_is_asdf(requirement, model, expected_path): +def cond_is_asdf(model, expected_path): """Check that the filename has the correct file type""" msg = 'Testing that result file path has file type "asdf"' result = expected_path.exists() and expected_path.suffix == ".asdf" - log_result(requirement, msg, result) assert result, msg -def cond_is_imagemodel(requirement, model, expected_path): +def cond_is_imagemodel(model, expected_path): """Check that the result is an ImageModel""" msg = "Testing that the result model is Level 2" result = isinstance(model, rdm.datamodels.ImageModel) - log_result(requirement, msg, result) assert result, msg -def cond_is_rampfit(requirement, model, expected_path): +def cond_is_rampfit(model, expected_path): """Check that the calibration suffix is 'rampfit'""" msg = 'Testing that the result file has the suffix "rampfit"' result = expected_path.exists() and expected_path.stem.endswith("rampfit") - log_result(requirement, msg, result) assert result, msg -def cond_is_step_complete(requirement, model, expected_path): +def cond_is_step_complete(model, expected_path): """Check that the calibration step is marked complete""" msg = "Testing that RampFitStep completed" result = model.meta.cal_step.ramp_fit == "COMPLETE" - log_result(requirement, msg, result) assert result, msg -def cond_is_truncated(requirement, model, expected_path): +def cond_is_truncated(model, expected_path): """Check if the data represents a truncated MA table/read pattern""" msg = "Testing if data represents a truncated MA table" result = model.meta.exposure.truncated - log_result(requirement, msg, result) assert result, msg -def cond_is_uneven(requirement, model, expected_path): +def cond_is_uneven(model, expected_path): """Verify that the provided model represents uneven ramps""" msg = "Testing that the ramps are uneven" length_set = {len(resultant) for resultant in model.meta.exposure.read_pattern} result = len(length_set) > 1 - log_result(requirement, msg, result) assert result, msg -def cond_science_verification( - requirement, model, expected_path, rtdata_module, ignore_asdf_paths -): +def cond_science_verification(model, expected_path, rtdata_module, ignore_asdf_paths): """Check against expected data results""" - msg = "Testing science veracity" diff = compare_asdf(rtdata_module.output, rtdata_module.truth, **ignore_asdf_paths) - result = diff.identical - log_result(requirement, msg, result) assert result, diff.report() @@ -99,22 +82,18 @@ def cond_science_verification( scope="module", params=[ ( - "DMS362", Path("WFI/image/r0000101001001001001_01101_0001_WFI01_darkcurrent.asdf"), CONDITIONS_FULL, ), ( - "DMS366", Path("WFI/grism/r0000201001001001001_01101_0001_WFI01_darkcurrent.asdf"), CONDITIONS_FULL, ), ( - "DMS363", Path("WFI/image/r0000101001001001001_01101_0003_WFI01_darkcurrent.asdf"), CONDITIONS_TRUNC, ), ( - "DMS367", Path("WFI/grism/r0000201001001001001_01101_0003_WFI01_darkcurrent.asdf"), CONDITIONS_TRUNC, ), @@ -135,7 +114,7 @@ def rampfit_result(request, rtdata_module): Model and path to model. """ # Setup inputs - requirement, artifactory_path, conditions = request.param + artifactory_path, conditions = request.param input_data = rtdata_module.get_data(str(artifactory_path)) rtdata_module.input = input_data @@ -153,7 +132,7 @@ def rampfit_result(request, rtdata_module): rtdata_module.get_truth(str(output_artifactory_path)) try: - yield requirement, result_model, expected_path, conditions + yield result_model, expected_path, conditions finally: result_model.close() @@ -171,18 +150,18 @@ def passfail(bool_expr): @pytest.mark.bigdata def test_rampfit_step(rampfit_result, rtdata_module, ignore_asdf_paths): """Test rampfit result against various conditions""" - requirement, model, expected_path, conditions = rampfit_result + model, expected_path, conditions = rampfit_result error_msgs = [] for condition in conditions: try: - condition(requirement, model, expected_path) + condition(model, expected_path) except AssertionError as e: error_msgs.append(str(e)) # Always do a full regression check. try: cond_science_verification( - requirement, model, expected_path, rtdata_module, ignore_asdf_paths + model, expected_path, rtdata_module, ignore_asdf_paths ) except AssertionError as e: error_msgs.append(str(e))