Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

21485: MAJOR Update Amalgam verison to 54.3.17 #13

Merged
merged 5 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 48 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,59 @@
# Introduction

An interface around the caml files produced by the `howso-engine` releases.
An interface surrounding `@howso/amalgam-lang` WASM to create a simplified client.

## Getting Started

### Install dependencies

```bash
npm install
npm install @howso/engine
```

### Create a client using a Worker

```ts
import { AmalgamWasmService, initRuntime } from "@howso/amalgam-lang";
import wasmDataUri from "@howso/amalgam-lang/lib/amalgam-st.data?url";
import wasmUri from "@howso/amalgam-lang/lib/amalgam-st.wasm?url";

(async function () {
const svc = new AmalgamWasmService((options) => {
return initRuntime(options, {
locateFile: (path: string) => {
// Override file paths so we can use hashed version in build
if (path.endsWith("amalgam-st.wasm")) {
return wasmUri;
} else if (path.endsWith("amalgam-st.data")) {
return wasmDataUri;
}
return self.location.href + path;
},
});
});
self.onmessage = async (ev) => {
svc.dispatch(ev);
};
self.postMessage({ type: "event", event: "ready" });
})();
```

You can then create the worker client using a url import:

```ts
import howsoUrl from "@/data/engine/howso.caml?url";
import migrationsUrl from "@/data/engine/migrations.caml?url";
import { type ClientOptions, Trainee, WasmClient } from "@howso/engine/wasm";

const getClient = async (): WasmClient => {
const worker = new Worker(new URL("@/workers/AmalgamWorker", import.meta.url), { type: "module" });
const client = new WasmClient(worker, {
howsoUrl,
migrationsUrl,
...options,
});
return client.setup();
};
```

