A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
fix: altair rendering with baseUrl (#1601)
Myles Scolnick422c45d215eb
diff --git a/frontend/src/plugins/impl/vega/loader.ts b/frontend/src/plugins/impl/vega/loader.tsindex 87049e87d9..8f0f73b119 100644--- a/frontend/src/plugins/impl/vega/loader.ts+++ b/frontend/src/plugins/impl/vega/loader.ts@@ -96,7 +96,9 @@ export function vegaLoadData(): Promise<object[]> {const { handleBigInt = false, replacePeriod = false } = opts;- return vegaLoader.load(url).then((csvData) => {+ const isCsv = format?.type === "csv";++ return vegaLoader.load(url).then((csvOrJsonData) => {// CSV data comes columnar and may have duplicate column names.// We need to uniquify the column names before parsing since vega-loader// returns an array of objects which drops duplicate keys.@@ -104,13 +106,13 @@ export function vegaLoadData(// We make the column names unique by appending a number to the end of// each duplicate column name. If we want to preserve the original key// we would need to store the data in columnar format.- if (typeof csvData === "string") {- csvData = uniquifyColumnNames(csvData);+ if (isCsv && typeof csvOrJsonData === "string") {+ csvOrJsonData = uniquifyColumnNames(csvOrJsonData);}// Replace periods in column names with a one-dot leader.// Some downstream libraries use periods as a nested key separator.- if (typeof csvData === "string" && replacePeriod) {- csvData = replacePeriodsInColumnNames(csvData);+ if (isCsv && typeof csvOrJsonData === "string" && replacePeriod) {+ csvOrJsonData = replacePeriodsInColumnNames(csvOrJsonData);}// We support enabling/disabling since the Table enables it@@ -120,14 +122,13 @@ export function vegaLoadData(}// Always set parse to auto for csv data, to be able to parse dates and floats- const results =- format && format.type === "csv"- ? // csv -> json- read(csvData, {- ...format,- parse: (format.parse as FieldTypes) || "auto",- })- : read(csvData, format);+ const results = isCsv+ ? // csv -> json+ read(csvOrJsonData, {+ ...format,+ parse: (format.parse as FieldTypes) || "auto",+ })+ : read(csvOrJsonData, format);if (handleBigInt) {disableBigInt();diff --git a/frontend/src/utils/__tests__/url.test.ts b/frontend/src/utils/__tests__/url.test.tsindex 4349db8156..cad36ac945 100644--- a/frontend/src/utils/__tests__/url.test.ts+++ b/frontend/src/utils/__tests__/url.test.ts@@ -49,7 +49,9 @@ describe("asURL function", () => {test('should handle relative path starting with "./"', () => {const path = "./path/to/resource";const result = asURL(path);- expect(result.toString()).toBe("https://example.com/path/to/resource");+ expect(result.toString()).toBe(+ "https://example.com/base/path/to/resource",+ );});test('should handle absolute path starting with "/"', () => {diff --git a/frontend/src/utils/url.ts b/frontend/src/utils/url.tsindex 4b4592d8bf..2a18d2ff03 100644--- a/frontend/src/utils/url.ts+++ b/frontend/src/utils/url.ts@@ -9,7 +9,7 @@*/export function asURL(path: string): URL {if (path.startsWith("./")) {- return new URL(path.slice(1), document.baseURI);+ return new URL(path, document.baseURI);}if (path.startsWith("/")) {