Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested strategy, fix nested config handling. #165

Merged
merged 2 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/util/models-universe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ export class ModelsUniverse {
return EMemModel;
case 'aveva':
return EAvevaModel;
default: // cover default
return BoaviztaCpuImpactModel;
default:
throw new Error(`Missing or wrong model: ${name}.`);
}
}

Expand Down
19 changes: 12 additions & 7 deletions src/util/supercomputer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,19 @@ export class Supercomputer {
/**
* Adds config entries to each obsercation object passed.
*/
private enrichObservations(observations: any[], config: any[]) {
private enrichObservations(
observations: any[],
config: any[],
nestedConfig: any[]
) {
const configValues = this.flattenConfigValues(config);
const nestedConfigValues =
nestedConfig && this.flattenConfigValues(nestedConfig);

return observations.map((observation: any) => ({
...observation,
...configValues,
...nestedConfigValues,
}));
}

Expand All @@ -64,9 +71,7 @@ export class Supercomputer {
const {pipeline, observations, config} = this.olderChild.info;

if ('children' in childrenObject[childName]) {
return this.compute(childrenObject[childName].children, {
config,
});
return this.compute(childrenObject[childName].children);
}

const specificObservations = areChildrenNested
Expand All @@ -75,7 +80,8 @@ export class Supercomputer {

const enrichedObservations = this.enrichObservations(
specificObservations,
config
config,
childrenObject[childName].config
);

const observatory = new Observatory(enrichedObservations);
Expand Down Expand Up @@ -105,7 +111,7 @@ export class Supercomputer {
/**
* Checks if object is top level children or nested, then runs through all children and calculates impacts.
*/
public async compute(childrenObject?: any, params?: any) {
public async compute(childrenObject?: any) {
const implOrChildren = childrenObject || this.impl;
const areChildrenNested = !!childrenObject;
const children = areChildrenNested
Expand All @@ -117,7 +123,6 @@ export class Supercomputer {
await this.calculateImpactsForChild(children, {
childName,
areChildrenNested,
...params,
});
}

Expand Down