## Build and Test
Expand Down
30 changes: 15 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"lint": "tsc --noEmit && eslint 'src/**'",
"lint:fix": "eslint --fix 'src/**'",
"prepack": "npm run build",
"test": "tsc --noEmit && eslint 'src/**'"
"test": "tsc --noEmit"
},
"files": [
"LICENSE.txt",
Expand All @@ -37,7 +37,7 @@
"./package.json": "./package.json"
},
"dependencies": {
"@howso/amalgam-lang": "^54.2.1",
"@howso/amalgam-lang": "^54.3.17",
"@howso/openapi-client": "^2.0.1",
"@microsoft/fetch-event-source": "^2.0.1",
"uuid": "^9.0.0"
Expand Down
96 changes: 59 additions & 37 deletions src/client/wasm/client.ts
Original file line number Diff line number Diff line change
@@ -1,66 +1,66 @@
import type { AmalgamRequest, AmalgamResponseBody, AmalgamCommand } from "@howso/amalgam-lang/worker";
import type { Capabilities, ITraineeClient, ISessionClient } from "../capabilities/index.js";
import { AmalgamCoreResponse, prepareCoreRequest, prepareCoreResponse } from "./core.js";
import { AmalgamOptions } from "@howso/amalgam-lang/wasm";
import type { AmalgamCommand, AmalgamOptions, AmalgamRequest, AmalgamResponseBody } from "@howso/amalgam-lang";
import { AmalgamError } from "@howso/amalgam-lang";
import { SetAutoAblationParamsRequest } from "@howso/openapi-client";
import {
AnalyzeRequest,
AnalyzeRequestToJSON,
CaseCountResponse,
Cases,
CasesRequest,
CaseCountResponse,
CasesRequestToJSON,
FeatureAttributes,
FeatureAttributesFromJSON,
FeatureAttributesToJSON,
FeatureConviction,
FeatureConvictionRequest,
FeatureConvictionRequestToJSON,
FeatureMarginalStats,
FeatureMarginalStatsFromJSON,
FeatureMarginalStatsRequest,
TrainRequest,
TrainResponse,
FeatureMarginalStatsRequestToJSON,
ReactAggregateRequest,
ReactAggregateRequestToJSON,
ReactAggregateResponse,
ReactAggregateResponseContent,
ReactAggregateResponseFromJSON,
ReactIntoFeaturesRequest,
ReactIntoFeaturesRequestToJSON,
ReactIntoFeaturesResponse,
ReactIntoFeaturesResponseFromJSON,
ReactRequest,
ReactRequestToJSON,
ReactResponse,
ReactResponseContent,
ReactResponseFromJSON,
ReactSeriesRequest,
ReactSeriesRequestToJSON,
ReactSeriesResponse,
ReactSeriesResponseContent,
ReactSeriesResponseFromJSON,
Session,
SessionIdentity,
SetAutoAnalyzeParamsRequest,
TraineeIdentity,
ReactIntoFeaturesRequest,
ReactIntoFeaturesResponse,
FeatureConviction,
FeatureConvictionRequest,
CasesRequestToJSON,
FeatureAttributesToJSON,
FeatureAttributesFromJSON,
FeatureMarginalStatsFromJSON,
FeatureMarginalStatsRequestToJSON,
SessionToJSON,
SetAutoAnalyzeParamsRequest,
SetAutoAnalyzeParamsRequestToJSON,
TraineeToJSON,
TraineeFromJSON,
TrainRequestToJSON,
ReactRequestToJSON,
ReactResponseFromJSON,
ReactSeriesRequestToJSON,
ReactSeriesResponseFromJSON,
ReactIntoFeaturesRequestToJSON,
ReactIntoFeaturesResponseFromJSON,
FeatureConvictionRequestToJSON,
AnalyzeRequestToJSON,
ReactAggregateResponse,
ReactAggregateRequest,
ReactAggregateResponseContent,
ReactAggregateResponseFromJSON,
ReactAggregateRequestToJSON,
TraineeWorkflowAttributesRequest,
TraineeIdentity,
TraineeToJSON,
TraineeWorkflowAttributesFromJSON,
TraineeWorkflowAttributesRequest,
TraineeWorkflowAttributesRequestToJSON,
TrainRequest,
TrainRequestToJSON,
TrainResponse,
} from "@howso/openapi-client/models";
import { RequiredError, mapValues } from "@howso/openapi-client/runtime";
import { mapValues, RequiredError } from "@howso/openapi-client/runtime";
import { v4 as uuid } from "uuid";
import { Trainee } from "../../trainees/index.js";
import { BaseClient, TraineeBaseCache } from "../capabilities/index";
import type { Capabilities, ISessionClient, ITraineeClient } from "../capabilities/index.js";
import { ProblemError } from "../errors";
import { CacheMap, isNode, batcher, BatchOptions } from "../utilities/index";
import { batcher, BatchOptions, CacheMap, isNode } from "../utilities/index";
import { AmalgamCoreResponse, prepareCoreRequest, prepareCoreResponse } from "./core.js";
import { FileSystemClient } from "./files";
import { AmalgamError } from "@howso/amalgam-lang";

export interface TraineeCache extends TraineeBaseCache {}

Expand Down Expand Up @@ -633,6 +633,28 @@ export class WasmClient extends BaseClient implements ITraineeClient, ISessionCl
return TraineeWorkflowAttributesFromJSON(response);
}

/**
* Set the parameters use by auto analyze.
* @param traineeId The trainee identifier.
* @param request The analysis parameters.
*/
public async setAutoAblationParams(
traineeId: string,
request: Omit<SetAutoAblationParamsRequest, "trainee_id">,
): Promise<void> {
await this.autoResolveTrainee(traineeId);

await this.execute(
traineeId,
"set_auto_ablation_params",
JSON.stringify({
trainee_id: traineeId,
...request,
}),
);
await this.autoPersistTrainee(traineeId);
}

/**
* Set the parameters use by auto analyze.
* @param traineeId The trainee identifier.
Expand Down
4 changes: 2 additions & 2 deletions src/client/wasm/files.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type {
IFileSystem,
FileSystemOperation,
FileSystemRequest,
FileSystemResponse,
FileSystemResponseBody,
} from "@howso/amalgam-lang/worker";
IFileSystem,
} from "@howso/amalgam-lang";
import { isNode } from "../utilities/detectors.js";

export class FileSystemClient implements IFileSystem {
Expand Down