Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(dao): Organize DAOs according to SIP-92 #24331

Merged
merged 1 commit into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
AnnotationBulkDeleteFailedError,
AnnotationNotFoundError,
)
from superset.annotation_layers.annotations.dao import AnnotationDAO
from superset.commands.base import BaseCommand
from superset.dao.exceptions import DAODeleteFailedError
from superset.daos.annotation import AnnotationDAO
from superset.daos.exceptions import DAODeleteFailedError
from superset.models.annotations import Annotation

logger = logging.getLogger(__name__)
Expand Down
5 changes: 2 additions & 3 deletions superset/annotation_layers/annotations/commands/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@
AnnotationInvalidError,
AnnotationUniquenessValidationError,
)
from superset.annotation_layers.annotations.dao import AnnotationDAO
from superset.annotation_layers.commands.exceptions import AnnotationLayerNotFoundError
from superset.annotation_layers.dao import AnnotationLayerDAO
from superset.commands.base import BaseCommand
from superset.dao.exceptions import DAOCreateFailedError
from superset.daos.annotation import AnnotationDAO, AnnotationLayerDAO
from superset.daos.exceptions import DAOCreateFailedError

logger = logging.getLogger(__name__)

Expand Down
4 changes: 2 additions & 2 deletions superset/annotation_layers/annotations/commands/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
AnnotationDeleteFailedError,
AnnotationNotFoundError,
)
from superset.annotation_layers.annotations.dao import AnnotationDAO
from superset.commands.base import BaseCommand
from superset.dao.exceptions import DAODeleteFailedError
from superset.daos.annotation import AnnotationDAO
from superset.daos.exceptions import DAODeleteFailedError
from superset.models.annotations import Annotation

logger = logging.getLogger(__name__)
Expand Down
5 changes: 2 additions & 3 deletions superset/annotation_layers/annotations/commands/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@
AnnotationUniquenessValidationError,
AnnotationUpdateFailedError,
)
from superset.annotation_layers.annotations.dao import AnnotationDAO
from superset.annotation_layers.commands.exceptions import AnnotationLayerNotFoundError
from superset.annotation_layers.dao import AnnotationLayerDAO
from superset.commands.base import BaseCommand
from superset.dao.exceptions import DAOUpdateFailedError
from superset.daos.annotation import AnnotationDAO, AnnotationLayerDAO
from superset.daos.exceptions import DAOUpdateFailedError
from superset.models.annotations import Annotation

logger = logging.getLogger(__name__)
Expand Down
64 changes: 0 additions & 64 deletions superset/annotation_layers/annotations/dao.py

This file was deleted.

4 changes: 2 additions & 2 deletions superset/annotation_layers/commands/bulk_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
AnnotationLayerBulkDeleteIntegrityError,
AnnotationLayerNotFoundError,
)
from superset.annotation_layers.dao import AnnotationLayerDAO
from superset.commands.base import BaseCommand
from superset.dao.exceptions import DAODeleteFailedError
from superset.daos.annotation import AnnotationLayerDAO
from superset.daos.exceptions import DAODeleteFailedError
from superset.models.annotations import AnnotationLayer

logger = logging.getLogger(__name__)
Expand Down
4 changes: 2 additions & 2 deletions superset/annotation_layers/commands/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
AnnotationLayerInvalidError,
AnnotationLayerNameUniquenessValidationError,
)
from superset.annotation_layers.dao import AnnotationLayerDAO
from superset.commands.base import BaseCommand
from superset.dao.exceptions import DAOCreateFailedError
from superset.daos.annotation import AnnotationLayerDAO
from superset.daos.exceptions import DAOCreateFailedError

logger = logging.getLogger(__name__)

Expand Down
4 changes: 2 additions & 2 deletions superset/annotation_layers/commands/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
AnnotationLayerDeleteIntegrityError,
AnnotationLayerNotFoundError,
)
from superset.annotation_layers.dao import AnnotationLayerDAO
from superset.commands.base import BaseCommand
from superset.dao.exceptions import DAODeleteFailedError
from superset.daos.annotation import AnnotationLayerDAO
from superset.daos.exceptions import DAODeleteFailedError
from superset.models.annotations import AnnotationLayer

logger = logging.getLogger(__name__)
Expand Down
4 changes: 2 additions & 2 deletions superset/annotation_layers/commands/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
AnnotationLayerNotFoundError,
AnnotationLayerUpdateFailedError,
)
from superset.annotation_layers.dao import AnnotationLayerDAO
from superset.commands.base import BaseCommand
from superset.dao.exceptions import DAOUpdateFailedError
from superset.daos.annotation import AnnotationLayerDAO
from superset.daos.exceptions import DAOUpdateFailedError
from superset.models.annotations import AnnotationLayer

