Skip to content

Commit

Permalink
Fix linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
reesercollins committed Jun 22, 2022
1 parent 2f8f3a4 commit 984ffe8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ const DatasetList: FunctionComponent<DatasetListProps> = ({
const openDatasetDuplicateModal = (dataset: VirtualDataset) => {
setDatasetCurrentlyDuplicating(dataset);
};

const handleBulkDatasetExport = (datasetsToExport: Dataset[]) => {
const ids = datasetsToExport.map(({ id }) => id);
handleResourceExport('dataset', ids, () => {
Expand Down
5 changes: 2 additions & 3 deletions superset/datasets/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@
from io import BytesIO
from typing import Any
from zipfile import is_zipfile, ZipFile
from numpy import save

import simplejson
from superset.datasets.commands.duplicate import DuplicateDatasetCommand
import yaml
from flask import g, make_response, request, Response, send_file
from flask_appbuilder.api import expose, protect, rison, safe
Expand All @@ -40,6 +38,7 @@
from superset.datasets.commands.bulk_delete import BulkDeleteDatasetCommand
from superset.datasets.commands.create import CreateDatasetCommand
from superset.datasets.commands.delete import DeleteDatasetCommand
from superset.datasets.commands.duplicate import DuplicateDatasetCommand
from superset.datasets.commands.exceptions import (
DatasetBulkDeleteFailedError,
DatasetCreateFailedError,
Expand Down Expand Up @@ -523,7 +522,7 @@ def export(self, **kwargs: Any) -> Response:
log_to_statsd=False,
)
@requires_json
def duplicate(self, **kwargs: Any) -> Response:
def duplicate(self) -> Response:
"""Duplicates a Dataset
---
post:
Expand Down
11 changes: 7 additions & 4 deletions superset/datasets/commands/duplicate.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

from superset.commands.base import BaseCommand, CreateMixin
from superset.commands.exceptions import DatasourceTypeInvalidError
from superset.connectors.sqla.models import SqlMetric, SqlaTable, TableColumn
from superset.connectors.sqla.models import SqlaTable, SqlMetric, TableColumn
from superset.dao.exceptions import DAOCreateFailedError
from superset.datasets.commands.exceptions import (
DatasetDuplicateFailedError,
Expand All @@ -36,7 +36,7 @@
from superset.datasets.dao import DatasetDAO
from superset.errors import ErrorLevel, SupersetError, SupersetErrorType
from superset.exceptions import SupersetErrorException
from superset.extensions import db, security_manager
from superset.extensions import db
from superset.models.core import Database
from superset.sql_parse import ParsedQuery

Expand All @@ -46,6 +46,7 @@
class DuplicateDatasetCommand(CreateMixin, BaseCommand):
def __init__(self, user: User, data: Dict[str, Any]):
self._actor = user
self._base_model: SqlaTable = SqlaTable()
self._properties = data.copy()

def run(self) -> Model:
Expand Down Expand Up @@ -108,9 +109,11 @@ def validate(self) -> None:
base_model_id = self._properties["base_model_id"]
duplicate_name = self._properties["table_name"]

self._base_model = DatasetDAO.find_by_id(base_model_id)
if not self._base_model:
base_model = DatasetDAO.find_by_id(base_model_id)
if not base_model:
exceptions.append(DatasetNotFoundError())
else:
self._base_model = base_model

if self._base_model and self._base_model.kind != "virtual":
exceptions.append(DatasourceTypeInvalidError())
Expand Down

0 comments on commit 984ffe8

Please sign in to comment.