From c62a486164a968680c8bcb3b24e73d67679e275a Mon Sep 17 00:00:00 2001 From: shayaharon Date: Mon, 10 Jul 2023 16:24:54 +0300 Subject: [PATCH] moved exceptions from training --- .../{training => common}/exceptions/dataset_exceptions.py | 0 .../{training => common}/exceptions/kd_trainer_exceptions.py | 0 .../{training => common}/exceptions/loss_exceptions.py | 0 .../{training => common}/exceptions/sg_trainer_exceptions.py | 0 .../datasets/detection_datasets/coco_format_detection.py | 2 +- .../training/datasets/detection_datasets/detection_dataset.py | 2 +- src/super_gradients/training/datasets/mixup.py | 2 +- src/super_gradients/training/exceptions/__init__.py | 0 src/super_gradients/training/kd_trainer/kd_trainer.py | 2 +- src/super_gradients/training/losses/ohem_ce_loss.py | 2 +- src/super_gradients/training/sg_trainer/sg_trainer.py | 2 +- src/super_gradients/training/utils/sg_trainer_utils.py | 2 +- tests/integration_tests/detection_dataset_test.py | 2 +- tests/unit_tests/detection_dataset_test.py | 2 +- tests/unit_tests/detection_sub_classing_test.py | 2 +- 15 files changed, 10 insertions(+), 10 deletions(-) rename src/super_gradients/{training => common}/exceptions/dataset_exceptions.py (100%) rename src/super_gradients/{training => common}/exceptions/kd_trainer_exceptions.py (100%) rename src/super_gradients/{training => common}/exceptions/loss_exceptions.py (100%) rename src/super_gradients/{training => common}/exceptions/sg_trainer_exceptions.py (100%) delete mode 100644 src/super_gradients/training/exceptions/__init__.py diff --git a/src/super_gradients/training/exceptions/dataset_exceptions.py b/src/super_gradients/common/exceptions/dataset_exceptions.py similarity index 100% rename from src/super_gradients/training/exceptions/dataset_exceptions.py rename to src/super_gradients/common/exceptions/dataset_exceptions.py diff --git a/src/super_gradients/training/exceptions/kd_trainer_exceptions.py b/src/super_gradients/common/exceptions/kd_trainer_exceptions.py similarity index 100% rename from src/super_gradients/training/exceptions/kd_trainer_exceptions.py rename to src/super_gradients/common/exceptions/kd_trainer_exceptions.py diff --git a/src/super_gradients/training/exceptions/loss_exceptions.py b/src/super_gradients/common/exceptions/loss_exceptions.py similarity index 100% rename from src/super_gradients/training/exceptions/loss_exceptions.py rename to src/super_gradients/common/exceptions/loss_exceptions.py diff --git a/src/super_gradients/training/exceptions/sg_trainer_exceptions.py b/src/super_gradients/common/exceptions/sg_trainer_exceptions.py similarity index 100% rename from src/super_gradients/training/exceptions/sg_trainer_exceptions.py rename to src/super_gradients/common/exceptions/sg_trainer_exceptions.py diff --git a/src/super_gradients/training/datasets/detection_datasets/coco_format_detection.py b/src/super_gradients/training/datasets/detection_datasets/coco_format_detection.py index fc4fe12b3f..cef97f767c 100644 --- a/src/super_gradients/training/datasets/detection_datasets/coco_format_detection.py +++ b/src/super_gradients/training/datasets/detection_datasets/coco_format_detection.py @@ -9,7 +9,7 @@ from contextlib import redirect_stdout from super_gradients.common.abstractions.abstract_logger import get_logger from super_gradients.training.datasets.detection_datasets.detection_dataset import DetectionDataset -from super_gradients.training.exceptions.dataset_exceptions import DatasetValidationException, ParameterMismatchException +from super_gradients.common.exceptions.dataset_exceptions import DatasetValidationException, ParameterMismatchException from super_gradients.training.datasets.data_formats.default_formats import XYXY_LABEL logger = get_logger(__name__) diff --git a/src/super_gradients/training/datasets/detection_datasets/detection_dataset.py b/src/super_gradients/training/datasets/detection_datasets/detection_dataset.py index 6f9c44e34a..08a493459d 100644 --- a/src/super_gradients/training/datasets/detection_datasets/detection_dataset.py +++ b/src/super_gradients/training/datasets/detection_datasets/detection_dataset.py @@ -19,7 +19,7 @@ from super_gradients.training.utils.detection_utils import get_cls_posx_in_target from super_gradients.common.abstractions.abstract_logger import get_logger from super_gradients.training.transforms.transforms import DetectionTransform, DetectionTargetsFormatTransform, DetectionTargetsFormat -from super_gradients.training.exceptions.dataset_exceptions import EmptyDatasetException, DatasetValidationException +from super_gradients.common.exceptions.dataset_exceptions import EmptyDatasetException, DatasetValidationException from super_gradients.common.factories.list_factory import ListFactory from super_gradients.common.factories.transforms_factory import TransformsFactory from super_gradients.training.datasets.data_formats.default_formats import XYXY_LABEL diff --git a/src/super_gradients/training/datasets/mixup.py b/src/super_gradients/training/datasets/mixup.py index f905ae82c4..c2ec595cfb 100644 --- a/src/super_gradients/training/datasets/mixup.py +++ b/src/super_gradients/training/datasets/mixup.py @@ -16,7 +16,7 @@ import torch from super_gradients.common.registry.registry import register_collate_function -from super_gradients.training.exceptions.dataset_exceptions import IllegalDatasetParameterException +from super_gradients.common.exceptions.dataset_exceptions import IllegalDatasetParameterException def one_hot(x, num_classes, on_value=1.0, off_value=0.0, device="cuda"): diff --git a/src/super_gradients/training/exceptions/__init__.py b/src/super_gradients/training/exceptions/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/super_gradients/training/kd_trainer/kd_trainer.py b/src/super_gradients/training/kd_trainer/kd_trainer.py index 3cce2373d2..fde032a3d2 100644 --- a/src/super_gradients/training/kd_trainer/kd_trainer.py +++ b/src/super_gradients/training/kd_trainer/kd_trainer.py @@ -9,7 +9,7 @@ from super_gradients.common.abstractions.abstract_logger import get_logger from super_gradients.training import utils as core_utils, models from super_gradients.training.dataloaders import dataloaders -from super_gradients.training.exceptions.kd_trainer_exceptions import ( +from super_gradients.common.exceptions.kd_trainer_exceptions import ( ArchitectureKwargsException, UnsupportedKDArchitectureException, InconsistentParamsException, diff --git a/src/super_gradients/training/losses/ohem_ce_loss.py b/src/super_gradients/training/losses/ohem_ce_loss.py index 80f91f327c..45a517d667 100644 --- a/src/super_gradients/training/losses/ohem_ce_loss.py +++ b/src/super_gradients/training/losses/ohem_ce_loss.py @@ -1,7 +1,7 @@ import torch from torch import nn from torch.nn.modules.loss import _Loss -from super_gradients.training.exceptions.loss_exceptions import IllegalRangeForLossAttributeException, RequiredLossComponentReductionException +from super_gradients.common.exceptions.loss_exceptions import IllegalRangeForLossAttributeException, RequiredLossComponentReductionException class OhemLoss(_Loss): diff --git a/src/super_gradients/training/sg_trainer/sg_trainer.py b/src/super_gradients/training/sg_trainer/sg_trainer.py index 61d5893897..87b0710b2e 100755 --- a/src/super_gradients/training/sg_trainer/sg_trainer.py +++ b/src/super_gradients/training/sg_trainer/sg_trainer.py @@ -39,7 +39,7 @@ from super_gradients.training import utils as core_utils, models, dataloaders from super_gradients.training.datasets.samplers import RepeatAugSampler -from super_gradients.training.exceptions.sg_trainer_exceptions import UnsupportedOptimizerFormat +from super_gradients.common.exceptions.sg_trainer_exceptions import UnsupportedOptimizerFormat from super_gradients.training.metrics.metric_utils import ( get_metrics_titles, get_metrics_results_tuple, diff --git a/src/super_gradients/training/utils/sg_trainer_utils.py b/src/super_gradients/training/utils/sg_trainer_utils.py index 29df3deef1..03f8c957b0 100644 --- a/src/super_gradients/training/utils/sg_trainer_utils.py +++ b/src/super_gradients/training/utils/sg_trainer_utils.py @@ -18,7 +18,7 @@ from torch.utils.tensorboard import SummaryWriter from super_gradients.common.environment.device_utils import device_config -from super_gradients.training.exceptions.dataset_exceptions import UnsupportedBatchItemsFormat +from super_gradients.common.exceptions.dataset_exceptions import UnsupportedBatchItemsFormat from super_gradients.common.data_types.enum import MultiGPUMode diff --git a/tests/integration_tests/detection_dataset_test.py b/tests/integration_tests/detection_dataset_test.py index b06dc67a0c..3c633b00f6 100644 --- a/tests/integration_tests/detection_dataset_test.py +++ b/tests/integration_tests/detection_dataset_test.py @@ -14,7 +14,7 @@ from super_gradients.training.datasets import PascalVOCDetectionDataset, COCODetectionDataset from super_gradients.training.transforms import DetectionMosaic, DetectionPaddedRescale, DetectionTargetsFormatTransform from super_gradients.training.datasets.data_formats.default_formats import XYXY_LABEL -from super_gradients.training.exceptions.dataset_exceptions import EmptyDatasetException +from super_gradients.common.exceptions.dataset_exceptions import EmptyDatasetException from super_gradients.common.environment.path_utils import normalize_path diff --git a/tests/unit_tests/detection_dataset_test.py b/tests/unit_tests/detection_dataset_test.py index 74caeaeba4..6e6efdd523 100644 --- a/tests/unit_tests/detection_dataset_test.py +++ b/tests/unit_tests/detection_dataset_test.py @@ -10,7 +10,7 @@ from super_gradients.training.datasets import COCODetectionDataset from super_gradients.training.datasets.data_formats.default_formats import LABEL_CXCYWH from super_gradients.training.datasets.datasets_conf import COCO_DETECTION_CLASSES_LIST -from super_gradients.training.exceptions.dataset_exceptions import DatasetValidationException, ParameterMismatchException +from super_gradients.common.exceptions.dataset_exceptions import DatasetValidationException, ParameterMismatchException from super_gradients.training.metrics import DetectionMetrics from super_gradients.training.models import YoloXPostPredictionCallback from super_gradients.training.transforms import DetectionMosaic, DetectionTargetsFormatTransform, DetectionPaddedRescale diff --git a/tests/unit_tests/detection_sub_classing_test.py b/tests/unit_tests/detection_sub_classing_test.py index fbc599c217..e4a97c21cf 100644 --- a/tests/unit_tests/detection_sub_classing_test.py +++ b/tests/unit_tests/detection_sub_classing_test.py @@ -3,7 +3,7 @@ from super_gradients.training.datasets import DetectionDataset from super_gradients.training.utils.detection_utils import DetectionTargetsFormat -from super_gradients.training.exceptions.dataset_exceptions import EmptyDatasetException, DatasetValidationException +from super_gradients.common.exceptions.dataset_exceptions import EmptyDatasetException, DatasetValidationException class DummyDetectionDataset(DetectionDataset):