-
Notifications
You must be signed in to change notification settings - Fork 13.8k
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
Bad export filenames #30308
Comments
Hey @FraterCRC! I'm here to help you with any bugs, questions, or contributions you have for Superset. Let's tackle this together! To address the issue where non-English model names result in filenames like '_{id}' that are not exported, you can modify the import unicodedata
import re
from werkzeug.utils import secure_filename
def slugify(value: str) -> str:
value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore').decode('ascii')
value = re.sub(r'[^\w\s-]', '', value).strip().lower()
return re.sub(r'[-\s]+', '-', value)
def get_filename(model_name: str, model_id: int, skip_id: bool = False) -> str:
slug = slugify(model_name)
filename = slug if skip_id else f"{slug}_{model_id}"
return filename if slug else str(model_id) This In the context of Superset, you can see that the |
Assigning to @yousoph since she's been taking stock of what is/isn't being exported properly. |
Looks closely related to #22118, see the discussion in comments there - is @EugeneTorap still actively contributing to Superset? |
Bug description
If you have a model with name in any other than english language you get filename '_{id}' which will not be exported
it is obvious from this code
def get_filename(model_name: str, model_id: int, skip_id: bool = False) -> str:
slug = secure_filename(model_name)
filename = slug if skip_id else f"{slug}_{model_id}"
return filename if slug else str(model_id)
How to reproduce the bug
Screenshots/recordings
No response
Superset version
master / latest-dev
Python version
3.9
Node version
16
Browser
Safari
Additional context
Suggest to do smthing like:
def get_filename(model_name: str, model_id: int, skip_id: bool = False) -> str:
slug = secure_filename(model_name)
slug = slug.replace('-', '').lstrip()
filename = f"{slug}_{model_id}" if slug else "{model_id}"
return filename
Checklist
The text was updated successfully, but these errors were encountered: