msyavuz opened a new pull request, #43763:
URL: https://github.com/apache/superset/pull/43763

   ### SUMMARY
   
   Deployments that attach their own metadata to charts and dashboards — an 
owning team, a catalogue entry, a folder — have no way to make it survive an 
export/import round trip. The only options today are forking the export 
commands or monkeypatching their internals, both of which break silently on 
upgrade.
   
   This adds two optional config hooks, alongside the existing 
`EXTRA_OWNERS_RESOLVER` and `AFTER_ASSET_CREATE`:
   
   - `EXTRA_ASSET_EXPORT_FIELDS(model, asset_type) -> dict` — serialised under 
the `extra` key of the exported YAML
   - `EXTRA_ASSET_IMPORT_HANDLER(model, asset_type, extra)` — called once the 
asset exists on import
   
   Everything is namespaced under a single `extra` key rather than merged at 
the top level. The import schemas reject unknown fields (marshmallow defaults 
to `RAISE`), so one declared field per asset type preserves that strictness 
while leaving the payload shape free to evolve without further schema changes.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   No UI. With `EXTRA_ASSET_EXPORT_FIELDS` configured, the exported YAML gains:
   
   ```yaml
   slice_name: Revenue by region
   ...
   extra:
     owning_team: analytics-platform
   ```
   
   With neither hook configured, exported files are byte-for-byte unchanged.
   
   ### TESTING INSTRUCTIONS
   
   `pytest tests/unit_tests/commands/extra_asset_fields_test.py` — 6 cases 
covering both hooks, a hook returning `None`, an empty `extra` being skipped, 
and the schemas accepting the field.
   
   End to end: set `EXTRA_ASSET_EXPORT_FIELDS`/`EXTRA_ASSET_IMPORT_HANDLER` in 
`superset_config.py` per the docs added here, export a chart or dashboard, 
confirm the `extra` block, then re-import and confirm the handler is called 
with the mapping.
   
   ### ADDITIONAL INFORMATION
   
   - [ ] Has associated issue: No
   - [ ] Required feature flags: None — both hooks default to `None`
   - [ ] Changes UI: No, backend only
   - [ ] Includes DB Migration: No
   - [x] Introduces new feature or API: two optional config hooks, documented 
in `docs/admin_docs/configuration/configuring-superset.mdx`
   - [ ] Removes existing feature or API: No
   
   Verified locally: 1364 passed / 2 xfailed across 
`tests/unit_tests/{commands,dashboards,charts}`, and `pre-commit run` clean 
including mypy.


-- 
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]

Reply via email to