logger = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion superset/charts/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
from superset.charts.commands.export import ExportChartsCommand
from superset.charts.commands.importers.dispatcher import ImportChartsCommand
from superset.charts.commands.update import UpdateChartCommand
from superset.charts.dao import ChartDAO
from superset.charts.filters import (
ChartAllTextFilter,
ChartCertifiedFilter,
Expand Down Expand Up @@ -75,6 +74,7 @@
)
from superset.commands.importers.v1.utils import get_contents_from_bundle
from superset.constants import MODEL_API_RW_METHOD_PERMISSION_MAP, RouteMethod
from superset.daos.chart import ChartDAO
from superset.extensions import event_logger
from superset.models.slice import Slice
from superset.tasks.thumbnails import cache_chart_thumbnail
Expand Down
4 changes: 2 additions & 2 deletions superset/charts/commands/bulk_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
ChartForbiddenError,
ChartNotFoundError,
)
from superset.charts.dao import ChartDAO
from superset.commands.base import BaseCommand
from superset.commands.exceptions import DeleteFailedError
from superset.daos.chart import ChartDAO
from superset.daos.report import ReportScheduleDAO
from superset.exceptions import SupersetSecurityException
from superset.models.slice import Slice
from superset.reports.dao import ReportScheduleDAO

logger = logging.getLogger(__name__)

Expand Down
6 changes: 3 additions & 3 deletions superset/charts/commands/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
ChartInvalidError,
DashboardsNotFoundValidationError,
)
from superset.charts.dao import ChartDAO
from superset.commands.base import BaseCommand, CreateMixin
from superset.commands.utils import get_datasource_by_id
from superset.dao.exceptions import DAOCreateFailedError
from superset.dashboards.dao import DashboardDAO
from superset.daos.chart import ChartDAO
from superset.daos.dashboard import DashboardDAO
from superset.daos.exceptions import DAOCreateFailedError

logger = logging.getLogger(__name__)

Expand Down
6 changes: 3 additions & 3 deletions superset/charts/commands/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
ChartForbiddenError,
ChartNotFoundError,
)
from superset.charts.dao import ChartDAO
from superset.commands.base import BaseCommand
from superset.dao.exceptions import DAODeleteFailedError
from superset.daos.chart import ChartDAO
from superset.daos.exceptions import DAODeleteFailedError
from superset.daos.report import ReportScheduleDAO
from superset.exceptions import SupersetSecurityException
from superset.models.dashboard import Dashboard
from superset.models.slice import Slice
from superset.reports.dao import ReportScheduleDAO

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion superset/charts/commands/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import yaml

from superset.charts.commands.exceptions import ChartNotFoundError
from superset.charts.dao import ChartDAO
from superset.daos.chart import ChartDAO
from superset.datasets.commands.export import ExportDatasetsCommand
from superset.commands.export.models import ExportModelsCommand
from superset.models.slice import Slice
Expand Down
2 changes: 1 addition & 1 deletion superset/charts/commands/importers/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@

from superset.charts.commands.exceptions import ChartImportError
from superset.charts.commands.importers.v1.utils import import_chart
from superset.charts.dao import ChartDAO
from superset.charts.schemas import ImportV1ChartSchema
from superset.commands.importers.v1 import ImportModelsCommand
from superset.connectors.sqla.models import SqlaTable
from superset.daos.chart import ChartDAO
from superset.databases.commands.importers.v1.utils import import_database
from superset.databases.schemas import ImportV1DatabaseSchema
from superset.datasets.commands.importers.v1.utils import import_dataset
Expand Down
6 changes: 3 additions & 3 deletions superset/charts/commands/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
DashboardsNotFoundValidationError,
DatasourceTypeUpdateRequiredValidationError,
)
from superset.charts.dao import ChartDAO
from superset.commands.base import BaseCommand, UpdateMixin
from superset.commands.utils import get_datasource_by_id
from superset.dao.exceptions import DAOUpdateFailedError
from superset.dashboards.dao import DashboardDAO
from superset.daos.chart import ChartDAO
from superset.daos.dashboard import DashboardDAO
from superset.daos.exceptions import DAOUpdateFailedError
from superset.exceptions import SupersetSecurityException
from superset.models.slice import Slice

