Skip to content
Snippets Groups Projects
Commit 6bd8c8b0 authored by stevereis's avatar stevereis
Browse files

Replace name by id (for algorithm)

parent 058061ca
No related branches found
No related tags found
No related merge requests found
import { Category } from 'src/engine/models/category.model';
import { AlgorithmParameter } from 'src/engine/models/experiment/algorithm-parameter.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 { 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';
......@@ -56,10 +56,10 @@ export const dataToVariable = (data: VariableEntity): Variable => {
};
};
const algoParamInputToData = (param: AlgorithmParameter) => {
const algoParamInputToData = (param: AlgorithmParamInput) => {
return {
name: param.name,
label: param.name,
name: param.id,
label: param.id,
value: param.value.join(','),
};
};
......@@ -90,7 +90,7 @@ export const experimentInputToData = (data: ExperimentCreateInput) => {
},
].concat(data.algorithm.parameters.map(algoParamInputToData)),
type: data.algorithm.type ?? 'string',
name: data.algorithm.name,
name: data.algorithm.id,
},
name: data.name,
};
......@@ -132,9 +132,7 @@ export const dataToExperiment = (data: ExperimentData): Experiment => {
};
exp.results = data.result
? data.result
.map((result) => dataToResult(result, exp.algorithm.name))
.flat()
? data.result.map((result) => dataToResult(result, exp.algorithm.id)).flat()
: [];
return exp;
......
......@@ -10,11 +10,11 @@ export const transformToAlgorithms = jsonata(`
$toArray := function($x) { $type($x) = 'array' ? $x : [$x]};
*.{
'name': name,
'id': name,
'label': label,
'description': desc,
'parameters': $toArray(parameters[$not(name in $params)].{
'name': name,
'id': name,
'description': desc,
'label': label,
'type': valueType,
......@@ -44,15 +44,15 @@ export const transformToExperiment = jsonata(`
"finishedAt": finished,
"shared": shared,
"updateAt": updated,
"domains": algorithm.parameters[name = "pathology"].value,
"domain": algorithm.parameters[name = "pathology"].value,
"variables": $split(algorithm.parameters[name = "y"].value, ','),
"filter": algorithm.parameters[name = "filter"].value,
"datasets": $split(algorithm.parameters[name = "dataset"].value, ','),
"algorithm": {
"name": algorithm.name,
"id": algorithm.name,
"parameters" : $toArray(
algorithm.parameters[$not(name in $params)].({
"name": name,
"id": name,
"label": label,
"value": $split(value, ',')
})
......
......@@ -3,7 +3,7 @@ import { Field, ObjectType } from '@nestjs/graphql';
@ObjectType()
export class AlgorithmParameter {
@Field()
name: string;
id: string;
@Field(() => [String], { nullable: true })
value?: string[];
......
......@@ -4,7 +4,7 @@ import { AlgorithmParameter } from './algorithm-parameter.model';
@ObjectType()
export class Algorithm {
@Field()
name: string;
id: string;
@Field(() => [AlgorithmParameter], { nullable: true, defaultValue: [] })
parameters?: AlgorithmParameter[];
......
......@@ -3,7 +3,7 @@ import { Field, InputType } from '@nestjs/graphql';
@InputType()
export class AlgorithmParamInput {
@Field()
name: string;
id: string;
@Field(() => [String])
value: string[];
......
......@@ -4,7 +4,7 @@ import { AlgorithmParamInput } from './algorithm-parameter.input';
@InputType()
export class AlgorithmInput {
@Field()
name: string;
id: string;
@Field(() => [AlgorithmParamInput], { nullable: true, defaultValue: [] })
parameters: AlgorithmParamInput[];
......
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