You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To address the issue of exporting dashboards using the CLI in Superset 3.1.1 when the 'admin' user is not created, you can modify the export_dashboards function to include a -u option. This allows you to specify a different admin account. Here is the updated function:
@click.command()@with_appcontext@click.option("--dashboard-file","-f",help="Specify the file to export to",)@click.option("--username","-u",required=True,help="Specify the user name to use for exporting dashboards",)defexport_dashboards(dashboard_file: Optional[str] =None, username: Optional[str] =None) ->None:
"""Export dashboards to ZIP file"""fromsuperset.commands.dashboard.exportimportExportDashboardsCommandfromsuperset.models.dashboardimportDashboardg.user=security_manager.find_user(username=username)
dashboard_ids= [id_for (id_,) indb.session.query(Dashboard.id).all()]
timestamp=datetime.now().strftime("%Y%m%dT%H%M%S")
root=f"dashboard_export_{timestamp}"dashboard_file=dashboard_fileorf"{root}.zip"try:
withZipFile(dashboard_file, "w") asbundle:
forfile_name, file_contentinExportDashboardsCommand(dashboard_ids).run():
withbundle.open(f"{root}/{file_name}", "w") asfp:
fp.write(file_content().encode())
exceptException:
logger.exception(
"There was an error when exporting the dashboards, please check ""the exception traceback in the log"
)
sys.exit(1)
This modification allows you to specify a different admin account using the -u option when exporting dashboards [1].
Additionally, there are existing command-line options in the Superset CLI that allow specifying a user for other commands, such as importing dashboards and datasources. These options are implemented using the --username or -u flag [1].
However, the current tests for the export_dashboards function do not cover scenarios where the 'admin' user does not exist. All tests assume the existence of the 'admin' user [2][3].
Details
About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
Bug description
Hello,
with Superset 3.1.1, I can't export dashboards with CLI if 'admin' user is not created
There should be a -u option to specify the admin account to use
Actually, on all branchs, 'admin' is hard coded :
https://github.com/apache/superset/blob/master/superset/cli/importexport.py
Best regards
How to reproduce the bug
I have an admin user 'xavier’ (user 'admin' is not created)
If I export / import from web app with user ‘xavier’, it's OK
with CLI, I have an error "AttributeError: 'NoneType' object has no attribute 'is_anonymous'"
To succed, user 'admin' must exist
Screenshots/recordings
No response
Superset version
master / latest-dev
Python version
3.9
Node version
16
Browser
Chrome
Additional context
No response
Checklist
The text was updated successfully, but these errors were encountered: