Repository: Project-MONAI/MONAI
File: monai/apps/auto3dseg/bundle_gen.py (Python)

Code before:
                            'num_trials': 6,
                            'range_num_images_per_batch': [1, 20],
                            'range_num_sw_batch_size': [1, 20]
                        }
                    }

            ALGO: the name of algorithm. It could be one of algorithm names (e.g., 'dints') or 'unversal' which
                would apply changes to all algorithms. Possible options are

                - {``"unversal"``, ``"dints"``, ``"segresnet"``, ``"segresnet2d"``, ``"swinunetr"``}.

            num_trials: the number of HPO trials/experiments to run.
            range_num_images_per_batch: the range of number of images per mini-batch.
            range_num_sw_batch_size: the range of batch size in sliding-window inferer.
        """
        fold_idx = list(range(num_fold))
        for algo in self.algos:
            for f_id in ensure_tuple(fold_idx):
                data_stats = self.get_data_stats()
                data_src_cfg = self.get_data_src()
                gen_algo = deepcopy(algo)
                gen_algo.set_data_stats(data_stats)
                gen_algo.set_data_source(data_src_cfg)
                name = f"{gen_algo.name}_{f_id}"
                gen_algo.pre_check_skip_algo()
                if not gen_algo.skip_bundlegen:
                    if gpu_customization:
                        gen_algo.export_to_disk(
                            output_folder,
                            name,
                            fold=f_id,
                            gpu_customization=True,
                            gpu_customization_specs=gpu_customization_specs,
                        )
                    else:
                        gen_algo.export_to_disk(output_folder, name, fold=f_id)

                    algo_to_pickle(gen_algo, template_path=algo.template_path)
                    self.history.append({name: gen_algo})  # track the previous, may create a persistent history
                else:
                    logger.info(f"{name} is skipped! Msg:{gen_algo.skip_info}")


Review comment (suggestion):
Maybe we can commit less line changes by:
```
if gen_algo.skip_bundlegen:
    log.info(...)
    continue

if gpu_customization:
    ...
```

Code after:
                        'ALOG': {
                            'num_trials': 6,
                            'range_num_images_per_batch': [1, 20],
                            'range_num_sw_batch_size': [1, 20]
                        }
                    }

            ALGO: the name of algorithm. It could be one of algorithm names (e.g., 'dints') or 'unversal' which
                would apply changes to all algorithms. Possible options are

                - {``"unversal"``, ``"dints"``, ``"segresnet"``, ``"segresnet2d"``, ``"swinunetr"``}.

            num_trials: the number of HPO trials/experiments to run.
            range_num_images_per_batch: the range of number of images per mini-batch.
            range_num_sw_batch_size: the range of batch size in sliding-window inferer.
        """
        fold_idx = list(range(num_fold))
        for algo in self.algos:
            for f_id in ensure_tuple(fold_idx):
                data_stats = self.get_data_stats()
                data_src_cfg = self.get_data_src()
                gen_algo = deepcopy(algo)
                gen_algo.set_data_stats(data_stats)
                gen_algo.set_data_source(data_src_cfg)
                name = f"{gen_algo.name}_{f_id}"
                skip_bundlegen, skip_info = gen_algo.pre_check_skip_algo()
                if skip_bundlegen:
                    logger.info(f"{name} is skipped! {skip_info}")
                    continue
                if gpu_customization:
                    gen_algo.export_to_disk(
                        output_folder,
                        name,
                        fold=f_id,
                        gpu_customization=True,
                        gpu_customization_specs=gpu_customization_specs,
                    )
                else:
                    gen_algo.export_to_disk(output_folder, name, fold=f_id)

                algo_to_pickle(gen_algo, template_path=algo.template_path)
                self.history.append({name: gen_algo})  # track the previous, may create a persistent history