Skip to content

Commit

Permalink
Further tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
WardBrian committed Jul 17, 2024
1 parent 5d8f943 commit 0f6ff12
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
15 changes: 8 additions & 7 deletions gui/src/app/StanSampler/StanSampler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { SamplingOpts } from "@SpCore/ProjectDataModel";
import { Replies, Requests } from "@SpStanSampler/StanModelWorker";
import StanWorkerUrl from "@SpStanSampler/StanModelWorker?worker&url";
import React from "react";
import type { SamplerParams } from "tinystan";
import { type StanRunAction } from "./useStanSampler";

Expand All @@ -13,24 +12,26 @@ export type StanSamplerStatus =
| "completed"
| "failed";

type StanSamplerAndCleanup = {
sampler: StanSampler;
cleanup: () => void;
};

class StanSampler {
#worker: Worker | undefined;
#samplingStartTimeSec: number = 0;

private constructor(
private compiledUrl: string,
private update: React.Dispatch<StanRunAction>,
private update: (action: StanRunAction) => void,
) {
this._initialize();
}

static __unsafe_create(
compiledUrl: string,
update: React.Dispatch<StanRunAction>,
): {
sampler: StanSampler;
cleanup: () => void;
} {
update: (action: StanRunAction) => void,
): StanSamplerAndCleanup {
const sampler = new StanSampler(compiledUrl, update);
const cleanup = () => {
console.log("terminating model worker");
Expand Down
13 changes: 5 additions & 8 deletions gui/src/app/StanSampler/useStanSampler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,11 @@ export const StanRunReducer = (
case "progressUpdate":
return { ...state, progress: action.progress };
case "statusUpdate":
if (action.errorMessage) {
return {
...state,
status: action.status,
errorMessage: action.errorMessage,
};
}
return { ...state, status: action.status };
return {
...state,
status: action.status,
errorMessage: action.errorMessage ?? state.errorMessage,
};
case "startSampling":
return {
status: "sampling",
Expand Down

0 comments on commit 0f6ff12

Please sign in to comment.