-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
feat: Sqllab to Explore UX improvements api changes #11836
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b49d935
api changes needed for sqllab to explore improvements
hughhhh 354eb12
fix discrepancies
hughhhh 178a5b6
more diff
hughhhh 0b2d6c9
changes
hughhhh 36bb481
pull changes from master
hughhhh 949ecaa
change typing
hughhhh f002d47
add comments
hughhhh 7ddf9ea
fix this code
hughhhh 57ca09c
fix
hughhhh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
# under the License. | ||
import logging | ||
from datetime import datetime | ||
from distutils.util import strtobool | ||
from io import BytesIO | ||
from typing import Any | ||
from zipfile import ZipFile | ||
|
@@ -252,6 +253,10 @@ def put(self, pk: int) -> Response: | |
schema: | ||
type: integer | ||
name: pk | ||
- in: path | ||
schema: | ||
type: bool | ||
name: override_column | ||
requestBody: | ||
description: Dataset schema | ||
required: true | ||
|
@@ -284,6 +289,11 @@ def put(self, pk: int) -> Response: | |
500: | ||
$ref: '#/components/responses/500' | ||
""" | ||
override_columns = ( | ||
bool(strtobool(request.args["override_columns"])) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It makes me angry that |
||
if "override_columns" in request.args | ||
else False | ||
) | ||
if not request.is_json: | ||
return self.response_400(message="Request is not JSON") | ||
try: | ||
|
@@ -292,7 +302,9 @@ def put(self, pk: int) -> Response: | |
except ValidationError as error: | ||
return self.response_400(message=error.messages) | ||
try: | ||
changed_model = UpdateDatasetCommand(g.user, pk, item).run() | ||
changed_model = UpdateDatasetCommand( | ||
g.user, pk, item, override_columns | ||
).run() | ||
response = self.response(200, id=changed_model.id, result=item) | ||
except DatasetNotFoundError: | ||
response = self.response_404() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,17 +48,29 @@ | |
|
||
|
||
class UpdateDatasetCommand(BaseCommand): | ||
def __init__(self, user: User, model_id: int, data: Dict[str, Any]): | ||
def __init__( | ||
self, | ||
user: User, | ||
model_id: int, | ||
data: Dict[str, Any], | ||
override_columns: bool = False, | ||
): | ||
self._actor = user | ||
self._model_id = model_id | ||
self._properties = data.copy() | ||
self._model: Optional[SqlaTable] = None | ||
self.override_columns = override_columns | ||
|
||
def run(self) -> Model: | ||
self.validate() | ||
if self._model: | ||
try: | ||
dataset = DatasetDAO.update(self._model, self._properties) | ||
dataset = DatasetDAO.update( | ||
model=self._model, | ||
properties=self._properties, | ||
commit=True, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change threw me off because |
||
override_columns=self.override_columns, | ||
) | ||
return dataset | ||
except DAOUpdateFailedError as ex: | ||
logger.exception(ex.exception) | ||
|
@@ -123,14 +135,16 @@ def _validate_columns( | |
] | ||
if not DatasetDAO.validate_columns_exist(self._model_id, columns_ids): | ||
exceptions.append(DatasetColumnNotFoundValidationError()) | ||
|
||
# validate new column names uniqueness | ||
columns_names: List[str] = [ | ||
column["column_name"] for column in columns if "id" not in column | ||
] | ||
if not DatasetDAO.validate_columns_uniqueness( | ||
self._model_id, columns_names | ||
): | ||
exceptions.append(DatasetColumnsExistsValidationError()) | ||
if not self.override_columns: | ||
columns_names: List[str] = [ | ||
column["column_name"] for column in columns if "id" not in column | ||
] | ||
if not DatasetDAO.validate_columns_uniqueness( | ||
self._model_id, columns_names | ||
): | ||
exceptions.append(DatasetColumnsExistsValidationError()) | ||
|
||
def _validate_metrics( | ||
self, metrics: List[Dict[str, Any]], exceptions: List[ValidationError] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
override_columns