diff --git a/gui/src/app/SamplerOutputView/SamplerOutputView.tsx b/gui/src/app/SamplerOutputView/SamplerOutputView.tsx index 4b79ab24..eaa5a4a5 100644 --- a/gui/src/app/SamplerOutputView/SamplerOutputView.tsx +++ b/gui/src/app/SamplerOutputView/SamplerOutputView.tsx @@ -13,7 +13,7 @@ import TracePlotsView from "./TracePlotsView"; type SamplerOutputViewProps = { width: number; height: number; - sampler: StanSampler; + sampler: StanSampler | undefined; }; const SamplerOutputView: FunctionComponent = ({ @@ -25,6 +25,7 @@ const SamplerOutputView: FunctionComponent = ({ useSamplerOutput(sampler); if (!draws || !paramNames || !numChains) return ; + if (!sampler) return No sampler; return ( = ({ const getScriptHeaderForEmptyDraws = () => { return ` -class _SPSampling: - def __init__(self): - self.draws = [] - self.parameter_names = [] - self.num_chains = 0 -sp_sampling = _SPSampling() +raise Exception("You must run the sampler before executing the analysis script.") `; +// return ` +// class _SPSampling: +// def __init__(self): +// self.draws = [] +// self.parameter_names = [] +// self.num_chains = 0 +// sp_sampling = _SPSampling() +// `; }; const getScriptHeaderForNonemptyDraws = () => { diff --git a/gui/src/app/pages/HomePage/HomePage.tsx b/gui/src/app/pages/HomePage/HomePage.tsx index a60fc88d..ed7ac5e7 100644 --- a/gui/src/app/pages/HomePage/HomePage.tsx +++ b/gui/src/app/pages/HomePage/HomePage.tsx @@ -18,9 +18,6 @@ import { import LeftPanel from "./LeftPanel"; import SamplingWindow from "./SamplingWindow/SamplingWindow"; import TopBar from "./TopBar"; -import TabWidget from "../../TabWidget/TabWidget"; -import AnalysisPyWindow from "./AnalysisPyWindow/AnalysisPyWindow"; -import StanSampler from "../../StanSampler/StanSampler"; type Props = { width: number; @@ -143,55 +140,17 @@ type RightViewProps = { compiledMainJsUrl: string; }; -const tabs = [ - { - id: "sampling", - label: "Sampling", - title: "Run sampling and view draws", - closeable: false, - }, - { - id: "analysis.py", - label: "Analysis (Py)", - title: "Python analysis", - closeable: false, - }, - { - id: "analysis.r", - label: "Analysis (R)", - title: "R analysis", - closeable: false, - }, -]; - const RightView: FunctionComponent = ({ width, height, compiledMainJsUrl, }) => { - const [currentTabId, setCurrentTabId] = useState("sampling"); - const [stanSampler, setStanSampler] = useState(null); return ( - - - -
R Analysis not yet implemented
-
+ compiledMainJsUrl={compiledMainJsUrl} + /> ); }; diff --git a/gui/src/app/pages/HomePage/SamplingWindow/SamplingWindow.tsx b/gui/src/app/pages/HomePage/SamplingWindow/SamplingWindow.tsx index 75f29d65..2389a7b4 100644 --- a/gui/src/app/pages/HomePage/SamplingWindow/SamplingWindow.tsx +++ b/gui/src/app/pages/HomePage/SamplingWindow/SamplingWindow.tsx @@ -4,29 +4,30 @@ import { useContext, useEffect, useMemo, + useState, } from "react"; import { ProjectContext } from "../../../Project/ProjectContextProvider"; import { modelHasUnsavedDataFileChanges } from "../../../Project/ProjectDataModel"; import RunPanel from "../../../RunPanel/RunPanel"; -import { SamplingOpts } from "../../../StanSampler/StanSampler"; +import StanSampler, { SamplingOpts } from "../../../StanSampler/StanSampler"; import useStanSampler, { useSamplerStatus, } from "../../../StanSampler/useStanSampler"; import SamplerOutputView from "../../../SamplerOutputView/SamplerOutputView"; import SamplingOptsPanel from "../../../SamplingOptsPanel/SamplingOptsPanel"; +import TabWidget from "../../../TabWidget/TabWidget"; +import AnalysisPyWindow from "../AnalysisPyWindow/AnalysisPyWindow"; type SamplingWindowProps = { width: number; height: number; compiledMainJsUrl?: string; - onStanSampler: (sampler: any) => void; // todo: lift the state rather than having to use this callback }; const SamplingWindow: FunctionComponent = ({ width, height, - compiledMainJsUrl, - onStanSampler, + compiledMainJsUrl }) => { const { data, update } = useContext(ProjectContext); const parsedData = useMemo(() => { @@ -47,9 +48,6 @@ const SamplingWindow: FunctionComponent = ({ ); const { sampler } = useStanSampler(compiledMainJsUrl); - useEffect(() => { - onStanSampler(sampler); - }, [sampler, onStanSampler]); const { status: samplerStatus } = useSamplerStatus(sampler); const isSampling = samplerStatus === "sampling"; return ( @@ -92,16 +90,64 @@ const SamplingWindow: FunctionComponent = ({ height: height - samplingOptsPanelHeight, }} > - {sampler && ( - - )} + ); }; +const samplingResultsTabs = [ + { + id: "output", + label: "Output", + title: "View the output of the sampler", + closeable: false, + }, + { + id: "analysis.py", + label: "Analysis (Py)", + title: "Python analysis", + closeable: false, + }, + { + id: "analysis.r", + label: "Analysis (R)", + title: "R analysis", + closeable: false, + } +]; + +type SamplingResultsAreaProps = { + width: number; + height: number; + sampler: StanSampler | undefined; +}; + +const SamplingResultsArea: FunctionComponent = ({ + width, + height, + sampler, +}) => { + const [currentTabId, setCurrentTabId] = useState("output"); + return ( + + + +
+
R analysis not yet implemented
+
+
+ ); +}; + export default SamplingWindow;