Skip to content

Commit

Permalink
chore(command): Organize Commands according to SIP-92 (apache#25850)
Browse files Browse the repository at this point in the history
  • Loading branch information
john-bodley authored and sfirke committed Mar 22, 2024
1 parent c2af0bc commit d588f5b
Show file tree
Hide file tree
Showing 265 changed files with 786 additions and 808 deletions.
28 changes: 11 additions & 17 deletions superset/annotation_layers/annotations/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,24 @@
from flask_babel import ngettext
from marshmallow import ValidationError

from superset.annotation_layers.annotations.commands.create import (
CreateAnnotationCommand,
)
from superset.annotation_layers.annotations.commands.delete import (
DeleteAnnotationCommand,
)
from superset.annotation_layers.annotations.commands.exceptions import (
AnnotationCreateFailedError,
AnnotationDeleteFailedError,
AnnotationInvalidError,
AnnotationNotFoundError,
AnnotationUpdateFailedError,
)
from superset.annotation_layers.annotations.commands.update import (
UpdateAnnotationCommand,
)
from superset.annotation_layers.annotations.filters import AnnotationAllTextFilter
from superset.annotation_layers.annotations.schemas import (
AnnotationPostSchema,
AnnotationPutSchema,
get_delete_ids_schema,
openapi_spec_methods_override,
)
from superset.annotation_layers.commands.exceptions import AnnotationLayerNotFoundError
from superset.commands.annotation_layer.annotation.create import CreateAnnotationCommand
from superset.commands.annotation_layer.annotation.delete import DeleteAnnotationCommand
from superset.commands.annotation_layer.annotation.exceptions import (
AnnotationCreateFailedError,
AnnotationDeleteFailedError,
AnnotationInvalidError,
AnnotationNotFoundError,
AnnotationUpdateFailedError,
)
from superset.commands.annotation_layer.annotation.update import UpdateAnnotationCommand
from superset.commands.annotation_layer.exceptions import AnnotationLayerNotFoundError
from superset.constants import MODEL_API_RW_METHOD_PERMISSION_MAP, RouteMethod
from superset.models.annotations import Annotation
from superset.views.base_api import (
Expand Down
22 changes: 11 additions & 11 deletions superset/annotation_layers/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,24 @@
from flask_babel import ngettext
from marshmallow import ValidationError

from superset.annotation_layers.commands.create import CreateAnnotationLayerCommand
from superset.annotation_layers.commands.delete import DeleteAnnotationLayerCommand
from superset.annotation_layers.commands.exceptions import (
AnnotationLayerCreateFailedError,
AnnotationLayerDeleteFailedError,
AnnotationLayerDeleteIntegrityError,
AnnotationLayerInvalidError,
AnnotationLayerNotFoundError,
AnnotationLayerUpdateFailedError,
)
from superset.annotation_layers.commands.update import UpdateAnnotationLayerCommand
from superset.annotation_layers.filters import AnnotationLayerAllTextFilter
from superset.annotation_layers.schemas import (
AnnotationLayerPostSchema,
AnnotationLayerPutSchema,
get_delete_ids_schema,
openapi_spec_methods_override,
)
from superset.commands.annotation_layer.create import CreateAnnotationLayerCommand
from superset.commands.annotation_layer.delete import DeleteAnnotationLayerCommand
from superset.commands.annotation_layer.exceptions import (
AnnotationLayerCreateFailedError,
AnnotationLayerDeleteFailedError,
AnnotationLayerDeleteIntegrityError,
AnnotationLayerInvalidError,
AnnotationLayerNotFoundError,
AnnotationLayerUpdateFailedError,
)
from superset.commands.annotation_layer.update import UpdateAnnotationLayerCommand
from superset.constants import MODEL_API_RW_METHOD_PERMISSION_MAP, RouteMethod
from superset.extensions import event_logger
from superset.models.annotations import AnnotationLayer
Expand Down
30 changes: 15 additions & 15 deletions superset/charts/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,6 @@
from werkzeug.wsgi import FileWrapper

from superset import app, is_feature_enabled, thumbnail_cache
from superset.charts.commands.create import CreateChartCommand
from superset.charts.commands.delete import DeleteChartCommand
from superset.charts.commands.exceptions import (
ChartCreateFailedError,
ChartDeleteFailedError,
ChartForbiddenError,
ChartInvalidError,
ChartNotFoundError,
ChartUpdateFailedError,
DashboardsForbiddenError,
)
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.commands.warm_up_cache import ChartWarmUpCacheCommand
from superset.charts.filters import (
ChartAllTextFilter,
ChartCertifiedFilter,
Expand All @@ -69,6 +54,21 @@
screenshot_query_schema,
thumbnail_query_schema,
)
from superset.commands.chart.create import CreateChartCommand
from superset.commands.chart.delete import DeleteChartCommand
from superset.commands.chart.exceptions import (
ChartCreateFailedError,
ChartDeleteFailedError,
ChartForbiddenError,
ChartInvalidError,
ChartNotFoundError,
ChartUpdateFailedError,
DashboardsForbiddenError,
)
from superset.commands.chart.export import ExportChartsCommand
from superset.commands.chart.importers.dispatcher import ImportChartsCommand
from superset.commands.chart.update import UpdateChartCommand
from superset.commands.chart.warm_up_cache import ChartWarmUpCacheCommand
from superset.commands.exceptions import CommandException
from superset.commands.importers.exceptions import (
IncorrectFormatError,
Expand Down
16 changes: 8 additions & 8 deletions superset/charts/data/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@
from superset import is_feature_enabled, security_manager
from superset.async_events.async_query_manager import AsyncQueryTokenException
from superset.charts.api import ChartRestApi
from superset.charts.commands.exceptions import (
ChartDataCacheLoadError,
ChartDataQueryFailedError,
)
from superset.charts.data.commands.create_async_job_command import (
CreateAsyncChartDataJobCommand,
)
from superset.charts.data.commands.get_data_command import ChartDataCommand
from superset.charts.data.query_context_cache_loader import QueryContextCacheLoader
from superset.charts.post_processing import apply_post_process
from superset.charts.schemas import ChartDataQueryContextSchema
from superset.commands.chart.data.create_async_job_command import (
CreateAsyncChartDataJobCommand,
)
from superset.commands.chart.data.get_data_command import ChartDataCommand
from superset.commands.chart.exceptions import (
ChartDataCacheLoadError,
ChartDataQueryFailedError,
)
from superset.common.chart_data import ChartDataResultFormat, ChartDataResultType
from superset.connectors.sqla.models import BaseDatasource
from superset.daos.exceptions import DatasourceNotFound
Expand Down
2 changes: 1 addition & 1 deletion superset/charts/data/query_context_cache_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from typing import Any

from superset import cache
from superset.charts.commands.exceptions import ChartDataCacheLoadError
from superset.commands.chart.exceptions import ChartDataCacheLoadError


class QueryContextCacheLoader: # pylint: disable=too-few-public-methods
Expand Down
16 changes: 7 additions & 9 deletions superset/cli/importexport.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def import_directory(directory: str, overwrite: bool, force: bool) -> None:
def export_dashboards(dashboard_file: Optional[str] = None) -> None:
"""Export dashboards to ZIP file"""
# pylint: disable=import-outside-toplevel
from superset.dashboards.commands.export import ExportDashboardsCommand
from superset.commands.dashboard.export import ExportDashboardsCommand
from superset.models.dashboard import Dashboard

g.user = security_manager.find_user(username="admin")
Expand Down Expand Up @@ -106,8 +106,8 @@ def export_dashboards(dashboard_file: Optional[str] = None) -> None:
def export_datasources(datasource_file: Optional[str] = None) -> None:
"""Export datasources to ZIP file"""
# pylint: disable=import-outside-toplevel
from superset.commands.dataset.export import ExportDatasetsCommand
from superset.connectors.sqla.models import SqlaTable
from superset.datasets.commands.export import ExportDatasetsCommand

g.user = security_manager.find_user(username="admin")

Expand Down Expand Up @@ -144,10 +144,10 @@ def export_datasources(datasource_file: Optional[str] = None) -> None:
def import_dashboards(path: str, username: Optional[str]) -> None:
"""Import dashboards from ZIP file"""
# pylint: disable=import-outside-toplevel
from superset.commands.importers.v1.utils import get_contents_from_bundle
from superset.dashboards.commands.importers.dispatcher import (
from superset.commands.dashboard.importers.dispatcher import (
ImportDashboardsCommand,
)
from superset.commands.importers.v1.utils import get_contents_from_bundle

if username is not None:
g.user = security_manager.find_user(username=username)
Expand Down Expand Up @@ -176,10 +176,8 @@ def import_dashboards(path: str, username: Optional[str]) -> None:
def import_datasources(path: str) -> None:
"""Import datasources from ZIP file"""
# pylint: disable=import-outside-toplevel
from superset.commands.dataset.importers.dispatcher import ImportDatasetsCommand
from superset.commands.importers.v1.utils import get_contents_from_bundle
from superset.datasets.commands.importers.dispatcher import (
ImportDatasetsCommand,
)

if is_zipfile(path):
with ZipFile(path) as bundle:
Expand Down Expand Up @@ -304,7 +302,7 @@ def export_datasources(
def import_dashboards(path: str, recursive: bool, username: str) -> None:
"""Import dashboards from JSON file"""
# pylint: disable=import-outside-toplevel
from superset.dashboards.commands.importers.v0 import ImportDashboardsCommand
from superset.commands.dashboard.importers.v0 import ImportDashboardsCommand

path_object = Path(path)
files: list[Path] = []
Expand Down Expand Up @@ -353,7 +351,7 @@ def import_dashboards(path: str, recursive: bool, username: str) -> None:
def import_datasources(path: str, sync: str, recursive: bool) -> None:
"""Import datasources from YAML"""
# pylint: disable=import-outside-toplevel
from superset.datasets.commands.importers.v0 import ImportDatasetsCommand
from superset.commands.dataset.importers.v0 import ImportDatasetsCommand

sync_array = sync.split(",")
sync_columns = "columns" in sync_array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
from flask_appbuilder.models.sqla import Model
from marshmallow import ValidationError

from superset.annotation_layers.annotations.commands.exceptions import (
from superset.commands.annotation_layer.annotation.exceptions import (
AnnotationCreateFailedError,
AnnotationDatesValidationError,
AnnotationInvalidError,
AnnotationUniquenessValidationError,
)
from superset.annotation_layers.commands.exceptions import AnnotationLayerNotFoundError
from superset.commands.annotation_layer.exceptions import AnnotationLayerNotFoundError
from superset.commands.base import BaseCommand
from superset.daos.annotation import AnnotationDAO, AnnotationLayerDAO
from superset.daos.annotation_layer import AnnotationDAO, AnnotationLayerDAO
from superset.daos.exceptions import DAOCreateFailedError

logger = logging.getLogger(__name__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
import logging
from typing import Optional

from superset.annotation_layers.annotations.commands.exceptions import (
from superset.commands.annotation_layer.annotation.exceptions import (
AnnotationDeleteFailedError,
AnnotationNotFoundError,
)
from superset.commands.base import BaseCommand
from superset.daos.annotation import AnnotationDAO
from superset.daos.annotation_layer import AnnotationDAO
from superset.daos.exceptions import DAODeleteFailedError
from superset.models.annotations import Annotation

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@
from flask_appbuilder.models.sqla import Model
from marshmallow import ValidationError

from superset.annotation_layers.annotations.commands.exceptions import (
from superset.commands.annotation_layer.annotation.exceptions import (
AnnotationDatesValidationError,
AnnotationInvalidError,
AnnotationNotFoundError,
AnnotationUniquenessValidationError,
AnnotationUpdateFailedError,
)
from superset.annotation_layers.commands.exceptions import AnnotationLayerNotFoundError
from superset.commands.annotation_layer.exceptions import AnnotationLayerNotFoundError
from superset.commands.base import BaseCommand
from superset.daos.annotation import AnnotationDAO, AnnotationLayerDAO
from superset.daos.annotation_layer import AnnotationDAO, AnnotationLayerDAO
from superset.daos.exceptions import DAOUpdateFailedError
from superset.models.annotations import Annotation

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
from flask_appbuilder.models.sqla import Model
from marshmallow import ValidationError

from superset.annotation_layers.commands.exceptions import (
from superset.commands.annotation_layer.exceptions import (
AnnotationLayerCreateFailedError,
AnnotationLayerInvalidError,
AnnotationLayerNameUniquenessValidationError,
)
from superset.commands.base import BaseCommand
from superset.daos.annotation import AnnotationLayerDAO
from superset.daos.annotation_layer import AnnotationLayerDAO
from superset.daos.exceptions import DAOCreateFailedError

logger = logging.getLogger(__name__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
import logging
from typing import Optional

from superset.annotation_layers.commands.exceptions import (
from superset.commands.annotation_layer.exceptions import (
AnnotationLayerDeleteFailedError,
AnnotationLayerDeleteIntegrityError,
AnnotationLayerNotFoundError,
)
from superset.commands.base import BaseCommand
from superset.daos.annotation import AnnotationLayerDAO
from superset.daos.annotation_layer import AnnotationLayerDAO
from superset.daos.exceptions import DAODeleteFailedError
from superset.models.annotations import AnnotationLayer

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
from flask_appbuilder.models.sqla import Model
from marshmallow import ValidationError

from superset.annotation_layers.commands.exceptions import (
from superset.commands.annotation_layer.exceptions import (
AnnotationLayerInvalidError,
AnnotationLayerNameUniquenessValidationError,
AnnotationLayerNotFoundError,
AnnotationLayerUpdateFailedError,
)
from superset.commands.base import BaseCommand
from superset.daos.annotation import AnnotationLayerDAO
from superset.daos.annotation_layer import AnnotationLayerDAO
from superset.daos.exceptions import DAOUpdateFailedError
from superset.models.annotations import AnnotationLayer

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
from marshmallow import ValidationError

from superset import security_manager
from superset.charts.commands.exceptions import (
from superset.commands.base import BaseCommand, CreateMixin
from superset.commands.chart.exceptions import (
ChartCreateFailedError,
ChartInvalidError,
DashboardsForbiddenError,
DashboardsNotFoundValidationError,
)
from superset.commands.base import BaseCommand, CreateMixin
from superset.commands.utils import get_datasource_by_id
from superset.daos.chart import ChartDAO
from superset.daos.dashboard import DashboardDAO
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@

from flask_babel import gettext as _

from superset.charts.commands.exceptions import (
from superset.commands.base import BaseCommand
from superset.commands.chart.exceptions import (
ChartDataCacheLoadError,
ChartDataQueryFailedError,
)
from superset.commands.base import BaseCommand
from superset.common.query_context import QueryContext
from superset.exceptions import CacheLoadError

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
from flask_babel import lazy_gettext as _

from superset import security_manager
from superset.charts.commands.exceptions import (
from superset.commands.base import BaseCommand
from superset.commands.chart.exceptions import (
ChartDeleteFailedError,
ChartDeleteFailedReportsExistError,
ChartForbiddenError,
ChartNotFoundError,
)
from superset.commands.base import BaseCommand
from superset.daos.chart import ChartDAO
from superset.daos.exceptions import DAODeleteFailedError
from superset.daos.report import ReportScheduleDAO
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@

import yaml

from superset.charts.commands.exceptions import ChartNotFoundError
from superset.commands.chart.exceptions import ChartNotFoundError
from superset.daos.chart import ChartDAO
from superset.datasets.commands.export import ExportDatasetsCommand
from superset.commands.dataset.export import ExportDatasetsCommand
from superset.commands.export.models import ExportModelsCommand
from superset.models.slice import Slice
from superset.utils.dict_import_export import EXPORT_VERSION
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

from marshmallow.exceptions import ValidationError

from superset.charts.commands.importers import v1
from superset.commands.base import BaseCommand
from superset.commands.chart.importers import v1
from superset.commands.exceptions import CommandInvalidError
from superset.commands.importers.exceptions import IncorrectVersionError

Expand Down
Loading

0 comments on commit d588f5b

Please sign in to comment.