diff --git a/looper/looper.py b/looper/looper.py index 53004c91..a120eebb 100755 --- a/looper/looper.py +++ b/looper/looper.py @@ -242,35 +242,37 @@ def __call__(self, args, preview_flag=True): :param bool preview_flag: whether to halt before actually removing files """ - _LOGGER.info("Removing results:") - - for sample in select_samples(prj=self.prj, args=args): - _LOGGER.info(self.counter.show(sample.sample_name)) - sample_output_folder = sample_folder(self.prj, sample) - if preview_flag: - # Preview: Don't actually delete, just show files. - _LOGGER.info(str(sample_output_folder)) - else: - _remove_or_dry_run(sample_output_folder, args.dry_run) - - _LOGGER.info("Removing summary:") use_pipestat = ( self.prj.pipestat_configured_project - if getattr( - args, "project", None - ) # TODO this argument hasn't been added to the pydantic models. + if getattr(args, "project", None) else self.prj.pipestat_configured ) + if use_pipestat: + _LOGGER.info("Removing summary:") destroy_summary( self.prj, getattr(args, "dry_run", None), getattr(args, "project", None), ) - else: - _LOGGER.warning( - "Pipestat must be configured to destroy any created summaries." - ) + + _LOGGER.info("Removing results:") + + for sample in select_samples(prj=self.prj, args=args): + _LOGGER.info(self.counter.show(sample.sample_name)) + sample_output_folder = sample_folder(self.prj, sample) + if preview_flag: + # Preview: Don't actually delete, just show files. + _LOGGER.info(str(sample_output_folder)) + else: + if use_pipestat: + psms = self.prj.get_pipestat_managers( + sample_name=sample.sample_name + ) + for pipeline_name, psm in psms.items(): + psm.remove(record_identifier=sample.sample_name) + else: + _remove_or_dry_run(sample_output_folder, args.dry_run) if not preview_flag: _LOGGER.info("Destroy complete.")