Expand Down
2 changes: 1 addition & 1 deletion superset/charts/data/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
from superset.charts.schemas import ChartDataQueryContextSchema
from superset.common.chart_data import ChartDataResultFormat, ChartDataResultType
from superset.connectors.base.models import BaseDatasource
from superset.dao.exceptions import DatasourceNotFound
from superset.daos.exceptions import DatasourceNotFound
from superset.exceptions import QueryObjectValidationError
from superset.extensions import event_logger
from superset.models.sql_lab import Query
Expand Down
2 changes: 1 addition & 1 deletion superset/commands/export/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

from superset.commands.base import BaseCommand
from superset.commands.exceptions import CommandException
from superset.dao.base import BaseDAO
from superset.daos.base import BaseDAO
from superset.utils.dict_import_export import EXPORT_VERSION

METADATA_FILE_NAME = "metadata.yaml"
Expand Down
2 changes: 1 addition & 1 deletion superset/commands/importers/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
METADATA_FILE_NAME,
validate_metadata_type,
)
from superset.dao.base import BaseDAO
from superset.daos.base import BaseDAO
from superset.models.core import Database


Expand Down
2 changes: 1 addition & 1 deletion superset/commands/importers/v1/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from superset.charts.schemas import ImportV1ChartSchema
from superset.commands.exceptions import CommandException
from superset.commands.importers.v1 import ImportModelsCommand
from superset.dao.base import BaseDAO
from superset.daos.base import BaseDAO
from superset.dashboards.commands.importers.v1 import ImportDashboardsCommand
from superset.dashboards.commands.importers.v1.utils import (
find_chart_uuids,
Expand Down
4 changes: 2 additions & 2 deletions superset/commands/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
OwnersNotFoundValidationError,
RolesNotFoundValidationError,
)
from superset.dao.exceptions import DatasourceNotFound
from superset.datasource.dao import DatasourceDAO
from superset.daos.datasource import DatasourceDAO
from superset.daos.exceptions import DatasourceNotFound
from superset.extensions import db
from superset.utils.core import DatasourceType, get_user_id

Expand Down
4 changes: 2 additions & 2 deletions superset/common/query_context_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
from typing import Any, TYPE_CHECKING

from superset import app, db
from superset.charts.dao import ChartDAO
from superset.common.chart_data import ChartDataResultFormat, ChartDataResultType
from superset.common.query_context import QueryContext
from superset.common.query_object import QueryObject
from superset.common.query_object_factory import QueryObjectFactory
from superset.datasource.dao import DatasourceDAO
from superset.daos.chart import ChartDAO
from superset.daos.datasource import DatasourceDAO
from superset.models.slice import Slice
from superset.utils.core import DatasourceDict, DatasourceType

Expand Down
4 changes: 2 additions & 2 deletions superset/common/query_context_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
from typing_extensions import TypedDict

from superset import app
from superset.annotation_layers.dao import AnnotationLayerDAO
from superset.charts.dao import ChartDAO
from superset.common.chart_data import ChartDataResultFormat
from superset.common.db_query_status import QueryStatus
from superset.common.query_actions import get_query_results
Expand All @@ -38,6 +36,8 @@
from superset.common.utils.time_range_utils import get_since_until_from_query_object
from superset.connectors.base.models import BaseDatasource
from superset.constants import CacheRegion, TimeGrain
from superset.daos.annotation import AnnotationLayerDAO
from superset.daos.chart import ChartDAO
from superset.exceptions import (
InvalidPostProcessingError,
QueryObjectValidationError,
Expand Down
2 changes: 1 addition & 1 deletion superset/common/query_object_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from sqlalchemy.orm import sessionmaker

from superset.connectors.base.models import BaseDatasource
from superset.datasource.dao import DatasourceDAO
from superset.daos.datasource import DatasourceDAO


class QueryObjectFactory: # pylint: disable=too-few-public-methods
Expand Down
2 changes: 1 addition & 1 deletion superset/connectors/sqla/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1439,8 +1439,8 @@ def before_update(
"""

# pylint: disable=import-outside-toplevel
from superset.daos.dataset import DatasetDAO
from superset.datasets.commands.exceptions import get_dataset_exist_error_msg
from superset.datasets.dao import DatasetDAO

# Check whether the relevant attributes have changed.
state = db.inspect(target) # pylint: disable=no-member
Expand Down
4 changes: 2 additions & 2 deletions superset/css_templates/commands/bulk_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
CssTemplateBulkDeleteFailedError,
CssTemplateNotFoundError,
)
from superset.css_templates.dao import CssTemplateDAO
from superset.dao.exceptions import DAODeleteFailedError
from superset.daos.css import CssTemplateDAO
from superset.daos.exceptions import DAODeleteFailedError
from superset.models.core import CssTemplate

logger = logging.getLogger(__name__)
Expand Down
File renamed without changes.
Loading