Skip to content

Commit

Permalink
run linter
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcook1186 committed Oct 30, 2023
1 parent a920e6c commit cd6e1bf
Show file tree
Hide file tree
Showing 45 changed files with 249 additions and 284 deletions.
10 changes: 5 additions & 5 deletions scripts/impact.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { parseProcessArgument } from '../src/util/args';
import { ModelsUniverse } from '../src/util/models-universe';
import { Supercomputer } from '../src/util/supercomputer';
import { openYamlFileAsObject, saveYamlFileAs } from '../src/util/yaml';
import {parseProcessArgument} from '../src/util/args';
import {ModelsUniverse} from '../src/util/models-universe';
import {Supercomputer} from '../src/util/supercomputer';
import {openYamlFileAsObject, saveYamlFileAs} from '../src/util/yaml';

/**
* 1. Parses yml input/output process arguments.
Expand All @@ -16,7 +16,7 @@ const outputScript = async () => {
const processParams = parseProcessArgument();

if (processParams) {
const { inputPath, outputPath } = processParams;
const {inputPath, outputPath} = processParams;
const impl = await openYamlFileAsObject(inputPath);

if (!('graph' in impl)) {
Expand Down
4 changes: 2 additions & 2 deletions src/__mocks__/fs/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { expect } from '@jest/globals';
import {expect} from '@jest/globals';

import * as YAML from 'js-yaml';

Expand Down Expand Up @@ -48,7 +48,7 @@ export const writeFile = async (pathToFile: string, content: string) => {
const mockContent = {
name: 'mock-name',
};
const mockObject = YAML.dump(mockContent, { noRefs: true });
const mockObject = YAML.dump(mockContent, {noRefs: true});

expect(pathToFile).toBe(mockPathToFile);
expect(content).toBe(mockObject);
Expand Down
8 changes: 4 additions & 4 deletions src/__mocks__/model-universe/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IoutputModelInterface } from '../../lib';
import {IoutputModelInterface} from '../../lib';

import {
ImplInitializeModel,
Expand All @@ -14,9 +14,9 @@ class MockModel implements IoutputModelInterface {
return Promise.resolve(this);
}
execute(): Promise<any[]> {
return Promise.resolve([{ data: 'mock-data' }]);
return Promise.resolve([{data: 'mock-data'}]);
}
authenticate(): void { }
authenticate(): void {}
}

/**
Expand Down Expand Up @@ -46,7 +46,7 @@ export class ModelsUniverse {
* Initializes and registers model.
*/
public writeDown(model: ImplInitializeModel) {
const { name } = model;
const {name} = model;

const Model = this.handModelByCriteria();

Expand Down
14 changes: 7 additions & 7 deletions src/__tests__/integration/ompl/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as fs from 'fs';
import { expect, jest, it } from '@jest/globals';
import {expect, jest, it} from '@jest/globals';

import { openYamlFileAsObject } from '../../../util/yaml';
import { describe } from 'node:test';
import {openYamlFileAsObject} from '../../../util/yaml';
import {describe} from 'node:test';

jest.setTimeout(30000);

Expand Down Expand Up @@ -70,10 +70,10 @@ describe('ompls: ', () => {

expect(
res.includes('energy-memory') &&
res.includes('energy-cpu') &&
res.includes('energy-network') &&
res.includes('energy') &&
res.includes('operational-carbon')
res.includes('energy-cpu') &&
res.includes('energy-network') &&
res.includes('energy') &&
res.includes('operational-carbon')
).toBeTruthy();
});
}
Expand Down
68 changes: 33 additions & 35 deletions src/__tests__/unit/lib/boavizta/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { describe, expect, jest, test } from '@jest/globals';
import {describe, expect, jest, test} from '@jest/globals';
import {
BoaviztaCloudoutputModel,
BoaviztaCpuoutputModel,
} from '../../../../lib/boavizta/index';
import axios, { AxiosResponse } from 'axios';
import axios, {AxiosResponse} from 'axios';
import * as PROVIDERS from '../../../../__mocks__/boavizta/providers.json';
import * as COUNTRIES from '../../../../__mocks__/boavizta/countries.json';
import * as INSTANCE_TYPES from '../../../../__mocks__/boavizta/instance_types.json';
Expand All @@ -13,9 +13,9 @@ async function axiosGet<T = any, R = AxiosResponse<T, any>>(
): Promise<R> {
switch (url) {
case 'https://api.boavizta.org/v1/cloud/instance/all_providers':
return { data: PROVIDERS } as R;
return {data: PROVIDERS} as R;
case 'https://api.boavizta.org/v1/utils/country_code':
return Promise.resolve({ data: COUNTRIES } as R);
return Promise.resolve({data: COUNTRIES} as R);
case 'https://api.boavizta.org/v1/cloud/instance/all_instances?provider=aws':
return Promise.resolve({
data: INSTANCE_TYPES['aws'],
Expand All @@ -42,7 +42,7 @@ mockAxios.post.mockImplementation(
max: 0.003113,
warnings: ['End of life is not included in the calculation'],
},
use: { value: 0.06743, min: 0.06743, max: 0.06743 },
use: {value: 0.06743, min: 0.06743, max: 0.06743},
unit: 'kgCO2eq',
description: 'Total climate change',
},
Expand All @@ -53,7 +53,7 @@ mockAxios.post.mockImplementation(
max: 7.771e-7,
warnings: ['End of life is not included in the calculation'],
},
use: { value: 1.796e-8, min: 1.796e-8, max: 1.796e-8 },
use: {value: 1.796e-8, min: 1.796e-8, max: 1.796e-8},
unit: 'kgSbeq',
description: 'Use of minerals and fossil ressources',
},
Expand All @@ -64,7 +64,7 @@ mockAxios.post.mockImplementation(
max: 0.04314,
warnings: ['End of life is not included in the calculation'],
},
use: { value: 2.07, min: 2.07, max: 2.07 },
use: {value: 2.07, min: 2.07, max: 2.07},
unit: 'MJ',
description: 'Consumption of primary energy',
},
Expand All @@ -82,7 +82,7 @@ mockAxios.post.mockImplementation(
max: 0.006226,
warnings: ['End of life is not included in the calculation'],
},
use: { value: 0.1924, min: 0.1924, max: 0.1924 },
use: {value: 0.1924, min: 0.1924, max: 0.1924},
unit: 'kgCO2eq',
description: 'Total climate change',
},
Expand All @@ -93,7 +93,7 @@ mockAxios.post.mockImplementation(
max: 0.000001554,
warnings: ['End of life is not included in the calculation'],
},
use: { value: 5.126e-8, min: 5.126e-8, max: 5.126e-8 },
use: {value: 5.126e-8, min: 5.126e-8, max: 5.126e-8},
unit: 'kgSbeq',
description: 'Use of minerals and fossil ressources',
},
Expand All @@ -104,7 +104,7 @@ mockAxios.post.mockImplementation(
max: 0.08627,
warnings: ['End of life is not included in the calculation'],
},
use: { value: 5.907, min: 5.907, max: 5.907 },
use: {value: 5.907, min: 5.907, max: 5.907},
unit: 'MJ',
description: 'Consumption of primary energy',
},
Expand All @@ -120,7 +120,7 @@ mockAxios.post.mockImplementation(
'End of life is not included in the calculation',
],
},
use: { value: 0.1924, min: 0.1924, max: 0.1924 },
use: {value: 0.1924, min: 0.1924, max: 0.1924},
unit: 'kgCO2eq',
description: 'Total climate change',
},
Expand All @@ -133,7 +133,7 @@ mockAxios.post.mockImplementation(
'End of life is not included in the calculation',
],
},
use: { value: 5.126e-8, min: 5.126e-8, max: 5.126e-8 },
use: {value: 5.126e-8, min: 5.126e-8, max: 5.126e-8},
unit: 'kgSbeq',
description: 'Use of minerals and fossil ressources',
},
Expand All @@ -146,12 +146,12 @@ mockAxios.post.mockImplementation(
'End of life is not included in the calculation',
],
},
use: { value: 5.907, min: 5.907, max: 5.907 },
use: {value: 5.907, min: 5.907, max: 5.907},
unit: 'MJ',
description: 'Consumption of primary energy',
},
},
units: { value: 1, status: 'ARCHETYPE', min: 1, max: 1 },
units: {value: 1, status: 'ARCHETYPE', min: 1, max: 1},
die_size: {
value: 521,
status: 'COMPLETED',
Expand All @@ -160,15 +160,15 @@ mockAxios.post.mockImplementation(
min: 41.2,
max: 3640,
},
duration: { value: 2, unit: 'hours' },
duration: {value: 2, unit: 'hours'},
avg_power: {
value: 260.05,
status: 'COMPLETED',
unit: 'W',
min: 260.05,
max: 260.05,
},
time_workload: { value: 100, status: 'INPUT', unit: '%' },
time_workload: {value: 100, status: 'INPUT', unit: '%'},
usage_location: {
value: 'USA',
status: 'INPUT',
Expand All @@ -189,7 +189,7 @@ mockAxios.post.mockImplementation(
max: 26280,
},
params: {
value: { a: 171.2, b: 0.0354, c: 36.89, d: -10.13 },
value: {a: 171.2, b: 0.0354, c: 36.89, d: -10.13},
status: 'ARCHETYPE',
},
gwp_factor: {
Expand Down Expand Up @@ -230,7 +230,7 @@ mockAxios.post.mockImplementation(
max: 0.006226,
warnings: ['End of life is not included in the calculation'],
},
use: { value: 0.1924, min: 0.1924, max: 0.1924 },
use: {value: 0.1924, min: 0.1924, max: 0.1924},
unit: 'kgCO2eq',
description: 'Total climate change',
},
Expand All @@ -241,7 +241,7 @@ mockAxios.post.mockImplementation(
max: 0.000001554,
warnings: ['End of life is not included in the calculation'],
},
use: { value: 5.126e-8, min: 5.126e-8, max: 5.126e-8 },
use: {value: 5.126e-8, min: 5.126e-8, max: 5.126e-8},
unit: 'kgSbeq',
description: 'Use of minerals and fossil ressources',
},
Expand All @@ -252,7 +252,7 @@ mockAxios.post.mockImplementation(
max: 0.08627,
warnings: ['End of life is not included in the calculation'],
},
use: { value: 5.907, min: 5.907, max: 5.907 },
use: {value: 5.907, min: 5.907, max: 5.907},
unit: 'MJ',
description: 'Consumption of primary energy',
},
Expand All @@ -268,7 +268,7 @@ mockAxios.post.mockImplementation(
'End of life is not included in the calculation',
],
},
use: { value: 0.1924, min: 0.1924, max: 0.1924 },
use: {value: 0.1924, min: 0.1924, max: 0.1924},
unit: 'kgCO2eq',
description: 'Total climate change',
},
Expand All @@ -281,7 +281,7 @@ mockAxios.post.mockImplementation(
'End of life is not included in the calculation',
],
},
use: { value: 5.126e-8, min: 5.126e-8, max: 5.126e-8 },
use: {value: 5.126e-8, min: 5.126e-8, max: 5.126e-8},
unit: 'kgSbeq',
description: 'Use of minerals and fossil ressources',
},
Expand All @@ -294,12 +294,12 @@ mockAxios.post.mockImplementation(
'End of life is not included in the calculation',
],
},
use: { value: 5.907, min: 5.907, max: 5.907 },
use: {value: 5.907, min: 5.907, max: 5.907},
unit: 'MJ',
description: 'Consumption of primary energy',
},
},
units: { value: 1, status: 'ARCHETYPE', min: 1, max: 1 },
units: {value: 1, status: 'ARCHETYPE', min: 1, max: 1},
die_size: {
value: 521,
status: 'COMPLETED',
Expand All @@ -308,15 +308,15 @@ mockAxios.post.mockImplementation(
min: 41.2,
max: 3640,
},
duration: { value: 2, unit: 'hours' },
duration: {value: 2, unit: 'hours'},
avg_power: {
value: 260.05,
status: 'COMPLETED',
unit: 'W',
min: 260.05,
max: 260.05,
},
time_workload: { value: 100, status: 'INPUT', unit: '%' },
time_workload: {value: 100, status: 'INPUT', unit: '%'},
usage_location: {
value: 'USA',
status: 'INPUT',
Expand All @@ -337,7 +337,7 @@ mockAxios.post.mockImplementation(
max: 26280,
},
params: {
value: { a: 171.2, b: 0.0354, c: 36.89, d: -10.13 },
value: {a: 171.2, b: 0.0354, c: 36.89, d: -10.13},
status: 'ARCHETYPE',
},
gwp_factor: {
Expand Down Expand Up @@ -376,7 +376,7 @@ describe('cpu:configure test', () => {
test('initialize wrong params should throw error', async () => {
const outputModel = new BoaviztaCpuoutputModel();
await expect(
outputModel.configure('test', { allocation: 'wrong' })
outputModel.configure('test', {allocation: 'wrong'})
).rejects.toThrowError();
expect(outputModel.name).toBe('test');
});
Expand Down Expand Up @@ -422,10 +422,8 @@ describe('cpu:configure test', () => {
);
// improper inputs will throw an invalid inputs error
await expect(
outputModel.execute([{ invalid: 'input' }])
).rejects.toStrictEqual(
Error('Invalid Input: Invalid inputs parameter')
);
outputModel.execute([{invalid: 'input'}])
).rejects.toStrictEqual(Error('Invalid Input: Invalid inputs parameter'));
});
});

Expand Down Expand Up @@ -490,13 +488,13 @@ describe('cloud:initialize with params', () => {
const outputModel = new BoaviztaCloudoutputModel();
expect(outputModel.modelIdentifier()).toBe('org.boavizta.cloud.sci');
await expect(
outputModel.validateLocation({ location: 'SomethingFail' })
outputModel.validateLocation({location: 'SomethingFail'})
).rejects.toThrowError();
await expect(
outputModel.validateInstanceType({ 'instance-type': 'SomethingFail' })
outputModel.validateInstanceType({'instance-type': 'SomethingFail'})
).rejects.toThrowError();
await expect(
outputModel.validateProvider({ provider: 'SomethingFail' })
outputModel.validateProvider({provider: 'SomethingFail'})
).rejects.toThrowError();
await expect(
outputModel.configure('test', {
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/unit/lib/case-studies/aveva.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, jest, test } from '@jest/globals';
import { EAvevaModel } from '../../../../lib/case-studies/aveva-model';
import {describe, expect, jest, test} from '@jest/globals';
import {EAvevaModel} from '../../../../lib/case-studies/aveva-model';

jest.setTimeout(30000);

Expand Down
8 changes: 3 additions & 5 deletions src/__tests__/unit/lib/case-studies/emem.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, jest, test } from '@jest/globals';
import { EMemModel } from '../../../../lib/case-studies/emem-model';
import {describe, expect, jest, test} from '@jest/globals';
import {EMemModel} from '../../../../lib/case-studies/emem-model';

jest.setTimeout(30000);

Expand Down Expand Up @@ -51,9 +51,7 @@ describe('emem:configure test', () => {
await expect(outputModel.execute(undefined)).rejects.toThrow();
await expect(outputModel.execute({})).rejects.toThrow();
expect(outputModel.modelIdentifier()).toBe('energy-memory');
await expect(
outputModel.execute([{ timestamp: 'test' }])
).rejects.toThrow();
await expect(outputModel.execute([{timestamp: 'test'}])).rejects.toThrow();
await expect(
outputModel.execute([
{
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/unit/lib/case-studies/eshoppen.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, expect, jest, test } from '@jest/globals';
import {describe, expect, jest, test} from '@jest/globals';
import {
EshoppenMemModel,
EshoppenModel,
Expand Down Expand Up @@ -32,7 +32,7 @@ describe('eshoppen:configure test', () => {
]);
await expect(model.execute([{}])).rejects.toThrowError();
await expect(model.execute({})).rejects.toThrowError();
expect(model.authenticate({ test: 'test' })).toBe(undefined);
expect(model.authenticate({test: 'test'})).toBe(undefined);

const model2 = await new EshoppenMemModel().configure('eshoppen', {
type: 'energy-memory',
Expand Down
Loading

0 comments on commit cd6e1bf

Please sign in to comment.