Skip to content

Commit

Permalink
re-gen
Browse files Browse the repository at this point in the history
  • Loading branch information
fulpm committed Oct 7, 2024
1 parent 582bec9 commit 63cda70
Show file tree
Hide file tree
Showing 15 changed files with 131 additions and 32 deletions.
8 changes: 2 additions & 6 deletions codegen/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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", {
Expand Down
8 changes: 6 additions & 2 deletions codegen/templates/client/AbstractBaseClient.njk
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,12 @@ export abstract class AbstractBaseClient {
/** Begin a new Session. */
public abstract beginSession(name?: string, metadata?: Record<string, any>): Promise<Session>;
{% 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.
Expand Down
8 changes: 6 additions & 2 deletions codegen/templates/engine/Trainee.njk
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion codegen/templates/schemas/label.njk
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export type {{ name }}Request = {
};
{% endif -%}

{%- if returns %}
{%- if returns and not returns | isRef %}
export type {{ name }}Response = {{ field(returns) }};

{%- endif %}
Binary file modified src/assets/howso.caml
Binary file not shown.
Binary file modified src/assets/migrations.caml
Binary file not shown.
35 changes: 25 additions & 10 deletions src/client/AbstractBaseClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ClientResponse<any>> {
public async copySubtrainee(
traineeId: string,
request: schemas.CopySubtraineeRequest,
): Promise<ClientResponse<schemas.CopySubtraineeResponse>> {
const trainee = await this.autoResolveTrainee(traineeId);
const response = await this.execute<any>(trainee.id, "copy_subtrainee", request);
const response = await this.execute<schemas.CopySubtraineeResponse>(trainee.id, "copy_subtrainee", request);
this.autoPersistTrainee(trainee.id);
return { payload: response.payload, warnings: response.warnings };
}
Expand Down Expand Up @@ -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<ClientResponse<any>> {
public async getAutoAblationParams(
traineeId: string,
): Promise<ClientResponse<schemas.GetAutoAblationParamsResponse>> {
const trainee = await this.autoResolveTrainee(traineeId);
const response = await this.execute<any>(trainee.id, "get_auto_ablation_params", {});
const response = await this.execute<schemas.GetAutoAblationParamsResponse>(
trainee.id,
"get_auto_ablation_params",
{},
);
return { payload: response.payload, warnings: response.warnings };
}

Expand Down Expand Up @@ -567,9 +576,9 @@ export abstract class AbstractBaseClient {
public async getParams(
traineeId: string,
request: schemas.GetParamsRequest,
): Promise<ClientResponse<shims.GetParamsResponse>> {
): Promise<ClientResponse<schemas.GetParamsResponse>> {
const trainee = await this.autoResolveTrainee(traineeId);
const response = await this.execute<shims.GetParamsResponse>(trainee.id, "get_params", request);
const response = await this.execute<schemas.GetParamsResponse>(trainee.id, "get_params", request);
return { payload: response.payload, warnings: response.warnings };
}

Expand Down Expand Up @@ -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<ClientResponse<any>> {
public async moveCases(
traineeId: string,
request: schemas.MoveCasesRequest,
): Promise<ClientResponse<schemas.MoveCasesResponse>> {
const trainee = await this.autoResolveTrainee(traineeId);
const response = await this.execute<any>(trainee.id, "move_cases", request);
const response = await this.execute<schemas.MoveCasesResponse>(trainee.id, "move_cases", request);
this.autoPersistTrainee(trainee.id);
return { payload: response.payload, warnings: response.warnings };
}
Expand Down Expand Up @@ -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<ClientResponse<any>> {
public async reduceData(
traineeId: string,
request: schemas.ReduceDataRequest,
): Promise<ClientResponse<schemas.ReduceDataResponse>> {
const trainee = await this.autoResolveTrainee(traineeId);
const response = await this.execute<any>(trainee.id, "reduce_data", request);
const response = await this.execute<schemas.ReduceDataResponse>(trainee.id, "reduce_data", request);
this.autoPersistTrainee(trainee.id);
return { payload: response.payload, warnings: response.warnings };
}
Expand Down
4 changes: 4 additions & 0 deletions src/types/schemas/CopySubtrainee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ export type CopySubtraineeRequest = {
*/
target_trainee: string | string[];
};

export type CopySubtraineeResponse = {
name?: string;
};
50 changes: 50 additions & 0 deletions src/types/schemas/GetAutoAblationParams.ts
Original file line number Diff line number Diff line change
@@ -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[];
};
25 changes: 25 additions & 0 deletions src/types/schemas/GetParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
/**
Expand All @@ -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;
};
4 changes: 4 additions & 0 deletions src/types/schemas/MoveCases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,7 @@ export type MoveCasesRequest = {
*/
target_name_path?: string[];
};

export type MoveCasesResponse = {
count?: number;
};
7 changes: 7 additions & 0 deletions src/types/schemas/ReduceData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, Record<string, Record<string, boolean>>>;
};
1 change: 1 addition & 0 deletions src/types/schemas/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
10 changes: 0 additions & 10 deletions src/types/shims/GetParams.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/types/shims/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export * from "./FeatureOriginalType";
export * from "./GetMarginalStats";
export * from "./GetParams";
export * from "./React";
export * from "./ReactAggregate";

0 comments on commit 63cda70

Please sign in to comment.