Comments (1)
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",
)
def export_dashboards(dashboard_file: Optional[str] = None, username: Optional[str] = None) -> None:
"""Export dashboards to ZIP file"""
from superset.commands.dashboard.export import ExportDashboardsCommand
from superset.models.dashboard import Dashboard
g.user = security_manager.find_user(username=username)
dashboard_ids = [id_ for (id_,) in db.session.query(Dashboard.id).all()]
timestamp = datetime.now().strftime("%Y%m%dT%H%M%S")
root = f"dashboard_export_{timestamp}"
dashboard_file = dashboard_file or f"{root}.zip"
try:
with ZipFile(dashboard_file, "w") as bundle:
for file_name, file_content in ExportDashboardsCommand(dashboard_ids).run():
with bundle.open(f"{root}/{file_name}", "w") as fp:
fp.write(file_content().encode())
except Exception:
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.
To continue the conversation, mention @dosu.
from superset.
Related Issues (20)
- 50 - Deprecate the KV_STORE feature flag HOT 3
- [SIP-137] Can we limit a user to only read certain tables in the database connection? HOT 6
- SPAM
- Version 4.0.1: Unable to adjust the size of a chart in a dashboard when the chart touches the right edge of the dashboard HOT 4
- SPAM
- SPAM
- SPAM
- SPAM
- SPAM
- SPAM
- SPAM
- SPAM
- SPAM
- SPAM
- Default native filters values don't set correctly HOT 1
- Superset 4.0.1 - Exported CSV Contains Garbled Chinese Characters and Numbers HOT 10
- Metric datatype incorrect when swap dataset HOT 1
- It is proposed to add the feature of grouping like folders HOT 3
- TimeSeries Chart is showing Year for the January month HOT 5
- Storybook controls are out of date HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from superset.