Skip to content

Commit

Permalink
TEST: remove duck-typing in save
Browse files Browse the repository at this point in the history
  • Loading branch information
braingram committed Jun 12, 2024
1 parent b6c94f8 commit 66cb508
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions src/stpipe/step.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,25 +519,10 @@ def run(self, *args):
for idx, result in enumerate(results_to_save):
if len(results_to_save) <= 1:
idx = None
if isinstance(result, AbstractDataModel):
self.save_model(result, idx=idx, format=self.name_format)
elif hasattr(result, "save"):
try:
output_path = self.make_output_path(
idx=idx, name_format=self.name_format
)
except AttributeError:
self.log.warning(
"`save_results` has been requested, but cannot"
" determine filename."
)
self.log.warning(
"Specify an output file with `--output_file` or set"
" `--save_results=false`"
)
else:
self.log.info("Saving file %s", output_path)
result.save(output_path, overwrite=True)
if not isinstance(result, AbstractDataModel):

Check warning on line 522 in src/stpipe/step.py

View check run for this annotation

Codecov / codecov/patch

src/stpipe/step.py#L522

Added line #L522 was not covered by tests
# what has a "save"? Does anything ever reach this code
raise Exception(f"Something has a save: {result}")
self.save_model(result, idx=idx, format=self.name_format)

Check warning on line 525 in src/stpipe/step.py

View check run for this annotation

Codecov / codecov/patch

src/stpipe/step.py#L524-L525

Added lines #L524 - L525 were not covered by tests

if not self.skip:
self.log.info("Step %s done", self.name)
Expand Down

0 comments on commit 66cb508

Please sign in to comment.