Skip to content

Commit 8d1090e

Browse files
committed
Fix analysis.R loading from gist, again
1 parent 0d0047f commit 8d1090e

File tree

4 files changed

+33
-4
lines changed

4 files changed

+33
-4
lines changed

gui/src/app/Project/FileMapping.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,10 @@ export const mapFileContentsToModel = (
102102

103103
fields.forEach((f) => {
104104
// Don't do anything for unrecognized filenames
105-
if (!isFileName(f)) return;
105+
if (!isFileName(f)) {
106+
console.warn(`Unrecognized filename: ${f}`);
107+
return;
108+
}
106109

107110
switch (f) {
108111
case FileNames.META: {

gui/src/app/Project/ProjectQueryLoading.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ export const fetchRemoteProject = async (query: QueryParams) => {
8888
false,
8989
);
9090
data.meta.title = contentLoadedFromGist.description;
91+
return persistStateToEphemera(data);
9192
} else {
9293
// right now we only support loading from a gist
9394
console.error("Unsupported project URI", projectUri);
@@ -105,7 +106,7 @@ export const fetchRemoteProject = async (query: QueryParams) => {
105106
: Promise.resolve(data.analysisPyFileContent);
106107
const analysisRFilePromise = query["analysis_r"]
107108
? tryFetch(query["analysis_r"])
108-
: Promise.resolve(data.analysisPyFileContent);
109+
: Promise.resolve(data.analysisRFileContent);
109110
const dataPyFilePromise = query["data_py"]
110111
? tryFetch(query["data_py"])
111112
: Promise.resolve(data.dataPyFileContent);

gui/src/app/Project/ProjectSerialization.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,8 @@ const loadFileFromString = (
138138
data: ProjectDataModel,
139139
field: ProjectKnownFiles,
140140
contents: string,
141-
replaceProject: boolean = false,
142141
): ProjectDataModel => {
143-
const newData = replaceProject ? { ...initialDataModel } : { ...data };
142+
const newData = { ...data };
144143
newData[field] = contents;
145144
return newData;
146145
};

gui/test/app/Project/ProjectQueryLoading.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ const hoistedMocks = vi.hoisted(() => {
4747
description: "gist discription",
4848
files: {
4949
"main.stan": "gist stan code",
50+
"data.json": '{"data": "gist data"}',
51+
"analysis.py": "gist analysis.py",
52+
"analysis.R": "gist analysis.R",
53+
"data.py": "gist data.py",
54+
"data.R": "gist data.R",
55+
"sampling_opts.json": JSON.stringify(mockedSamplingOpts),
56+
"extra.txt": "gist extra",
5057
},
5158
};
5259

@@ -297,6 +304,25 @@ describe("Query fetching", () => {
297304
expect(project.stanFileContent).toEqual("gist stan code");
298305
expect(project.ephemera.stanFileContent).toEqual("gist stan code");
299306
expect(project.meta.title).toEqual("gist discription");
307+
308+
expect(project.dataFileContent).toEqual('{"data": "gist data"}');
309+
expect(project.ephemera.dataFileContent).toEqual('{"data": "gist data"}');
310+
311+
expect(project.analysisPyFileContent).toEqual("gist analysis.py");
312+
expect(project.ephemera.analysisPyFileContent).toEqual(
313+
"gist analysis.py",
314+
);
315+
316+
expect(project.analysisRFileContent).toEqual("gist analysis.R");
317+
expect(project.ephemera.analysisRFileContent).toEqual("gist analysis.R");
318+
319+
expect(project.dataPyFileContent).toEqual("gist data.py");
320+
expect(project.ephemera.dataPyFileContent).toEqual("gist data.py");
321+
322+
expect(project.dataRFileContent).toEqual("gist data.R");
323+
expect(project.ephemera.dataRFileContent).toEqual("gist data.R");
324+
325+
expect(project.samplingOpts).toEqual(hoistedMocks.mockedSamplingOpts);
300326
});
301327
});
302328
});

0 commit comments

Comments
 (0)