diff --git a/scripts/impact.ts b/scripts/impact.ts index 897414545..5df83f986 100644 --- a/scripts/impact.ts +++ b/scripts/impact.ts @@ -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. @@ -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)) { diff --git a/src/__mocks__/fs/index.ts b/src/__mocks__/fs/index.ts index 5dcfdd9f4..2ad89de81 100644 --- a/src/__mocks__/fs/index.ts +++ b/src/__mocks__/fs/index.ts @@ -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'; @@ -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); diff --git a/src/__mocks__/model-universe/index.ts b/src/__mocks__/model-universe/index.ts index a24494ac5..3cb8aaca9 100644 --- a/src/__mocks__/model-universe/index.ts +++ b/src/__mocks__/model-universe/index.ts @@ -1,4 +1,4 @@ -import { IoutputModelInterface } from '../../lib'; +import {IoutputModelInterface} from '../../lib'; import { ImplInitializeModel, @@ -14,9 +14,9 @@ class MockModel implements IoutputModelInterface { return Promise.resolve(this); } execute(): Promise { - return Promise.resolve([{ data: 'mock-data' }]); + return Promise.resolve([{data: 'mock-data'}]); } - authenticate(): void { } + authenticate(): void {} } /** @@ -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(); diff --git a/src/__tests__/integration/ompl/index.test.ts b/src/__tests__/integration/ompl/index.test.ts index b1b1aed94..51cf33155 100644 --- a/src/__tests__/integration/ompl/index.test.ts +++ b/src/__tests__/integration/ompl/index.test.ts @@ -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); @@ -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(); }); } diff --git a/src/__tests__/unit/lib/boavizta/index.test.ts b/src/__tests__/unit/lib/boavizta/index.test.ts index e3f8d9f64..625598aeb 100644 --- a/src/__tests__/unit/lib/boavizta/index.test.ts +++ b/src/__tests__/unit/lib/boavizta/index.test.ts @@ -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'; @@ -13,9 +13,9 @@ async function axiosGet>( ): Promise { 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'], @@ -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', }, @@ -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', }, @@ -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', }, @@ -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', }, @@ -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', }, @@ -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', }, @@ -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', }, @@ -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', }, @@ -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', @@ -160,7 +160,7 @@ 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', @@ -168,7 +168,7 @@ mockAxios.post.mockImplementation( 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', @@ -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: { @@ -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', }, @@ -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', }, @@ -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', }, @@ -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', }, @@ -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', }, @@ -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', @@ -308,7 +308,7 @@ 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', @@ -316,7 +316,7 @@ mockAxios.post.mockImplementation( 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', @@ -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: { @@ -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'); }); @@ -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')); }); }); @@ -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', { diff --git a/src/__tests__/unit/lib/case-studies/aveva.test.ts b/src/__tests__/unit/lib/case-studies/aveva.test.ts index b14b487ae..9c58953b7 100644 --- a/src/__tests__/unit/lib/case-studies/aveva.test.ts +++ b/src/__tests__/unit/lib/case-studies/aveva.test.ts @@ -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); diff --git a/src/__tests__/unit/lib/case-studies/emem.test.ts b/src/__tests__/unit/lib/case-studies/emem.test.ts index aab3637a9..99c905535 100644 --- a/src/__tests__/unit/lib/case-studies/emem.test.ts +++ b/src/__tests__/unit/lib/case-studies/emem.test.ts @@ -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); @@ -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([ { diff --git a/src/__tests__/unit/lib/case-studies/eshoppen.test.ts b/src/__tests__/unit/lib/case-studies/eshoppen.test.ts index da1b98c29..1c52bf5e0 100644 --- a/src/__tests__/unit/lib/case-studies/eshoppen.test.ts +++ b/src/__tests__/unit/lib/case-studies/eshoppen.test.ts @@ -1,4 +1,4 @@ -import { describe, expect, jest, test } from '@jest/globals'; +import {describe, expect, jest, test} from '@jest/globals'; import { EshoppenMemModel, EshoppenModel, @@ -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', diff --git a/src/__tests__/unit/lib/case-studies/sci-accenture.test.ts b/src/__tests__/unit/lib/case-studies/sci-accenture.test.ts index 09b84e43c..57036c7d2 100644 --- a/src/__tests__/unit/lib/case-studies/sci-accenture.test.ts +++ b/src/__tests__/unit/lib/case-studies/sci-accenture.test.ts @@ -1,5 +1,5 @@ -import { describe, expect, jest, test } from '@jest/globals'; -import { SciAccentureModel } from '../../../../lib/case-studies/sci-accenture-model'; +import {describe, expect, jest, test} from '@jest/globals'; +import {SciAccentureModel} from '../../../../lib/case-studies/sci-accenture-model'; jest.setTimeout(30000); diff --git a/src/__tests__/unit/lib/ccf/index.test.ts b/src/__tests__/unit/lib/ccf/index.test.ts index 2fc923087..b051bbe9e 100644 --- a/src/__tests__/unit/lib/ccf/index.test.ts +++ b/src/__tests__/unit/lib/ccf/index.test.ts @@ -1,5 +1,5 @@ -import { describe, expect, jest, test } from '@jest/globals'; -import { CloudCarbonFootprint } from '../../../../lib/ccf/index'; +import {describe, expect, jest, test} from '@jest/globals'; +import {CloudCarbonFootprint} from '../../../../lib/ccf/index'; jest.setTimeout(30000); @@ -27,7 +27,7 @@ describe('ccf:configure test', () => { }); await expect( outputModel.execute([ - { duration: 3600, 'cpu-util': 50, timestamp: '2021-01-01T00:00:00Z' }, + {duration: 3600, 'cpu-util': 50, timestamp: '2021-01-01T00:00:00Z'}, ]) ).resolves.toStrictEqual([ { @@ -45,7 +45,7 @@ describe('ccf:configure test', () => { }); await expect( outputModel.execute([ - { duration: 3600, 'cpu-util': 50, timestamp: '2021-01-01T00:00:00Z' }, + {duration: 3600, 'cpu-util': 50, timestamp: '2021-01-01T00:00:00Z'}, ]) ).resolves.toStrictEqual([ { @@ -214,7 +214,7 @@ describe('ccf:configure test', () => { ).rejects.toThrowError(); await expect( outputModel.execute([ - { duration: 3600, 'cpu-util': 50, timestamp: '2021-01-01T00:00:00Z' }, + {duration: 3600, 'cpu-util': 50, timestamp: '2021-01-01T00:00:00Z'}, ]) ).rejects.toThrowError(); }); @@ -228,7 +228,7 @@ describe('ccf:configure test', () => { ).rejects.toThrowError(); await expect( outputModel.execute([ - { duration: 3600, 'cpu-util': 50, timestamp: '2021-01-01T00:00:00Z' }, + {duration: 3600, 'cpu-util': 50, timestamp: '2021-01-01T00:00:00Z'}, ]) ).rejects.toThrowError(); }); @@ -243,7 +243,7 @@ describe('ccf:configure test', () => { ).resolves.toBeInstanceOf(CloudCarbonFootprint); await expect( outputModel.execute([ - { duration: 3600, cpus: 1, timestamp: '2021-01-01T00:00:00Z' }, + {duration: 3600, cpus: 1, timestamp: '2021-01-01T00:00:00Z'}, ]) ).rejects.toThrowError(); }); diff --git a/src/__tests__/unit/lib/cloud-interface-metadata/index.test.ts b/src/__tests__/unit/lib/cloud-interface-metadata/index.test.ts index dd775ee7e..146bb4e53 100644 --- a/src/__tests__/unit/lib/cloud-interface-metadata/index.test.ts +++ b/src/__tests__/unit/lib/cloud-interface-metadata/index.test.ts @@ -1,5 +1,5 @@ -import { describe, expect, jest, test } from '@jest/globals'; -import { CloudInstanceMetadataModel } from '../../../../lib/cloud-instance-metadata/index'; +import {describe, expect, jest, test} from '@jest/globals'; +import {CloudInstanceMetadataModel} from '../../../../lib/cloud-instance-metadata/index'; jest.setTimeout(30000); diff --git a/src/__tests__/unit/lib/sci-e/index.test.ts b/src/__tests__/unit/lib/sci-e/index.test.ts index 194eac91c..5b5b44841 100644 --- a/src/__tests__/unit/lib/sci-e/index.test.ts +++ b/src/__tests__/unit/lib/sci-e/index.test.ts @@ -1,5 +1,5 @@ -import { describe, expect, jest, test } from '@jest/globals'; -import { SciEModel } from '../../../../lib/sci-e/index'; +import {describe, expect, jest, test} from '@jest/globals'; +import {SciEModel} from '../../../../lib/sci-e/index'; jest.setTimeout(30000); diff --git a/src/__tests__/unit/lib/sci-m/index.test.ts b/src/__tests__/unit/lib/sci-m/index.test.ts index 2ba88ce58..4cff01d9b 100644 --- a/src/__tests__/unit/lib/sci-m/index.test.ts +++ b/src/__tests__/unit/lib/sci-m/index.test.ts @@ -1,5 +1,5 @@ -import { describe, expect, jest, test } from '@jest/globals'; -import { SciMModel } from '../../../../lib/sci-m/index'; +import {describe, expect, jest, test} from '@jest/globals'; +import {SciMModel} from '../../../../lib/sci-m/index'; jest.setTimeout(30000); describe('sci-o:configure test', () => { diff --git a/src/__tests__/unit/lib/sci-o/index.test.ts b/src/__tests__/unit/lib/sci-o/index.test.ts index 92c832b27..10af3bd70 100644 --- a/src/__tests__/unit/lib/sci-o/index.test.ts +++ b/src/__tests__/unit/lib/sci-o/index.test.ts @@ -1,5 +1,5 @@ -import { describe, expect, jest, test } from '@jest/globals'; -import { SciOModel } from '../../../../lib/sci-o/index'; +import {describe, expect, jest, test} from '@jest/globals'; +import {SciOModel} from '../../../../lib/sci-o/index'; jest.setTimeout(30000); describe('ccf:configure test', () => { diff --git a/src/__tests__/unit/lib/sci/index.test.ts b/src/__tests__/unit/lib/sci/index.test.ts index d79b11b03..af25c3a36 100644 --- a/src/__tests__/unit/lib/sci/index.test.ts +++ b/src/__tests__/unit/lib/sci/index.test.ts @@ -1,5 +1,5 @@ -import { describe, expect, jest, test } from '@jest/globals'; -import { SciModel } from '../../../../lib/sci/index'; +import {describe, expect, jest, test} from '@jest/globals'; +import {SciModel} from '../../../../lib/sci/index'; jest.setTimeout(30000); describe('sci:configure test', () => { diff --git a/src/__tests__/unit/lib/shell-imp/index.test.ts b/src/__tests__/unit/lib/shell-imp/index.test.ts index b74f01655..45787d89d 100644 --- a/src/__tests__/unit/lib/shell-imp/index.test.ts +++ b/src/__tests__/unit/lib/shell-imp/index.test.ts @@ -1,5 +1,5 @@ -import { describe, expect, jest, test } from '@jest/globals'; -import { ShellModel } from '../../../../lib/shell-imp/index'; +import {describe, expect, jest, test} from '@jest/globals'; +import {ShellModel} from '../../../../lib/shell-imp/index'; jest.setTimeout(30000); @@ -14,10 +14,10 @@ describe('lib/shell-imp: ', () => { }); await expect( outputModel.execute([ - { duration: 3600, cpu: 0.5, datetime: '2021-01-01T00:00:00Z' }, + {duration: 3600, cpu: 0.5, datetime: '2021-01-01T00:00:00Z'}, ]) ).resolves.toStrictEqual([ - { duration: 3600, cpu: 0.5, datetime: '2021-01-01T00:00:00Z', energy: 1 }, + {duration: 3600, cpu: 0.5, datetime: '2021-01-01T00:00:00Z', energy: 1}, ]); }); }); diff --git a/src/__tests__/unit/lib/teads-aws/index.test.ts b/src/__tests__/unit/lib/teads-aws/index.test.ts index e90d363b8..7d8611635 100644 --- a/src/__tests__/unit/lib/teads-aws/index.test.ts +++ b/src/__tests__/unit/lib/teads-aws/index.test.ts @@ -1,7 +1,7 @@ -import { describe, expect, jest, test } from '@jest/globals'; -import { TeadsAWS } from '../../../../lib/teads-aws/index'; +import {describe, expect, jest, test} from '@jest/globals'; +import {TeadsAWS} from '../../../../lib/teads-aws/index'; -import { Interpolation } from '../../../../types/common'; +import {Interpolation} from '../../../../types/common'; jest.setTimeout(30000); diff --git a/src/__tests__/unit/lib/teads-curve/index.test.ts b/src/__tests__/unit/lib/teads-curve/index.test.ts index 5e584fa43..e5fb78e34 100644 --- a/src/__tests__/unit/lib/teads-curve/index.test.ts +++ b/src/__tests__/unit/lib/teads-curve/index.test.ts @@ -1,5 +1,5 @@ -import { describe, expect, jest, test } from '@jest/globals'; -import { TeadsCurveModel } from '../../../../lib/teads-curve/index'; +import {describe, expect, jest, test} from '@jest/globals'; +import {TeadsCurveModel} from '../../../../lib/teads-curve/index'; jest.setTimeout(30000); diff --git a/src/__tests__/unit/lib/watt-time/index.test.ts b/src/__tests__/unit/lib/watt-time/index.test.ts index 7d521c1fd..f1fadeb41 100644 --- a/src/__tests__/unit/lib/watt-time/index.test.ts +++ b/src/__tests__/unit/lib/watt-time/index.test.ts @@ -1,5 +1,5 @@ -import { describe, expect, jest, test } from '@jest/globals'; -import { WattTimeGridEmissions } from '../../../../lib/watt-time/index'; +import {describe, expect, jest, test} from '@jest/globals'; +import {WattTimeGridEmissions} from '../../../../lib/watt-time/index'; import * as DATA from '../../../../__mocks__/watt-time/data.json'; import axios from 'axios'; diff --git a/src/__tests__/unit/util/args.test.ts b/src/__tests__/unit/util/args.test.ts index 0355746e6..07ec697d1 100644 --- a/src/__tests__/unit/util/args.test.ts +++ b/src/__tests__/unit/util/args.test.ts @@ -27,15 +27,15 @@ jest.mock('ts-command-line-args', () => ({ })); import path = require('path'); -import { describe, expect, it, jest } from '@jest/globals'; +import {describe, expect, it, jest} from '@jest/globals'; -import { parseProcessArgument } from '../../../util/args'; +import {parseProcessArgument} from '../../../util/args'; -import { STRINGS, CONFIG } from '../../../config'; +import {STRINGS, CONFIG} from '../../../config'; -const { impact } = CONFIG; -const { HELP } = impact; -const { WRONG_CLI_ARGUMENT } = STRINGS; +const {impact} = CONFIG; +const {HELP} = impact; +const {WRONG_CLI_ARGUMENT} = STRINGS; describe('util/args: ', () => { const originalEnv = process.env; diff --git a/src/__tests__/unit/util/models-universe.test.ts b/src/__tests__/unit/util/models-universe.test.ts index 57316defe..88653168d 100644 --- a/src/__tests__/unit/util/models-universe.test.ts +++ b/src/__tests__/unit/util/models-universe.test.ts @@ -1,8 +1,8 @@ -import { describe, expect, it } from '@jest/globals'; +import {describe, expect, it} from '@jest/globals'; -import { ModelsUniverse } from '../../../util/models-universe'; -import { ImplInitializeModel } from '../../../types/models-universe'; -import { BoaviztaCpuoutputModel } from '../../../lib'; +import {ModelsUniverse} from '../../../util/models-universe'; +import {ImplInitializeModel} from '../../../types/models-universe'; +import {BoaviztaCpuoutputModel} from '../../../lib'; describe('util/models-universe: ', () => { describe('init ModelsUniverse', () => { diff --git a/src/__tests__/unit/util/observatory.test.ts b/src/__tests__/unit/util/observatory.test.ts index bfa1b1763..f1535bc7c 100644 --- a/src/__tests__/unit/util/observatory.test.ts +++ b/src/__tests__/unit/util/observatory.test.ts @@ -1,6 +1,6 @@ -import { describe, expect, it, jest } from '@jest/globals'; -import { Observatory } from '../../../util/observatory'; -import { BoaviztaCpuoutputModel } from '../../../lib'; +import {describe, expect, it, jest} from '@jest/globals'; +import {Observatory} from '../../../util/observatory'; +import {BoaviztaCpuoutputModel} from '../../../lib'; describe('util/observatory: ', () => { const expectedValue = [ diff --git a/src/__tests__/unit/util/supercomputer.test.ts b/src/__tests__/unit/util/supercomputer.test.ts index a2dad2454..a0b25b86d 100644 --- a/src/__tests__/unit/util/supercomputer.test.ts +++ b/src/__tests__/unit/util/supercomputer.test.ts @@ -1,14 +1,14 @@ -import { ModelsUniverse as MockModelUniverse } from '../../../__mocks__/model-universe'; +import {ModelsUniverse as MockModelUniverse} from '../../../__mocks__/model-universe'; jest.mock('../../../util/models-universe', () => ({ __esModule: true, ModelsUniverse: MockModelUniverse, })); -import { describe, expect, it, jest } from '@jest/globals'; +import {describe, expect, it, jest} from '@jest/globals'; -import { Supercomputer } from '../../../util/supercomputer'; -import { ModelsUniverse } from '../../../util/models-universe'; +import {Supercomputer} from '../../../util/supercomputer'; +import {ModelsUniverse} from '../../../util/models-universe'; describe('util/supercomputer: ', () => { const impl = { diff --git a/src/config/config.ts b/src/config/config.ts index eccfa596b..b19dc7f97 100644 --- a/src/config/config.ts +++ b/src/config/config.ts @@ -1,6 +1,6 @@ -import { ArgumentConfig } from 'ts-command-line-args'; +import {ArgumentConfig} from 'ts-command-line-args'; -import { impactProcessArgs } from '../types/process-args'; +import {impactProcessArgs} from '../types/process-args'; export const CONFIG = { MODEL_IDS: { diff --git a/src/lib/boavizta/index.ts b/src/lib/boavizta/index.ts index f6f3aba57..5a9690b87 100644 --- a/src/lib/boavizta/index.ts +++ b/src/lib/boavizta/index.ts @@ -1,13 +1,13 @@ import axios from 'axios'; -import { IoutputModelInterface } from '../interfaces'; -import { CONFIG } from '../../config'; +import {IoutputModelInterface} from '../interfaces'; +import {CONFIG} from '../../config'; -import { BoaviztaInstanceTypes, IBoaviztaUsageSCI } from '../../types/boavizta'; -import { KeyValuePair } from '../../types/common'; +import {BoaviztaInstanceTypes, IBoaviztaUsageSCI} from '../../types/boavizta'; +import {KeyValuePair} from '../../types/common'; -const { MODEL_IDS } = CONFIG; -const { BOAVIZTA_CPU, BOAVIZTA_CLOUD } = MODEL_IDS; +const {MODEL_IDS} = CONFIG; +const {BOAVIZTA_CPU, BOAVIZTA_CLOUD} = MODEL_IDS; abstract class BoaviztaoutputModel implements IoutputModelInterface { name: string | undefined; @@ -67,9 +67,7 @@ abstract class BoaviztaoutputModel implements IoutputModelInterface { const results: KeyValuePair[] = []; for (const input of inputs) { - const usageResult = await this.calculateUsageForinput( - input - ); + const usageResult = await this.calculateUsageForinput(input); results.push(usageResult); } @@ -113,7 +111,7 @@ abstract class BoaviztaoutputModel implements IoutputModelInterface { e = data['pe']['use'] / 3.6; } - return { 'embodied-carbon': m, energy: e }; + return {'embodied-carbon': m, energy: e}; } // converts the usage to the format required by Boavizta API. @@ -140,7 +138,8 @@ abstract class BoaviztaoutputModel implements IoutputModelInterface { export class BoaviztaCpuoutputModel extends BoaviztaoutputModel - implements IoutputModelInterface { + implements IoutputModelInterface +{ sharedParams: object | undefined = undefined; public name: string | undefined; public verbose = false; @@ -209,7 +208,8 @@ export class BoaviztaCpuoutputModel export class BoaviztaCloudoutputModel extends BoaviztaoutputModel - implements IoutputModelInterface { + implements IoutputModelInterface +{ public sharedParams: object | undefined = undefined; public instanceTypes: BoaviztaInstanceTypes = {}; public name: string | undefined; @@ -227,9 +227,9 @@ export class BoaviztaCloudoutputModel if (!countries.includes(location)) { throw new Error( "Improper configure: Invalid location parameter: '" + - location + - "'. Valid values are : " + - countries.join(', ') + location + + "'. Valid values are : " + + countries.join(', ') ); } return staticParamsCast.location as string; @@ -263,7 +263,8 @@ export class BoaviztaCloudoutputModel ) ) { throw new Error( - `Improper configure: Invalid 'instance-type' parameter: '${staticParamsCast['instance-type'] + `Improper configure: Invalid 'instance-type' parameter: '${ + staticParamsCast['instance-type'] }'. Valid values are : ${this.instanceTypes[provider].join(', ')}` ); } @@ -279,9 +280,9 @@ export class BoaviztaCloudoutputModel if (!supportedProviders.includes(staticParamsCast.provider as string)) { throw new Error( "Improper configure: Invalid provider parameter: '" + - staticParamsCast.provider + - "'. Valid values are : " + - supportedProviders.join(', ') + staticParamsCast.provider + + "'. Valid values are : " + + supportedProviders.join(', ') ); } } @@ -356,6 +357,6 @@ export class BoaviztaCloudoutputModel /** * For JSII. */ -export { IoutputModelInterface } from '../interfaces'; -export { BoaviztaInstanceTypes, IBoaviztaUsageSCI } from '../../types/boavizta'; -export { KeyValuePair } from '../../types/common'; +export {IoutputModelInterface} from '../interfaces'; +export {BoaviztaInstanceTypes, IBoaviztaUsageSCI} from '../../types/boavizta'; +export {KeyValuePair} from '../../types/common'; diff --git a/src/lib/case-studies/aveva-model.ts b/src/lib/case-studies/aveva-model.ts index 9c389274d..c078b0b72 100644 --- a/src/lib/case-studies/aveva-model.ts +++ b/src/lib/case-studies/aveva-model.ts @@ -1,9 +1,9 @@ -import { IoutputModelInterface } from '../interfaces'; +import {IoutputModelInterface} from '../interfaces'; -import { CONFIG } from '../../config'; +import {CONFIG} from '../../config'; -const { MODEL_IDS } = CONFIG; -const { AVEVA } = MODEL_IDS; +const {MODEL_IDS} = CONFIG; +const {AVEVA} = MODEL_IDS; export class EAvevaModel implements IoutputModelInterface { authParams: object | undefined; // Defined for compatibility. Not used in Aveva. diff --git a/src/lib/case-studies/emem-model.ts b/src/lib/case-studies/emem-model.ts index 1f91acb73..809f459e7 100644 --- a/src/lib/case-studies/emem-model.ts +++ b/src/lib/case-studies/emem-model.ts @@ -1,11 +1,11 @@ -import { IoutputModelInterface } from '../interfaces'; +import {IoutputModelInterface} from '../interfaces'; -import { CONFIG } from '../../config'; +import {CONFIG} from '../../config'; -import { KeyValuePair } from '../../types/common'; +import {KeyValuePair} from '../../types/common'; -const { MODEL_IDS } = CONFIG; -const { EMEM } = MODEL_IDS; +const {MODEL_IDS} = CONFIG; +const {EMEM} = MODEL_IDS; export class EMemModel implements IoutputModelInterface { authParams: object | undefined; // Defined for compatibility. Not used in this. diff --git a/src/lib/case-studies/eshoppen-model.ts b/src/lib/case-studies/eshoppen-model.ts index 85a4ca867..c0ee0a39e 100644 --- a/src/lib/case-studies/eshoppen-model.ts +++ b/src/lib/case-studies/eshoppen-model.ts @@ -1,13 +1,13 @@ -import { IoutputModelInterface } from '../interfaces'; +import {IoutputModelInterface} from '../interfaces'; -import { CONFIG } from '../../config'; +import {CONFIG} from '../../config'; -import { KeyValuePair } from '../../types/common'; +import {KeyValuePair} from '../../types/common'; -export { KeyValuePair } from '../../types/common'; +export {KeyValuePair} from '../../types/common'; -const { MODEL_IDS } = CONFIG; -const { ESHOPPEN, ESHOPPEN_CPU, ESHOPPEN_MEM, ESHOPPEN_NET } = MODEL_IDS; +const {MODEL_IDS} = CONFIG; +const {ESHOPPEN, ESHOPPEN_CPU, ESHOPPEN_MEM, ESHOPPEN_NET} = MODEL_IDS; export class EshoppenModel implements IoutputModelInterface { authParams: object | undefined = undefined; @@ -59,8 +59,7 @@ export class EshoppenModel implements IoutputModelInterface { case 'energy-network': { // energy-network = data-in + data-out * net-energy input['energy-network'] = - ((input['data-in'] + input['data-out']) * - input['net-energy']) / + ((input['data-in'] + input['data-out']) * input['net-energy']) / 1000; if (isNaN(input['energy-network'])) { diff --git a/src/lib/case-studies/sci-accenture-model.ts b/src/lib/case-studies/sci-accenture-model.ts index 42d5a335d..92900007a 100644 --- a/src/lib/case-studies/sci-accenture-model.ts +++ b/src/lib/case-studies/sci-accenture-model.ts @@ -1,11 +1,11 @@ -import { IoutputModelInterface } from '../interfaces'; +import {IoutputModelInterface} from '../interfaces'; -import { CONFIG } from '../../config'; +import {CONFIG} from '../../config'; -import { KeyValuePair } from '../../types/common'; +import {KeyValuePair} from '../../types/common'; -const { MODEL_IDS } = CONFIG; -const { SCI_ACCENTURE } = MODEL_IDS; +const {MODEL_IDS} = CONFIG; +const {SCI_ACCENTURE} = MODEL_IDS; export class SciAccentureModel implements IoutputModelInterface { authParams: object | undefined = undefined; diff --git a/src/lib/ccf/index.ts b/src/lib/ccf/index.ts index 4176e5b6f..334e1512b 100644 --- a/src/lib/ccf/index.ts +++ b/src/lib/ccf/index.ts @@ -1,9 +1,9 @@ import Spline from 'typescript-cubic-spline'; -import { IComputeInstance, IoutputModelInterface } from '../interfaces'; -import { INSTANCE_TYPE_COMPUTE_PROCESSOR_MAPPING } from '@cloud-carbon-footprint/aws/dist/lib/AWSInstanceTypes'; +import {IComputeInstance, IoutputModelInterface} from '../interfaces'; +import {INSTANCE_TYPE_COMPUTE_PROCESSOR_MAPPING} from '@cloud-carbon-footprint/aws/dist/lib/AWSInstanceTypes'; -import { CONFIG } from '../../config'; +import {CONFIG} from '../../config'; import * as AWS_INSTANCES from './aws-instances.json'; import * as GCP_INSTANCES from './gcp-instances.json'; @@ -15,10 +15,10 @@ import * as GCP_EMBODIED from './gcp-embodied.json'; import * as AWS_EMBODIED from './aws-embodied.json'; import * as AZURE_EMBODIED from './azure-embodied.json'; -import { KeyValuePair, Interpolation } from '../../types/common'; +import {KeyValuePair, Interpolation} from '../../types/common'; -const { MODEL_IDS } = CONFIG; -const { CCF } = MODEL_IDS; +const {MODEL_IDS} = CONFIG; +const {CCF} = MODEL_IDS; export class CloudCarbonFootprint implements IoutputModelInterface { // Defined for compatibility. Not used in CCF. @@ -241,11 +241,11 @@ export class CloudCarbonFootprint implements IoutputModelInterface { architecture = this.resolveAwsArchitecture(architecture); minWatts += this.computeInstanceUsageByArchitecture['aws'][architecture][ - 'Min Watts' + 'Min Watts' ] ?? 0; maxWatts += this.computeInstanceUsageByArchitecture['aws'][architecture][ - 'Max Watts' + 'Max Watts' ] ?? 0; count += 1; }); @@ -282,11 +282,11 @@ export class CloudCarbonFootprint implements IoutputModelInterface { consumption: { minWatts: this.computeInstanceUsageByArchitecture['gcp'][architecture][ - 'Min Watts' + 'Min Watts' ] * cpus, maxWatts: this.computeInstanceUsageByArchitecture['gcp'][architecture][ - 'Max Watts' + 'Max Watts' ] * cpus, }, maxvCPUs: parseInt( @@ -305,11 +305,11 @@ export class CloudCarbonFootprint implements IoutputModelInterface { consumption: { minWatts: this.computeInstanceUsageByArchitecture['azure'][architecture][ - 'Min Watts' + 'Min Watts' ] * cpus, maxWatts: this.computeInstanceUsageByArchitecture['azure'][architecture][ - 'Max Watts' + 'Max Watts' ] * cpus, }, name: instance['Virtual Machine'], diff --git a/src/lib/cloud-instance-metadata/index.ts b/src/lib/cloud-instance-metadata/index.ts index 7f66c70a0..7faf67529 100644 --- a/src/lib/cloud-instance-metadata/index.ts +++ b/src/lib/cloud-instance-metadata/index.ts @@ -1,12 +1,12 @@ -import { IoutputModelInterface } from '../interfaces'; +import {IoutputModelInterface} from '../interfaces'; -import { CONFIG } from '../../config'; +import {CONFIG} from '../../config'; -import { KeyValuePair } from '../../types/common'; +import {KeyValuePair} from '../../types/common'; import * as AWS_INSTANCES from './aws-instances.json'; -const { MODEL_IDS } = CONFIG; -const { CLOUD_INSTANCE_METADATA } = MODEL_IDS; +const {MODEL_IDS} = CONFIG; +const {CLOUD_INSTANCE_METADATA} = MODEL_IDS; export class CloudInstanceMetadataModel implements IoutputModelInterface { authParams: object | undefined = undefined; @@ -45,9 +45,7 @@ export class CloudInstanceMetadataModel implements IoutputModelInterface { if ('cloud-instance-type' in input) { instance_type = input['cloud-instance-type']; } else { - throw new Error( - 'Each input must contain a cloud-instance-type key' - ); + throw new Error('Each input must contain a cloud-instance-type key'); } if (vendor !== 'aws') { throw new Error('cloud-vendor: Only `aws` is currently supported'); diff --git a/src/lib/sci-e/index.ts b/src/lib/sci-e/index.ts index 2af3d2d91..60e99fad0 100644 --- a/src/lib/sci-e/index.ts +++ b/src/lib/sci-e/index.ts @@ -1,11 +1,11 @@ -import { IoutputModelInterface } from '../interfaces'; +import {IoutputModelInterface} from '../interfaces'; -import { CONFIG } from '../../config'; +import {CONFIG} from '../../config'; -import { KeyValuePair } from '../../types/common'; +import {KeyValuePair} from '../../types/common'; -const { MODEL_IDS } = CONFIG; -const { SCI_E } = MODEL_IDS; +const {MODEL_IDS} = CONFIG; +const {SCI_E} = MODEL_IDS; export class SciEModel implements IoutputModelInterface { authParams: object | undefined; // Defined for compatibility. Not used in thi smodel. diff --git a/src/lib/sci-m/index.ts b/src/lib/sci-m/index.ts index 0b264a031..0c8522d76 100644 --- a/src/lib/sci-m/index.ts +++ b/src/lib/sci-m/index.ts @@ -1,11 +1,11 @@ -import { IoutputModelInterface } from '../interfaces'; +import {IoutputModelInterface} from '../interfaces'; -import { CONFIG } from '../../config'; +import {CONFIG} from '../../config'; -import { KeyValuePair } from '../../types/common'; +import {KeyValuePair} from '../../types/common'; -const { MODEL_IDS } = CONFIG; -const { SCI_M } = MODEL_IDS; +const {MODEL_IDS} = CONFIG; +const {SCI_M} = MODEL_IDS; export class SciMModel implements IoutputModelInterface { authParams: object | undefined = undefined; @@ -45,25 +45,13 @@ export class SciMModel implements IoutputModelInterface { if (!('time-reserved' in input || 'time-reserved' in input)) { throw new Error('time-reserved is missing. Provide in seconds'); } - if ( - !( - 'expected-lifespan' in input || - 'expected-lifespan' in input - ) - ) { + if (!('expected-lifespan' in input || 'expected-lifespan' in input)) { throw new Error('expected-lifespan is missing. Provide in seconds'); } - if ( - !( - 'resources-reserved' in input || - 'resources-reserved' in input - ) - ) { + if (!('resources-reserved' in input || 'resources-reserved' in input)) { throw new Error('resources-reserved is missing. Provide as a count'); } - if ( - !('total-resources' in input || 'total-resources' in input) - ) { + if (!('total-resources' in input || 'total-resources' in input)) { throw new Error( 'total-resources: total-resources is missing. Provide as a count' ); @@ -84,15 +72,12 @@ export class SciMModel implements IoutputModelInterface { input['expected-lifespan'] = input['expected-lifespan'] ?? input['expected-lifespan']; input['resources-reserved'] = - input['resources-reserved'] ?? - input['resources-reserved']; + input['resources-reserved'] ?? input['resources-reserved']; input['total-resources'] = input['total-resources'] ?? input['total-resources']; if (typeof input['total-embodied-emissions'] === 'string') { te = parseFloat(input[input['total-embodied-emissions']]); - } else if ( - typeof input['total-embodied-emissions'] === 'number' - ) { + } else if (typeof input['total-embodied-emissions'] === 'number') { te = input['total-embodied-emissions']; } else { te = parseFloat(input['total-embodied-emissions']); diff --git a/src/lib/sci-o/index.ts b/src/lib/sci-o/index.ts index 936dbf8b3..1b33a5e0f 100644 --- a/src/lib/sci-o/index.ts +++ b/src/lib/sci-o/index.ts @@ -1,11 +1,11 @@ -import { IoutputModelInterface } from '../interfaces'; +import {IoutputModelInterface} from '../interfaces'; -import { CONFIG } from '../../config'; +import {CONFIG} from '../../config'; -import { KeyValuePair } from '../../types/common'; +import {KeyValuePair} from '../../types/common'; -const { MODEL_IDS } = CONFIG; -const { SCI_O } = MODEL_IDS; +const {MODEL_IDS} = CONFIG; +const {SCI_O} = MODEL_IDS; export class SciOModel implements IoutputModelInterface { authParams: object | undefined = undefined; diff --git a/src/lib/sci/index.test.ts b/src/lib/sci/index.test.ts index 9054ca323..00f7b19bb 100644 --- a/src/lib/sci/index.test.ts +++ b/src/lib/sci/index.test.ts @@ -1,5 +1,5 @@ -import { describe, expect, jest, test } from '@jest/globals'; -import { SciModel } from './index'; +import {describe, expect, jest, test} from '@jest/globals'; +import {SciModel} from './index'; jest.setTimeout(30000); describe('sci:configure test', () => { diff --git a/src/lib/sci/index.ts b/src/lib/sci/index.ts index 8a0b28e2c..5fd190503 100644 --- a/src/lib/sci/index.ts +++ b/src/lib/sci/index.ts @@ -1,11 +1,11 @@ -import { IoutputModelInterface } from '../interfaces'; +import {IoutputModelInterface} from '../interfaces'; -import { CONFIG } from '../../config'; +import {CONFIG} from '../../config'; -import { KeyValuePair } from '../../types/common'; +import {KeyValuePair} from '../../types/common'; -const { MODEL_IDS } = CONFIG; -const { SCI } = MODEL_IDS; +const {MODEL_IDS} = CONFIG; +const {SCI} = MODEL_IDS; export class SciModel implements IoutputModelInterface { authParams: object | undefined = undefined; diff --git a/src/lib/shell-imp/index.ts b/src/lib/shell-imp/index.ts index 65bedaf2d..34e09935a 100644 --- a/src/lib/shell-imp/index.ts +++ b/src/lib/shell-imp/index.ts @@ -1,14 +1,14 @@ import * as cp from 'child_process'; import * as yaml from 'js-yaml'; -import { IoutputModelInterface } from '../interfaces'; +import {IoutputModelInterface} from '../interfaces'; -import { CONFIG } from '../../config'; +import {CONFIG} from '../../config'; -import { KeyValuePair } from '../../types/common'; +import {KeyValuePair} from '../../types/common'; -const { MODEL_IDS } = CONFIG; -const { SHELL_MODEL } = MODEL_IDS; +const {MODEL_IDS} = CONFIG; +const {SHELL_MODEL} = MODEL_IDS; export class ShellModel implements IoutputModelInterface { authParams: object | undefined; // Defined for compatibility. Not used. diff --git a/src/lib/teads-aws/index.ts b/src/lib/teads-aws/index.ts index 903039afc..faa436301 100644 --- a/src/lib/teads-aws/index.ts +++ b/src/lib/teads-aws/index.ts @@ -3,14 +3,14 @@ import Spline from 'typescript-cubic-spline'; import * as AWS_INSTANCES from './aws-instances.json'; import * as AWS_EMBODIED from './aws-embodied.json'; -import { IoutputModelInterface } from '../interfaces'; +import {IoutputModelInterface} from '../interfaces'; -import { CONFIG } from '../../config'; +import {CONFIG} from '../../config'; -import { KeyValuePair, Interpolation } from '../../types/common'; +import {KeyValuePair, Interpolation} from '../../types/common'; -const { MODEL_IDS } = CONFIG; -const { TEADS_AWS } = MODEL_IDS; +const {MODEL_IDS} = CONFIG; +const {TEADS_AWS} = MODEL_IDS; export class TeadsAWS implements IoutputModelInterface { authParams: object | undefined; // Defined for compatibility. Not used in TEADS. diff --git a/src/lib/teads-curve/index.ts b/src/lib/teads-curve/index.ts index 6fc2d9ddc..be82f9e56 100644 --- a/src/lib/teads-curve/index.ts +++ b/src/lib/teads-curve/index.ts @@ -1,13 +1,13 @@ import Spline from 'typescript-cubic-spline'; -import { IoutputModelInterface } from '../interfaces'; +import {IoutputModelInterface} from '../interfaces'; -import { CONFIG } from '../../config'; +import {CONFIG} from '../../config'; -import { KeyValuePair, Interpolation } from '../../types/common'; +import {KeyValuePair, Interpolation} from '../../types/common'; -const { MODEL_IDS } = CONFIG; -const { TEADS_CURVE } = MODEL_IDS; +const {MODEL_IDS} = CONFIG; +const {TEADS_CURVE} = MODEL_IDS; export class TeadsCurveModel implements IoutputModelInterface { authParams: object | undefined; // Defined for compatibility. Not used in TEADS. @@ -177,4 +177,4 @@ export class TeadsCurveModel implements IoutputModelInterface { /** * For JSII. */ -export { KeyValuePair, Interpolation } from '../../types/common'; +export {KeyValuePair, Interpolation} from '../../types/common'; diff --git a/src/lib/watt-time/index.ts b/src/lib/watt-time/index.ts index b58b80a9b..13644ab36 100644 --- a/src/lib/watt-time/index.ts +++ b/src/lib/watt-time/index.ts @@ -1,14 +1,14 @@ import axios from 'axios'; import * as dayjs from 'dayjs'; -import { IoutputModelInterface } from '../interfaces'; +import {IoutputModelInterface} from '../interfaces'; -import { CONFIG } from '../../config'; +import {CONFIG} from '../../config'; -import { KeyValuePair } from '../../types/common'; +import {KeyValuePair} from '../../types/common'; -const { MODEL_IDS } = CONFIG; -const { WATT_TIME } = MODEL_IDS; +const {MODEL_IDS} = CONFIG; +const {WATT_TIME} = MODEL_IDS; export class WattTimeGridEmissions implements IoutputModelInterface { authParams: object | undefined = undefined; @@ -70,8 +70,7 @@ export class WattTimeGridEmissions implements IoutputModelInterface { // validate inputs for location data + timestamp + duration this.validateinputs(inputs); // determine the earliest start and total duration of all input blocks - const { startTime, fetchDuration } = - this.determineinputStartEnd(inputs); + const {startTime, fetchDuration} = this.determineinputStartEnd(inputs); // fetch data from WattTime API for the entire duration const wattimedata = await this.fetchData({ timestamp: startTime.format(), @@ -81,11 +80,8 @@ export class WattTimeGridEmissions implements IoutputModelInterface { // for each input block, calculate the average emission inputs.map((input: KeyValuePair) => { const inputStart = dayjs(input.timestamp); - const inputEnd = inputStart.add( - input.duration, - 'seconds' - ); - const { datapoints, data } = this.getWattTimeDataForDuration( + const inputEnd = inputStart.add(input.duration, 'seconds'); + const {datapoints, data} = this.getWattTimeDataForDuration( wattimedata, inputStart, inputEnd @@ -106,7 +102,7 @@ export class WattTimeGridEmissions implements IoutputModelInterface { wattimedata: KeyValuePair[], inputStart: dayjs.Dayjs, inputEnd: dayjs.Dayjs - ): { datapoints: number; data: number[] } { + ): {datapoints: number; data: number[]} { let datapoints = 0; const data = wattimedata.map((data: KeyValuePair) => { // WattTime API returns full data for the entire duration. @@ -131,14 +127,13 @@ export class WattTimeGridEmissions implements IoutputModelInterface { datapoints += 1; return grid_emission; }); - return { datapoints, data }; + return {datapoints, data}; } private validateinputs(inputs: object[]) { inputs.forEach((input: KeyValuePair) => { if (!('location' in input)) { - const { latitude, longitude } = - this.getLatitudeLongitudeFrominput(input); + const {latitude, longitude} = this.getLatitudeLongitudeFrominput(input); if (isNaN(latitude) || isNaN(longitude)) { throw new Error('latitude or longitude is not a number'); } @@ -167,7 +162,7 @@ export class WattTimeGridEmissions implements IoutputModelInterface { } const latitude = parseFloat(location[0]); //convert latitude to float const longitude = parseFloat(location[1]); //convert longitude to float - return { latitude, longitude }; + return {latitude, longitude}; } private determineinputStartEnd(inputs: object[]) { @@ -184,9 +179,7 @@ export class WattTimeGridEmissions implements IoutputModelInterface { : starttime; // if the input timestamp + duration is after the current endtime, set it as the new endtime - endtime = dayjs(input.timestamp) - .add(duration, 'seconds') - .isAfter(endtime) + endtime = dayjs(input.timestamp).add(duration, 'seconds').isAfter(endtime) ? dayjs(input.timestamp).add(duration, 'seconds') : endtime; }); @@ -194,11 +187,11 @@ export class WattTimeGridEmissions implements IoutputModelInterface { if (fetchDuration > 32 * 24 * 60 * 60) { throw new Error( 'duration is too long.WattTime API only supports up to 32 days. All inputs must be within 32 days of each other. Duration of ' + - fetchDuration + - ' seconds is too long.' + fetchDuration + + ' seconds is too long.' ); } - return { startTime: starttime, fetchDuration }; + return {startTime: starttime, fetchDuration}; } async fetchData(input: KeyValuePair): Promise { @@ -207,8 +200,7 @@ export class WattTimeGridEmissions implements IoutputModelInterface { if (duration > 32 * 24 * 60 * 60) { throw new Error('duration is too long'); } - const { latitude, longitude } = - this.getLatitudeLongitudeFrominput(input); + const {latitude, longitude} = this.getLatitudeLongitudeFrominput(input); const params = { latitude: latitude, diff --git a/src/types/models-universe.ts b/src/types/models-universe.ts index 84a27ba13..80cc34dd9 100644 --- a/src/types/models-universe.ts +++ b/src/types/models-universe.ts @@ -1,4 +1,4 @@ -import { IoutputModelInterface } from '../lib'; +import {IoutputModelInterface} from '../lib'; type InitializeOptions = { allocation: string; diff --git a/src/util/args.ts b/src/util/args.ts index df59cd2ba..4fd12a3fd 100644 --- a/src/util/args.ts +++ b/src/util/args.ts @@ -1,16 +1,16 @@ import * as path from 'path'; -import { parse } from 'ts-command-line-args'; +import {parse} from 'ts-command-line-args'; -import { checkIfFileIsYaml } from './yaml'; +import {checkIfFileIsYaml} from './yaml'; -import { CONFIG, STRINGS } from '../config'; +import {CONFIG, STRINGS} from '../config'; -import { impactProcessArgs } from '../types/process-args'; +import {impactProcessArgs} from '../types/process-args'; -const { impact } = CONFIG; -const { ARGS, HELP } = impact; +const {impact} = CONFIG; +const {ARGS, HELP} = impact; -const { WRONG_CLI_ARGUMENT } = STRINGS; +const {WRONG_CLI_ARGUMENT} = STRINGS; /** * Validates process arguments @@ -33,7 +33,7 @@ const prependFullFilePath = (filePath: string) => { * Otherwise throws error. */ export const parseProcessArgument = () => { - const { impl, ompl, help } = validateAndParseProcessArgs(); + const {impl, ompl, help} = validateAndParseProcessArgs(); if (help) { console.log(HELP); @@ -44,7 +44,7 @@ export const parseProcessArgument = () => { if (checkIfFileIsYaml(impl)) { return { inputPath: prependFullFilePath(impl), - ...(ompl && { outputPath: prependFullFilePath(ompl) }), + ...(ompl && {outputPath: prependFullFilePath(ompl)}), }; } } diff --git a/src/util/models-universe.ts b/src/util/models-universe.ts index fbc41996c..a80a83e97 100644 --- a/src/util/models-universe.ts +++ b/src/util/models-universe.ts @@ -109,7 +109,7 @@ export class ModelsUniverse { * Initializes and registers model. */ public writeDown(model: ImplInitializeModel) { - const { name, kind, config } = model; + const {name, kind, config} = model; const Model = this.handModelByCriteria(name, kind); diff --git a/src/util/observatory.ts b/src/util/observatory.ts index 0feb1a92c..49f4dd6dd 100644 --- a/src/util/observatory.ts +++ b/src/util/observatory.ts @@ -1,4 +1,4 @@ -import { IoutputModelInterface } from '../lib'; +import {IoutputModelInterface} from '../lib'; /** * Observatory calculates outputs based on `inputs` and `model`. @@ -18,9 +18,7 @@ export class Observatory { * Calculates output based on inputs. */ public async doInvestigationsWith(modelInstance: IoutputModelInterface) { - const reuseCalculation = this.output.length - ? this.output - : this.inputs; + const reuseCalculation = this.output.length ? this.output : this.inputs; const calculatedoutputs = await modelInstance.execute(reuseCalculation); diff --git a/src/util/supercomputer.ts b/src/util/supercomputer.ts index 95b305aee..92fa17157 100644 --- a/src/util/supercomputer.ts +++ b/src/util/supercomputer.ts @@ -1,13 +1,13 @@ -import { ModelsUniverse } from './models-universe'; -import { Observatory } from './observatory'; +import {ModelsUniverse} from './models-universe'; +import {Observatory} from './observatory'; -import { ChildInformation } from '../types/supercomputer'; +import {ChildInformation} from '../types/supercomputer'; /** * Computer for `impl` documents. */ export class Supercomputer { - private olderChild: ChildInformation = { name: '', info: {} }; + private olderChild: ChildInformation = {name: '', info: {}}; private impl: any; private modelsHandbook: ModelsUniverse; @@ -36,11 +36,7 @@ export class Supercomputer { /** * Adds config entries to each obsercation object passed. */ - private enrichinputs( - inputs: any[], - config: any[], - nestedConfig: any[] - ) { + private enrichinputs(inputs: any[], config: any[], nestedConfig: any[]) { const configValues = this.flattenConfigValues(config); const nestedConfigValues = nestedConfig && this.flattenConfigValues(nestedConfig); @@ -59,7 +55,7 @@ export class Supercomputer { * For each model from pipeline Observatory gathers inputs. Then results are stored. */ private async calculateoutputsForChild(childrenObject: any, params: any) { - const { childName, areChildrenNested } = params; + const {childName, areChildrenNested} = params; if (!areChildrenNested) { this.olderChild = { @@ -68,7 +64,7 @@ export class Supercomputer { }; } - const { pipeline, inputs, config } = this.olderChild.info; + const {pipeline, inputs, config} = this.olderChild.info; if ('children' in childrenObject[childName]) { return this.compute(childrenObject[childName].children);