Skip to content
Snippets Groups Projects
Commit 4fcc49a7 authored by stevereis's avatar stevereis
Browse files

wip: handle exceptions experiment exareme

parent af4a74ac
No related branches found
No related tags found
No related merge requests found
......@@ -220,8 +220,17 @@ export const dataToExperiment = (
return exp;
} catch (e) {
//TODO : Add logger can't convert experiment
return undefined;
return {
id: data.uuid,
name: data.name,
status: 'error',
variables: [],
domain: data['domain'] ?? '',
datasets: [],
algorithm: {
id: 'unknown',
},
};
}
};
......@@ -229,10 +238,19 @@ export const dataToAlgorithms = (data: string): Algorithm[] => {
return transformToAlgorithms.evaluate(data);
};
export const dataToRaw = (result: ResultExperiment): RawResult[] => {
export const dataToRaw = (
algo: string,
result: ResultExperiment,
): RawResult[] => {
let data = result;
if (algo === 'CART') {
data = { ...data, type: 'application/binary-tree+json' };
}
return [
{
rawdata: result,
rawdata: data,
},
];
};
......@@ -247,7 +265,7 @@ export const dataToResult = (
case 'application/vnd.highcharts+json':
return dataHighchartToResult(result as ResultChartExperiment, algo);
default:
return dataToRaw(result);
return dataToRaw(algo, result);
}
};
......@@ -259,7 +277,7 @@ export const dataJSONtoResult = (
case 'descriptive_stats':
return descriptiveDataToTableResult(result);
default:
return dataToRaw(result);
return dataToRaw(algo, result);
}
};
......@@ -273,6 +291,6 @@ export const dataHighchartToResult = (
case 'area':
return [dataROCToLineResult.evaluate(result) as LineChartResult];
default:
return dataToRaw(result);
return dataToRaw(algo, result);
}
};
......@@ -5,6 +5,7 @@ export interface ExperimentData {
uuid?: string;
status?: string;
createdBy?: string;
created: string;
shared?: boolean;
viewed?: boolean;
result?: ResultExperiment[];
......
......@@ -74,9 +74,7 @@ export default class ExaremeService implements IEngineService {
return {
...resultAPI.data,
experiments:
resultAPI.data.experiments?.map(dataToExperiment).filter((r) => r) ??
[],
experiments: resultAPI.data.experiments?.map(dataToExperiment) ?? [],
};
}
......
......@@ -31,10 +31,9 @@ export const transformToAlgorithms = jsonata(`
export const transformToExperiment = jsonata(`
(
$params := ["y", "pathology", "dataset", "filter", "x"];
$toArray := function($x) { $type($x) = 'array' ? $x : [$x]};
$convDate := function($v) { $type($v) = 'string' ? $toMillis($v) : $v };
$rp := function($v) {$replace($v, /(\\+|\\*|-)/, ',')};
{
"name": name,
......@@ -47,8 +46,8 @@ export const transformToExperiment = jsonata(`
"shared": shared,
"updateAt": $convDate(updated),
"domain": algorithm.parameters[name = "pathology"].value,
"variables": $split(algorithm.parameters[name = "y"].value, ','),
"coVariables": $toArray($split(algorithm.parameters[name = "x"].value, ',')),
"variables": $split($rp(algorithm.parameters[name = "y"].value), ','),
"coVariables": $toArray($split($rp(algorithm.parameters[name = "x"].value), ',')),
"filter": algorithm.parameters[name = "filter"].value,
"datasets": $split(algorithm.parameters[name = "dataset"].value, ','),
"algorithm": {
......
......@@ -53,10 +53,11 @@ export class EngineModule {
const engine = new service.default(options, httpService, req);
return engine;
} catch {
} catch (e) {
this.logger.error(
`There is a problem with the connector '${options.type}'`,
);
this.logger.verbose(e);
process.exit(); // We can't continue without an engine, shutdown the process...
}
}
......
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