rusackas commented on code in PR #36538:
URL: https://github.com/apache/superset/pull/36538#discussion_r2621629628
##########
superset/examples/helpers.py:
##########
@@ -119,52 +88,91 @@ def get_slice_json(defaults: dict[Any, Any], **kwargs:
Any) -> str:
return json.dumps(defaults_copy, indent=4, sort_keys=True)
-def get_example_url(filepath: str) -> str:
- """Return an absolute URL to *filepath* under the examples‑data repo.
-
- All calls are routed through jsDelivr unless overridden. Supports nested
- paths like ``datasets/examples/slack/messages.csv``.
- """
- return f"{BASE_URL}{filepath}"
+def normalize_example_data_url(url: str) -> str:
+ """Normalize example data URLs for consistency.
+ This function ensures that example data URLs are properly formatted.
+ Since the schema validator expects valid URLs and our examples:// protocol
+ isn't standard, we convert to file:// URLs pointing to the actual location.
-def normalize_example_data_url(url: str) -> str:
- """Convert example data URLs to use the configured CDN.
+ Args:
+ url: URL to normalize (e.g., "examples://birth_names" or
"birth_names.duckdb")
- Transforms examples:// URLs to the configured CDN URL.
- Non-example URLs are returned unchanged.
+ Returns:
+ Normalized file:// URL pointing to the DuckDB file
"""
+ import os
+
+ # Handle existing examples:// protocol
if url.startswith(EXAMPLES_PROTOCOL):
- relative_path = url[len(EXAMPLES_PROTOCOL) :]
- return get_example_url(relative_path)
+ # Remove the protocol for processing
+ path = url[len(EXAMPLES_PROTOCOL) :]
+ elif url.startswith("file://"):
+ # Already a file URL, just return it
+ return url
+ else:
Review Comment:
Valid concern. The else branch incorrectly treats HTTP/HTTPS URLs as local
paths. Fix pushed.
--
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]