diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7fc370a..d3a4f5e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,8 +23,10 @@ jobs: with: build-type: ${{ inputs.build-type }} optional-release-tag: ${{ inputs.optional-release-tag }} - - # Add NPM test here when the time is right + + npm-test: + uses: howsoai/.github/.github/workflows/npm-test.yml@main + secrets: inherit release: needs: @@ -33,4 +35,4 @@ jobs: uses: howsoai/.github/.github/workflows/npm-release.yml@main secrets: inherit with: - version: ${{ needs.metadata.outputs.version }} \ No newline at end of file + version: ${{ needs.metadata.outputs.version }} diff --git a/package-lock.json b/package-lock.json index 1acfb91..78f48bb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,8 +9,8 @@ "version": "0.0.0", "license": "AGPL-3.0-only", "dependencies": { - "@howso/amalgam-lang": "^0.0.10", - "@howso/openapi-client": "^1.0.1", + "@howso/amalgam-lang": "^0.0.11", + "@howso/openapi-client": "^2.0.0", "@microsoft/fetch-event-source": "^2.0.1", "uuid": "^9.0.0" }, @@ -25,7 +25,7 @@ "eslint-plugin-prettier": "^5.1.3", "prettier": "^3.2.5", "rimraf": "^5.0.5", - "typescript": "^5.3.3" + "typescript": "^5.5.3" }, "engines": { "node": ">=18" @@ -97,14 +97,14 @@ } }, "node_modules/@howso/amalgam-lang": { - "version": "0.0.10", - "resolved": "https://dpbuild.jfrog.io/artifactory/api/npm/npm-virtual/@howso/amalgam-lang/-/@howso/amalgam-lang-0.0.10.tgz", - "integrity": "sha512-7UQS/8vp0Q91YLYd9zSn4KWzZR0q++biHr7iS3Jwd7ykaQs8jkBNdE9ZrRSAwIL6yb3Mmo4ltqCXeo3t535esQ==" + "version": "0.0.11", + "resolved": "https://dpbuild.jfrog.io/artifactory/api/npm/npm-virtual/@howso/amalgam-lang/-/@howso/amalgam-lang-0.0.11.tgz", + "integrity": "sha512-pn+8g7V/Y/xDqajQph+u39j495PvWk5vKNoCeoGLl4bNuFrfpIm6leNauDpzYS5Lrwyfa/a0W63fsskDIJGghA==" }, "node_modules/@howso/openapi-client": { - "version": "1.0.1", - "resolved": "https://dpbuild.jfrog.io/artifactory/api/npm/npm-virtual/@howso/openapi-client/-/@howso/openapi-client-1.0.1.tgz", - "integrity": "sha512-LRGv+mePf1Ef5eXuyrAIJcqnSEkVbsB4yCturOtm1mP3LssSlO+JhhC7YBh8GbHfydghbCX9HkaVVjG/iYV2ug==", + "version": "2.0.0", + "resolved": "https://dpbuild.jfrog.io/artifactory/api/npm/npm-virtual/@howso/openapi-client/-/@howso/openapi-client-2.0.0.tgz", + "integrity": "sha512-AUBZvQ1CraFqkaBuNrQwWSUzfZsMQYOakgyoGVin1Q+NHAsQjBZ/lAnqj3KRjQ6sVw5xn2kBqPuX8X+Ktk4vxg==", "engines": { "node": ">=18" } @@ -2000,9 +2000,9 @@ } }, "node_modules/typescript": { - "version": "5.3.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz", - "integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==", + "version": "5.5.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.3.tgz", + "integrity": "sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ==", "dev": true, "bin": { "tsc": "bin/tsc", @@ -2213,14 +2213,14 @@ "dev": true }, "@howso/amalgam-lang": { - "version": "0.0.10", - "resolved": "https://dpbuild.jfrog.io/artifactory/api/npm/npm-virtual/@howso/amalgam-lang/-/@howso/amalgam-lang-0.0.10.tgz", - "integrity": "sha512-7UQS/8vp0Q91YLYd9zSn4KWzZR0q++biHr7iS3Jwd7ykaQs8jkBNdE9ZrRSAwIL6yb3Mmo4ltqCXeo3t535esQ==" + "version": "0.0.11", + "resolved": "https://dpbuild.jfrog.io/artifactory/api/npm/npm-virtual/@howso/amalgam-lang/-/@howso/amalgam-lang-0.0.11.tgz", + "integrity": "sha512-pn+8g7V/Y/xDqajQph+u39j495PvWk5vKNoCeoGLl4bNuFrfpIm6leNauDpzYS5Lrwyfa/a0W63fsskDIJGghA==" }, "@howso/openapi-client": { - "version": "1.0.1", - "resolved": "https://dpbuild.jfrog.io/artifactory/api/npm/npm-virtual/@howso/openapi-client/-/@howso/openapi-client-1.0.1.tgz", - "integrity": "sha512-LRGv+mePf1Ef5eXuyrAIJcqnSEkVbsB4yCturOtm1mP3LssSlO+JhhC7YBh8GbHfydghbCX9HkaVVjG/iYV2ug==" + "version": "2.0.0", + "resolved": "https://dpbuild.jfrog.io/artifactory/api/npm/npm-virtual/@howso/openapi-client/-/@howso/openapi-client-2.0.0.tgz", + "integrity": "sha512-AUBZvQ1CraFqkaBuNrQwWSUzfZsMQYOakgyoGVin1Q+NHAsQjBZ/lAnqj3KRjQ6sVw5xn2kBqPuX8X+Ktk4vxg==" }, "@humanwhocodes/config-array": { "version": "0.11.14", @@ -3542,9 +3542,9 @@ "dev": true }, "typescript": { - "version": "5.3.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz", - "integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==", + "version": "5.5.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.3.tgz", + "integrity": "sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ==", "dev": true }, "uri-js": { diff --git a/package.json b/package.json index 4cda06d..65430d6 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,8 @@ "build": "tsc --build", "lint": "tsc --noEmit && eslint 'src/**'", "lint:fix": "eslint --fix 'src/**'", - "prepack": "npm run build" + "prepack": "npm run build", + "test": "tsc --noEmit && eslint 'src/**'" }, "files": [ "LICENSE.txt", @@ -36,8 +37,8 @@ "./package.json": "./package.json" }, "dependencies": { - "@howso/amalgam-lang": "^0.0.10", - "@howso/openapi-client": "^1.0.1", + "@howso/amalgam-lang": "^0.0.11", + "@howso/openapi-client": "^2.0.0", "@microsoft/fetch-event-source": "^2.0.1", "uuid": "^9.0.0" }, @@ -52,7 +53,7 @@ "eslint-plugin-prettier": "^5.1.3", "prettier": "^3.2.5", "rimraf": "^5.0.5", - "typescript": "^5.3.3" + "typescript": "^5.5.3" }, "eslintConfig": { "root": true, diff --git a/src/client/capabilities/trainees.ts b/src/client/capabilities/trainees.ts index 9a9aaee..03fffe6 100644 --- a/src/client/capabilities/trainees.ts +++ b/src/client/capabilities/trainees.ts @@ -5,13 +5,8 @@ import type { FeatureAttributes, FeatureConviction, FeatureConvictionRequest, - FeatureContributionsRequest, - FeaturePredictionStats, - FeaturePredictionStatsRequest, FeatureMarginalStats, FeatureMarginalStatsRequest, - FeatureResidualsRequest, - FeatureMdaRequest, TrainRequest, ReactRequest, ReactResponse, @@ -19,10 +14,10 @@ import type { ReactIntoFeaturesResponse, ReactSeriesRequest, ReactSeriesResponse, - ReactIntoTraineeRequest, - ReactIntoTraineeResponse, SetAutoAnalyzeParamsRequest, TraineeIdentity, + TraineeWorkflowAttributesRequest, + TraineeWorkflowAttributes, } from "@howso/openapi-client/models"; import { Trainee } from "../../trainees/index"; @@ -40,16 +35,12 @@ export interface ITraineeClient { setAutoAnalyzeParams(traineeId: string, request: SetAutoAnalyzeParamsRequest): Promise; react(traineeId: string, request: ReactRequest): Promise; reactSeries(traineeId: string, request: ReactSeriesRequest): Promise; - reactIntoTrainee(traineeId: string, request: ReactIntoTraineeRequest): Promise; reactIntoFeatures(traineeId: string, request: ReactIntoFeaturesRequest): Promise; getCases(traineeId: string, request?: CasesRequest): Promise; + getInternalParams(traineeId: string, request: TraineeWorkflowAttributesRequest): Promise; getNumTrainingCases(traineeId: string): Promise; setFeatureAttributes(traineeId: string, attributes: Record): Promise; getFeatureAttributes(traineeId: string): Promise>; getFeatureConviction(traineeId: string, request: FeatureConvictionRequest): Promise; - getFeatureResiduals(traineeId: string, request: FeatureResidualsRequest): Promise>; - getFeatureContributions(traineeId: string, request: FeatureContributionsRequest): Promise>; - getFeatureMda(traineeId: string, request: FeatureMdaRequest): Promise>; - getPredictionStats(traineeId: string, request: FeaturePredictionStatsRequest): Promise; getMarginalStats(traineeId: string, request: FeatureMarginalStatsRequest): Promise; } diff --git a/src/client/wasm/client.ts b/src/client/wasm/client.ts index affbd39..85b0385 100644 --- a/src/client/wasm/client.ts +++ b/src/client/wasm/client.ts @@ -1,7 +1,6 @@ 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 { AnalyzeRequest, @@ -9,8 +8,6 @@ import { CasesRequest, CaseCountResponse, FeatureAttributes, - FeaturePredictionStats, - FeaturePredictionStatsRequest, FeatureMarginalStats, FeatureMarginalStatsRequest, TrainRequest, @@ -27,18 +24,11 @@ import { TraineeIdentity, ReactIntoFeaturesRequest, ReactIntoFeaturesResponse, - ReactIntoTraineeRequest, - ReactIntoTraineeResponse, - FeatureContributionsRequest, - FeatureMdaRequest, FeatureConviction, FeatureConvictionRequest, - FeatureResidualsRequest, CasesRequestToJSON, FeatureAttributesToJSON, FeatureAttributesFromJSON, - FeaturePredictionStatsFromJSON, - FeaturePredictionStatsRequestToJSON, FeatureMarginalStatsFromJSON, FeatureMarginalStatsRequestToJSON, SessionToJSON, @@ -52,17 +42,19 @@ import { ReactSeriesResponseFromJSON, ReactIntoFeaturesRequestToJSON, ReactIntoFeaturesResponseFromJSON, - ReactIntoTraineeRequestToJSON, - ReactIntoTraineeResponseFromJSON, FeatureConvictionRequestToJSON, - FeatureContributionsRequestToJSON, - FeatureResidualsRequestToJSON, - FeatureMdaRequestToJSON, AnalyzeRequestToJSON, + ReactAggregateResponse, + ReactAggregateRequest, + ReactAggregateResponseContent, + ReactAggregateResponseFromJSON, + ReactAggregateRequestToJSON, + TraineeWorkflowAttributesRequest, + TraineeWorkflowAttributesFromJSON, + TraineeWorkflowAttributesRequestToJSON, } from "@howso/openapi-client/models"; import { RequiredError, mapValues } from "@howso/openapi-client/runtime"; import { v4 as uuid } from "uuid"; - import { Trainee } from "../../trainees/index.js"; import { BaseClient, TraineeBaseCache } from "../capabilities/index"; import { ProblemError } from "../errors"; @@ -627,6 +619,20 @@ export class WasmClient extends BaseClient implements ITraineeClient, ISessionCl await this.autoPersistTrainee(trainee.id); } + /** + * Set the parameters use by auto analyze. + */ + public async getInternalParams(traineeId: string, request: TraineeWorkflowAttributesRequest = {}) { + await this.autoResolveTrainee(traineeId); + + const response = this.execute( + traineeId, + "get_internal_parameters", + TraineeWorkflowAttributesRequestToJSON(request), + ); + return TraineeWorkflowAttributesFromJSON(response); + } + /** * Set the parameters use by auto analyze. * @param traineeId The trainee identifier. @@ -704,6 +710,23 @@ export class WasmClient extends BaseClient implements ITraineeClient, ISessionCl return ReactResponseFromJSON({ warnings, content }); } + /** + * React to a trainee. + * @param traineeId The trainee identifier. + * @param request The react parameters. + * @returns The react response. + */ + public async reactAggregate(traineeId: string, request: ReactAggregateRequest): Promise { + const trainee = await this.autoResolveTrainee(traineeId); + this.preprocessReactRequest(trainee, request); + const { warnings = [], content } = await this.execute( + traineeId, + "react_aggregate", + ReactAggregateRequestToJSON(request), + ); + return ReactAggregateResponseFromJSON({ warnings, content }); + } + /** * React in series to a trainee. * @param traineeId The trainee identifier. @@ -741,42 +764,6 @@ export class WasmClient extends BaseClient implements ITraineeClient, ISessionCl return ReactIntoFeaturesResponseFromJSON({ warnings }); } - /** - * Compute and cache specified feature interpretations. - * @param traineeId The trainee identifier. - * @param request The react into trainee request. - * @returns The react into trainee response. - */ - public async reactIntoTrainee( - traineeId: string, - request: ReactIntoTraineeRequest, - ): Promise { - await this.autoResolveTrainee(traineeId); - - const { warnings = [] } = await this.execute(traineeId, "react_into_trainee", { - ...ReactIntoTraineeRequestToJSON(request), - }); - return ReactIntoTraineeResponseFromJSON({ warnings }); - } - - /** - * Get prediction stats of a trainee. - * @param traineeId The trainee identifier. - * @param request The prediction stats request. - * @returns The prediction stats. - */ - public async getPredictionStats( - traineeId: string, - request: FeaturePredictionStatsRequest, - ): Promise { - await this.autoResolveTrainee(traineeId); - - const { content, warnings = [] } = await this.execute(traineeId, "get_prediction_stats", { - ...FeaturePredictionStatsRequestToJSON(request), - }); - return FeaturePredictionStatsFromJSON({ content, warnings }); - } - /** * Get marginal stats of a trainee. * @param traineeId The trainee identifier. @@ -810,60 +797,6 @@ export class WasmClient extends BaseClient implements ITraineeClient, ISessionCl return content; } - /** - * Get contributions for features. - * @deprecated Use getPredictionStats instead. - * @param traineeId The trainee identifier. - * @param request The feature contributions request. - * @returns A map of feature name to contribution value. - */ - public async getFeatureContributions( - traineeId: string, - request: FeatureContributionsRequest, - ): Promise> { - await this.autoResolveTrainee(traineeId); - - const { content } = await this.execute>(traineeId, "get_feature_contributions", { - ...FeatureContributionsRequestToJSON(request), - }); - return content; - } - - /** - * Get residuals for features. - * @deprecated Use getPredictionStats instead. - * @param traineeId The trainee identifier. - * @param request The feature residuals request. - * @returns A map of feature name to residual value. - */ - public async getFeatureResiduals( - traineeId: string, - request: FeatureResidualsRequest, - ): Promise> { - await this.autoResolveTrainee(traineeId); - - const { content } = await this.execute>(traineeId, "get_feature_residuals", { - ...FeatureResidualsRequestToJSON(request), - }); - return content; - } - - /** - * Get mean decrease in accuracy for features. - * @deprecated Use getPredictionStats instead. - * @param traineeId The trainee identifier. - * @param request The feature MDA request. - * @returns A map of feature name to MDA value. - */ - public async getFeatureMda(traineeId: string, request: FeatureMdaRequest): Promise> { - await this.autoResolveTrainee(traineeId); - - const { content } = await this.execute>(traineeId, "get_feature_mda", { - ...FeatureMdaRequestToJSON(request), - }); - return content; - } - /** * Preprocess a request for react or react series. * @param trainee The trainee identifier.