diff --git a/codegen/generator.ts b/codegen/generator.ts index 74eddd5..50e51de 100644 --- a/codegen/generator.ts +++ b/codegen/generator.ts @@ -43,15 +43,10 @@ export class Generator { // Temporary shims until return values are defined this.responseShims = { analyze: "null", - get_cases: "shims.GetCasesResponse", - get_feature_attributes: "schemas.FeatureAttributesIndex", - set_feature_attributes: "schemas.FeatureAttributesIndex", get_marginal_stats: "shims.GetMarginalStatsResponse", - get_params: "shims.GetParamsResponse", react: "shims.ReactResponse", react_aggregate: "shims.ReactAggregateResponse", react_into_features: "null", - train: "shims.TrainResponse", }; // Setup template engine @@ -111,7 +106,8 @@ export class Generator { for (const [label, definition] of Object.entries(this.doc.labels)) { if (this.ignoredLabels.includes(label) || definition.attribute) continue; // Add schemas for label parameters and/or return value if it has any - if (definition.parameters != null || definition.returns != null) { + // For returns that are just a Ref, ignore them as they can already be referenced directly + if (definition.parameters != null || (definition.returns != null && !isRef(definition.returns))) { const title = toPascalCase(label); allNames.push(title); this.renderFile(this.schemaDir, `${title}.ts`, "schemas/label.njk", { diff --git a/codegen/templates/client/AbstractBaseClient.njk b/codegen/templates/client/AbstractBaseClient.njk index 9e39ce1..8bcf8c5 100644 --- a/codegen/templates/client/AbstractBaseClient.njk +++ b/codegen/templates/client/AbstractBaseClient.njk @@ -161,8 +161,12 @@ export abstract class AbstractBaseClient { /** Begin a new Session. */ public abstract beginSession(name?: string, metadata?: Record): Promise; {% for label, def in labels | dictsort %} -{%- set requestName = "schemas." + label | pascalCase + "Request" %} -{%- set responseName = "schemas." + label | pascalCase + "Response" %} + {%- set requestName = "schemas." + label | pascalCase + "Request" %} + {%- if def.returns | isRef %} + {%- set responseName = "schemas." + def.returns.ref %} + {%- else %} + {%- set responseName = "schemas." + label | pascalCase + "Response" %} + {%- endif %} /** * {{ def.description | blockComment | safe | indent(2) }} * @param traineeId The Trainee identifier. diff --git a/codegen/templates/engine/Trainee.njk b/codegen/templates/engine/Trainee.njk index bf50133..31e7fea 100644 --- a/codegen/templates/engine/Trainee.njk +++ b/codegen/templates/engine/Trainee.njk @@ -116,8 +116,12 @@ export class Trainee implements BaseTrainee { } {% for label, def in labels | dictsort %} -{%- set requestName = "schemas." + label | pascalCase + "Request" %} -{%- set responseName = "schemas." + label | pascalCase + "Response" %} + {%- set requestName = "schemas." + label | pascalCase + "Request" %} + {%- if def.returns | isRef %} + {%- set responseName = "schemas." + def.returns.ref %} + {%- else %} + {%- set responseName = "schemas." + label | pascalCase + "Response" %} + {%- endif %} /** * {{ def.description | blockComment | safe | indent(2) }} * @param traineeId The Trainee identifier. diff --git a/codegen/templates/schemas/label.njk b/codegen/templates/schemas/label.njk index cb9c305..d21fead 100644 --- a/codegen/templates/schemas/label.njk +++ b/codegen/templates/schemas/label.njk @@ -11,7 +11,7 @@ export type {{ name }}Request = { }; {% endif -%} -{%- if returns %} +{%- if returns and not returns | isRef %} export type {{ name }}Response = {{ field(returns) }}; {%- endif %} \ No newline at end of file diff --git a/src/assets/howso.caml b/src/assets/howso.caml index 55ffe5b..c06326b 100644 Binary files a/src/assets/howso.caml and b/src/assets/howso.caml differ diff --git a/src/assets/migrations.caml b/src/assets/migrations.caml index ee4771c..8356df8 100644 Binary files a/src/assets/migrations.caml and b/src/assets/migrations.caml differ diff --git a/src/client/AbstractBaseClient.ts b/src/client/AbstractBaseClient.ts index d12d3f5..900d8fa 100644 --- a/src/client/AbstractBaseClient.ts +++ b/src/client/AbstractBaseClient.ts @@ -241,9 +241,12 @@ export abstract class AbstractBaseClient { * @param request The operation parameters. * @returns The response of the operation, including any warnings. */ - public async copySubtrainee(traineeId: string, request: schemas.CopySubtraineeRequest): Promise> { + public async copySubtrainee( + traineeId: string, + request: schemas.CopySubtraineeRequest, + ): Promise> { const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "copy_subtrainee", request); + const response = await this.execute(trainee.id, "copy_subtrainee", request); this.autoPersistTrainee(trainee.id); return { payload: response.payload, warnings: response.warnings }; } @@ -365,9 +368,15 @@ export abstract class AbstractBaseClient { * @param request The operation parameters. * @returns The response of the operation, including any warnings. */ - public async getAutoAblationParams(traineeId: string): Promise> { + public async getAutoAblationParams( + traineeId: string, + ): Promise> { const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "get_auto_ablation_params", {}); + const response = await this.execute( + trainee.id, + "get_auto_ablation_params", + {}, + ); return { payload: response.payload, warnings: response.warnings }; } @@ -567,9 +576,9 @@ export abstract class AbstractBaseClient { public async getParams( traineeId: string, request: schemas.GetParamsRequest, - ): Promise> { + ): Promise> { const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "get_params", request); + const response = await this.execute(trainee.id, "get_params", request); return { payload: response.payload, warnings: response.warnings }; } @@ -727,9 +736,12 @@ export abstract class AbstractBaseClient { * @param request The operation parameters. * @returns The response of the operation, including any warnings. */ - public async moveCases(traineeId: string, request: schemas.MoveCasesRequest): Promise> { + public async moveCases( + traineeId: string, + request: schemas.MoveCasesRequest, + ): Promise> { const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "move_cases", request); + const response = await this.execute(trainee.id, "move_cases", request); this.autoPersistTrainee(trainee.id); return { payload: response.payload, warnings: response.warnings }; } @@ -822,9 +834,12 @@ export abstract class AbstractBaseClient { * @param request The operation parameters. * @returns The response of the operation, including any warnings. */ - public async reduceData(traineeId: string, request: schemas.ReduceDataRequest): Promise> { + public async reduceData( + traineeId: string, + request: schemas.ReduceDataRequest, + ): Promise> { const trainee = await this.autoResolveTrainee(traineeId); - const response = await this.execute(trainee.id, "reduce_data", request); + const response = await this.execute(trainee.id, "reduce_data", request); this.autoPersistTrainee(trainee.id); return { payload: response.payload, warnings: response.warnings }; } diff --git a/src/types/schemas/CopySubtrainee.ts b/src/types/schemas/CopySubtrainee.ts index e76c4fb..cb099dc 100644 --- a/src/types/schemas/CopySubtrainee.ts +++ b/src/types/schemas/CopySubtrainee.ts @@ -34,3 +34,7 @@ export type CopySubtraineeRequest = { */ target_trainee: string | string[]; }; + +export type CopySubtraineeResponse = { + name?: string; +}; diff --git a/src/types/schemas/GetAutoAblationParams.ts b/src/types/schemas/GetAutoAblationParams.ts new file mode 100644 index 0000000..c91bc3a --- /dev/null +++ b/src/types/schemas/GetAutoAblationParams.ts @@ -0,0 +1,50 @@ +/** + * WARNING: This file is auto generated, do not modify manually. + * + * GetAutoAblationParams + * + * Get auto-ablation parameters set by #set_auto_ablation_params + */ + +export type GetAutoAblationParamsResponse = { + /** + * Flag indicating if automatic ablation is enabled. + */ + auto_ablation_enabled?: boolean; + /** + * The name of the weight feature which is accumulated and used in automatic ablation. + */ + auto_ablation_weight_feature?: boolean; + /** + * The conviction threshold above which cases will be ablated. + */ + conviction_lower_threshold?: number; + /** + * The conviction threshold below which cases will be ablated. + */ + conviction_upper_threshold?: number; + /** + * The list of features that if predicted correctly on a new case will trigger the ablation of the case. + */ + exact_prediction_features?: string[]; + /** + * The minimum threshold of influence weight entropy for a case to be ablated in the process of automatic ablation. + */ + influence_weight_entropy_threshold?: number; + /** + * The minimum number of cases to train before automatic ablation begins. + */ + minimum_model_size?: number; + /** + * The map of features to relative thresholds that if predicted within on a new case will trigger the ablation of the case. + */ + relative_prediction_threshold_map?: string[]; + /** + * The list of features that if predicted within their residual on a new case will trigger the ablation of the case. + */ + residual_prediction_features?: string[]; + /** + * The map of features to absolute thresholds that if predicted within on a new case will trigger the ablation of the case. + */ + tolerance_prediction_threshold_map?: string[]; +}; diff --git a/src/types/schemas/GetParams.ts b/src/types/schemas/GetParams.ts index ffc7695..9c40d0c 100644 --- a/src/types/schemas/GetParams.ts +++ b/src/types/schemas/GetParams.ts @@ -6,6 +6,8 @@ * Return the full internal parameters map if no parameters are specified. * if any of the parameters are specified, then GetHyperparameters is called, which uses the specified parameters to find the most suitable set of hyperparameters to return */ +import type { FullHyperparameterMap } from "./FullHyperparameterMap"; +import type { HyperparameterMap } from "./HyperparameterMap"; export type GetParamsRequest = { /** @@ -28,3 +30,26 @@ export type GetParamsRequest = { */ weight_feature?: string; }; + +export type GetParamsResponse = { + /** + * The scalar rate at which the number of cases to trigger an auto-analysis grows with each iteration + */ + analyze_growth_factor?: number; + /** + * The number of cases at which the auto-analysis is triggered. + */ + analyze_threshold?: number; + /** + * Flag indicating of auto-analysis is enabled. + */ + auto_analyze_enabled?: boolean; + /** + * The map of default hyperparameters + */ + default_hyperparameter_map?: HyperparameterMap; + /** + * The full map of hyperparameters or a specific map of hyperparameters if any parameters were given + */ + hyperparameter_map?: FullHyperparameterMap; +}; diff --git a/src/types/schemas/MoveCases.ts b/src/types/schemas/MoveCases.ts index 81be732..216e1ff 100644 --- a/src/types/schemas/MoveCases.ts +++ b/src/types/schemas/MoveCases.ts @@ -73,3 +73,7 @@ export type MoveCasesRequest = { */ target_name_path?: string[]; }; + +export type MoveCasesResponse = { + count?: number; +}; diff --git a/src/types/schemas/ReduceData.ts b/src/types/schemas/ReduceData.ts index bd399f5..2627027 100644 --- a/src/types/schemas/ReduceData.ts +++ b/src/types/schemas/ReduceData.ts @@ -67,3 +67,10 @@ export type ReduceDataRequest = { */ skip_auto_analyze?: boolean; }; + +export type ReduceDataResponse = { + /** + * A map of threshold-type (abs, relative, or delta) to map of metric to map of feature name to boolean. Indicating what thresholds were met to trigger the end of data reduction. + */ + threshold_info?: Record>>; +}; diff --git a/src/types/schemas/index.ts b/src/types/schemas/index.ts index 08f1379..b3cf436 100644 --- a/src/types/schemas/index.ts +++ b/src/types/schemas/index.ts @@ -25,6 +25,7 @@ export * from "./FeatureAttributesIndex"; export * from "./FeatureBoundsMap"; export * from "./FullHyperparameterMap"; export * from "./GenerateNewCases"; +export * from "./GetAutoAblationParams"; export * from "./GetCases"; export * from "./GetDistances"; export * from "./GetEntityPathById"; diff --git a/src/types/shims/GetParams.ts b/src/types/shims/GetParams.ts deleted file mode 100644 index 55089f2..0000000 --- a/src/types/shims/GetParams.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { FullHyperparameterMap, HyperparameterMap } from "../schemas"; - -export type GetParamsResponse = { - default_hyperparameter_map?: FullHyperparameterMap; - hyperparameter_map?: HyperparameterMap; - auto_analyze_enabled?: boolean; - auto_analyze_limit_size?: number; - analyze_growth_factor?: number; - analyze_threshold?: number; -}; diff --git a/src/types/shims/index.ts b/src/types/shims/index.ts index f5e54fd..3d02a64 100644 --- a/src/types/shims/index.ts +++ b/src/types/shims/index.ts @@ -1,5 +1,4 @@ export * from "./FeatureOriginalType"; export * from "./GetMarginalStats"; -export * from "./GetParams"; export * from "./React"; export * from "./ReactAggregate";