withnale opened a new issue, #32987:
URL: https://github.com/apache/superset/issues/32987
### Bug description
The export format that superset generates should be as clean as possible to
make it easy to take an export and use it in multiple scenarios. This should
generate a predictable export where things only change when the actual resource
is changed. Some parts of the dashboard export logic make use of random which
hinders this goal.
If you look at a simple dashboard export you will see sections in the export
similar to this:
```yaml
position:
CHART-2oF-uUdrSO:
children: []
id: CHART-2oF-uUdrSO
meta:
chartId: 392
height: 20
sliceName: My Wonderful Chart
uuid: 812bc377-ac09-475a-8d34-a63f7f087bd7
width: 2
parents:
- ROOT_ID
- GRID_ID
- ROW-DOiwK0ZZha
type: CHART
CHART-6c90Bu_yvV:
children: []
id: CHART-6c90Bu_yvV
meta:
chartId: 529
height: 20
sliceName: Another Wonderful Chart
uuid: 5b738061-5575-4689-b8d1-267c699e456e
width: 2
parents:
- ROOT_ID
- GRID_ID
- ROW-DOiwK0ZZha
type: CHART
```
However if we look at the export methods, the values `CHART-2oF-uUdrSO` and
`CHART-6c90Bu_yvV` are generated by the following code snippet (from
`superset/commands/dashboard/export.py` ):
```python
def suffix(length: int = 8) -> str:
return "".join(
random.SystemRandom().choice(string.ascii_uppercase + string.digits)
for _ in range(length)
)
def append_charts(position: dict[str, Any], charts: set[Slice]) -> dict[str,
Any]:
chart_hashes = [f"CHART-{suffix()}" for _ in charts]
```
Is there an easy way to make this predictable? Considering at present a
chart can only appear on a dashboard once, is there a downside to making this
`CHART-{chart.uuid}` ? Or considering the same issue I assume exists for the
`ROW-` blocks, maybe generating a predicable key based on ordered traversal
from `ROOT-ID`.
### Screenshots/recordings
_No response_
### Superset version
master / latest-dev
### Python version
3.9
### Node version
16
### Browser
Chrome
### Additional context
_No response_
### Checklist
- [ ] I have searched Superset docs and Slack and didn't find a solution to
my problem.
- [ ] I have searched the GitHub issue tracker and didn't find a similar bug
report.
- [ ] I have checked Superset's logs for errors and if I found a relevant
Python stacktrace, I included it here as text in the "additional context"
section.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]