diff --git a/changes/1499.stpipe.rst b/changes/1499.stpipe.rst new file mode 100644 index 000000000..fd937f567 --- /dev/null +++ b/changes/1499.stpipe.rst @@ -0,0 +1 @@ +Remove Step.__call__ usage (which will be deprecated in stpipe). diff --git a/docs/roman/outlier_detection/outlier_examples.rst b/docs/roman/outlier_detection/outlier_examples.rst index 1e8592f7e..9caef0733 100644 --- a/docs/roman/outlier_detection/outlier_examples.rst +++ b/docs/roman/outlier_detection/outlier_examples.rst @@ -14,7 +14,7 @@ the outlier detection step. # read the file list into a ModelLibrary object mc = ModelLibrary(["img_1.asdf", "img_2.asdf"]) step = OutlierDetectionStep() - step.process(mc) + step.run(mc) 2. To run the outlier detection step (with the default parameters) on an ASN file called "asn_sample.json" with the following content: @@ -56,7 +56,7 @@ the outlier detection step. # read the file list into a ModelLibrary object mc = ModelLibrary("asn_sample.json") step = OutlierDetectionStep() - step.process(mc) + step.run(mc) #. To run the outlier detection step (with the default parameters) on an ASN file called "asn_sample.json" (the files listed in the association file must have been diff --git a/docs/roman/stpipe/call_via_run.rst b/docs/roman/stpipe/call_via_run.rst index af839c1b1..014ef62f8 100644 --- a/docs/roman/stpipe/call_via_run.rst +++ b/docs/roman/stpipe/call_via_run.rst @@ -22,9 +22,6 @@ parameter file will be ignored. pipe.output_dir = '/my/data/pipeline_outputs' # Run the pipeline - result = pipe('r0000101001001001001_01101_0001_WFI01_uncal.asdf') - - # Or, execute the pipeline using the run method result = pipe.run('r0000101001001001001_01101_0001_WFI01_uncal.asdf') To run a single step: @@ -41,8 +38,5 @@ To run a single step: step.save_results = True step.output_dir = '/my/data/jump_data' - # Execute by calling the instance directly - result = step('r0000101001001001001_01101_0001_WFI01_linearity.asdf') - - # Or, execute using the run method + # Execute using the run method result = step.run('r0000101001001001001_01101_0001_WFI01_linearity.asdf') diff --git a/docs/roman/stpipe/user_pipeline.rst b/docs/roman/stpipe/user_pipeline.rst index d1eb71bc0..9176baf8c 100644 --- a/docs/roman/stpipe/user_pipeline.rst +++ b/docs/roman/stpipe/user_pipeline.rst @@ -183,10 +183,10 @@ step in the example above, one can do:: From Python ----------- -Once the pipeline has been configured (as above), just call the -instance to run it. +Once the pipeline has been configured (as above) it can be executed +using run. - pipe(input_data) + pipe.run(input_data) Caching details --------------- diff --git a/docs/roman/stpipe/user_step.rst b/docs/roman/stpipe/user_step.rst index 8cb8d3cbd..b50878603 100644 --- a/docs/roman/stpipe/user_step.rst +++ b/docs/roman/stpipe/user_step.rst @@ -243,8 +243,3 @@ the step. The previous example could be re-written as:: mystep = FlatFieldStep(override_sflat='sflat.asdf') output = mystep.run(input) - -Using the ``.run()`` method is the same as calling the instance directly. -They are equivalent:: - - output = mystep(input) diff --git a/docs/roman/tweakreg/tweakreg_examples.rst b/docs/roman/tweakreg/tweakreg_examples.rst index 032ffd5a5..d6beced2c 100644 --- a/docs/roman/tweakreg/tweakreg_examples.rst +++ b/docs/roman/tweakreg/tweakreg_examples.rst @@ -9,11 +9,11 @@ or a Roman datamodel `ImageModel`. from romancal.tweakreg.tweakreg_step import TweakRegStep step = TweakRegStep() - step.call([img]) + step.run([img]) .. note:: If the input is a single Roman ``DataModel``, - either ``step.call([img])`` or ``step.call(img)`` will work. For multiple elements as input, + either ``step.run([img])`` or ``step.run(img)`` will work. For multiple elements as input, they must be passed in as either a list or a ModelLibrary. #. To run TweakReg in a Python session on an association file with the default parameters: @@ -22,7 +22,7 @@ or a Roman datamodel `ImageModel`. from romancal.tweakreg.tweakreg_step import TweakRegStep step = TweakRegStep() - step.call("asn_file.json") + step.run("asn_file.json") #. To run TweakReg on a Roman's exposure with default astrometric parameters and save the absolute catalog data: @@ -34,7 +34,7 @@ or a Roman datamodel `ImageModel`. step.save_abs_catalog = True # save the catalog data used for absolute astrometry step.abs_refcat = 'GAIADR3' # use Gaia DR3 for absolute astrometry step.catalog_path = '/path/for/the/abs/catalog' # save the Gaia catalog to this path - step.call([img]) + step.run([img]) #. To run TweakReg using a custom source catalog with the default parameters: @@ -93,4 +93,4 @@ or a Roman datamodel `ImageModel`. step.use_custom_catalogs = True # use custom catalogs step.catalog_format = "ascii.ecsv" # custom catalogs format step.catfile = '/path/to/catfile/catfilename' # path to datamodel:catalog mapping - step.call([img]) + step.run([img]) diff --git a/romancal/outlier_detection/tests/test_outlier_detection.py b/romancal/outlier_detection/tests/test_outlier_detection.py index df60e3b6d..8ee91d9d0 100644 --- a/romancal/outlier_detection/tests/test_outlier_detection.py +++ b/romancal/outlier_detection/tests/test_outlier_detection.py @@ -115,7 +115,7 @@ def test_outlier_do_detection_write_files_to_custom_location(tmp_path, base_imag # set output dir for all files created by the step outlier_step.output_dir = tmp_path.as_posix() - outlier_step(input_models) + outlier_step.run(input_models) # meta.filename for the median image created by OutlierDetection.do_detection() median_path = tmp_path / "drizzled_median.asdf" @@ -183,7 +183,7 @@ def test_find_outliers(tmp_path, base_image, on_disk): # make sure files are written out to disk outlier_step.in_memory = not on_disk - result = outlier_step(input_models) + result = outlier_step.run(input_models) expected_crs = [img_0_input_coords, img_1_input_coords, None] with result: @@ -222,7 +222,7 @@ def test_identical_images(tmp_path, base_image, caplog): # make sure files are written out to disk outlier_step.in_memory = False - result = outlier_step(input_models) + result = outlier_step.run(input_models) # assert that log shows no new outliers detected assert "0 pixels marked as outliers" in {x.message for x in caplog.records} diff --git a/romancal/pipeline/exposure_pipeline.py b/romancal/pipeline/exposure_pipeline.py index 6fb029620..3dde01e25 100644 --- a/romancal/pipeline/exposure_pipeline.py +++ b/romancal/pipeline/exposure_pipeline.py @@ -124,12 +124,12 @@ def process(self, input): log.info(f"Processing a WFI exposure {input_filename}") self.dq_init.suffix = "dq_init" - result = self.dq_init(input) + result = self.dq_init.run(input) if input_filename: result.meta.filename = input_filename - result = self.saturation(result) + result = self.saturation.run(result) # Test for fully saturated data if is_fully_saturated(result): @@ -155,16 +155,16 @@ def process(self, input): results.append(result) return results - result = self.refpix(result) - result = self.linearity(result) - result = self.dark_current(result) - result = self.rampfit(result) - result = self.assign_wcs(result) + result = self.refpix.run(result) + result = self.linearity.run(result) + result = self.dark_current.run(result) + result = self.rampfit.run(result) + result = self.assign_wcs.run(result) if result.meta.exposure.type == "WFI_IMAGE": - result = self.flatfield(result) - result = self.photom(result) - result = self.source_catalog(result) + result = self.flatfield.run(result) + result = self.photom.run(result) + result = self.source_catalog.run(result) tweakreg_input.append(result) log.info( f"Number of models to tweakreg: {len(tweakreg_input), n_members}" @@ -185,7 +185,7 @@ def process(self, input): # Now that all the exposures are collated, run tweakreg # Note: this does not cover the case where the asn mixes imaging and spectral # observations. This should not occur on-prem - result = self.tweakreg(results) + result = self.tweakreg.run(results) log.info("Roman exposure calibration pipeline ending...") diff --git a/romancal/pipeline/mosaic_pipeline.py b/romancal/pipeline/mosaic_pipeline.py index f34b8c53c..0276225fe 100644 --- a/romancal/pipeline/mosaic_pipeline.py +++ b/romancal/pipeline/mosaic_pipeline.py @@ -72,11 +72,11 @@ def process(self, input): if file_type == "asn": input = ModelLibrary(input, on_disk=self.on_disk) self.flux.suffix = "flux" - result = self.flux(input) + result = self.flux.run(input) self.skymatch.suffix = "skymatch" - result = self.skymatch(result) + result = self.skymatch.run(result) self.outlier_detection.suffix = "outlier_detection" - result = self.outlier_detection(result) + result = self.outlier_detection.run(result) # # check to see if the product name contains a skycell name & if true get the skycell record product_name = input.asn["products"][0]["name"] @@ -131,9 +131,9 @@ def process(self, input): wcs_file = asdf.open(self.resample.output_wcs) self.suffix = "i2d" self.output_file = input.asn["products"][0]["name"] - result = self.resample(result) + result = self.resample.run(result) self.sourcecatalog.output_file = self.output_file - result_catalog = self.sourcecatalog(result) + result_catalog = self.sourcecatalog.run(result) else: log.info("resampling a mosaic file is not yet supported") exit(0) @@ -141,9 +141,9 @@ def process(self, input): else: self.resample.suffix = "i2d" self.output_file = input.asn["products"][0]["name"] - result = self.resample(result) + result = self.resample.run(result) self.sourcecatalog.output_file = self.output_file - result_catalog = self.sourcecatalog(result) # noqa: F841 + result_catalog = self.sourcecatalog.run(result) # noqa: F841 self.suffix = "i2d" if input_filename: result.meta.filename = self.output_file