Skip to content
Snippets Groups Projects
Commit 8bf0a424 authored by stevereis's avatar stevereis
Browse files

Add param type value algorithm input

parent 3cf869c7
No related branches found
No related tags found
No related merge requests found
import { Category } from 'src/engine/models/category.model';
import { Algorithm } from 'src/engine/models/experiment/algorithm.model';
import { Experiment } from 'src/engine/models/experiment/experiment.model';
import { AlgorithmParamInput } from 'src/engine/models/experiment/input/algorithm-parameter.input';
import {
AlgorithmParamInput,
ParamType,
} from 'src/engine/models/experiment/input/algorithm-parameter.input';
import { ExperimentCreateInput } from 'src/engine/models/experiment/input/experiment-create.input';
import { Group } from 'src/engine/models/group.model';
import { ResultUnion } from 'src/engine/models/result/common/result-union.model';
......@@ -65,14 +68,17 @@ const algoParamInputToData = (param: AlgorithmParamInput) => {
return {
name: param.id,
label: param.id,
value: param.value.join(','),
value:
param.type === ParamType.NUMBER
? Number(param.value)
: param.value.join(','),
};
};
export const experimentInputToData = (data: ExperimentCreateInput) => {
const params = {
algorithm: {
parameters: [
parameters: data.algorithm.parameters.map(algoParamInputToData).concat([
{
name: 'dataset',
label: 'dataset',
......@@ -93,7 +99,7 @@ export const experimentInputToData = (data: ExperimentCreateInput) => {
label: 'y',
value: data.variables.join(','),
},
].concat(data.algorithm.parameters.map(algoParamInputToData)),
]),
type: data.algorithm.type ?? 'string',
name: data.algorithm.id,
},
......@@ -185,7 +191,7 @@ export const dataJSONtoResult = (
case 'descriptive_stats':
return descriptiveDataToTableResult(result);
default:
return [];
return dataToRaw(result);
}
};
......
......@@ -34,6 +34,7 @@ export const transformToExperiment = jsonata(`
$toArray := function($x) { $type($x) = 'array' ? $x : [$x]};
{
"name": name,
"id": uuid,
......
import { Field, InputType } from '@nestjs/graphql';
import { Field, InputType, registerEnumType } from '@nestjs/graphql';
export enum ParamType {
STRING,
NUMBER,
}
registerEnumType(ParamType, {
name: 'ParamType',
});
@InputType()
export class AlgorithmParamInput {
@Field()
id: string;
@Field(() => ParamType, {
nullable: true,
defaultValue: ParamType.STRING,
})
type?: ParamType;
@Field(() => [String])
value: string[];
}
......@@ -207,9 +207,15 @@ input AlgorithmInput {
input AlgorithmParamInput {
id: String!
type: ParamType = STRING
value: [String!]!
}
enum ParamType {
STRING
NUMBER
}
input ExperimentEditInput {
name: String
shared: Boolean
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment