diff --git a/client/src/components/CarbonEmissions/CarbonEmissions.test.js b/client/src/components/CarbonEmissions/CarbonEmissions.test.js index dcd74060d8a..74e2b7c0f26 100644 --- a/client/src/components/CarbonEmissions/CarbonEmissions.test.js +++ b/client/src/components/CarbonEmissions/CarbonEmissions.test.js @@ -7,48 +7,48 @@ const localVue = getLocalVue(); const oneGibibyeMemoryInMebibyte = 1024; const oneHourInSeconds = 3600; const testServerInstance = { - name: 'some-server-name', - cpuInfo: { - modelName: 'some-processor-name', - totalAvailableCores: 10, - tdp: 100 - } -} + name: "some-server-name", + cpuInfo: { + modelName: "some-processor-name", + totalAvailableCores: 10, + tdp: 100, + }, +}; describe("CarbonEmissions/CarbonEmissions.vue", () => { it("correctly calculated carbon emissions.", async () => { const wrapper = mount(CarbonEmissions, { propsData: { - estimatedServerInstance: testServerInstance, - jobRuntimeInSeconds: oneHourInSeconds, - coresAllocated: 1, - memoryAllocatedInMebibyte: oneGibibyeMemoryInMebibyte, + estimatedServerInstance: testServerInstance, + jobRuntimeInSeconds: oneHourInSeconds, + coresAllocated: 1, + memoryAllocatedInMebibyte: oneGibibyeMemoryInMebibyte, }, localVue, }); - const cpuEmissions = wrapper.find("#cpu-carbon-emissions").text(); - const memoryEmissions = wrapper.find("#memory-carbon-emissions").text(); - const cpuEnergyUsage = wrapper.find("#cpu-energy-usage").text(); - const memoryEnergyUsage = wrapper.find("#memory-energy-usage").text(); + const cpuEmissions = wrapper.find("#cpu-carbon-emissions").text(); + const memoryEmissions = wrapper.find("#memory-carbon-emissions").text(); + const cpuEnergyUsage = wrapper.find("#cpu-energy-usage").text(); + const memoryEnergyUsage = wrapper.find("#memory-energy-usage").text(); - expect(cpuEmissions).toMatch("8 g CO2e"); - expect(memoryEmissions).toMatch("295 mg CO2e"); - expect(cpuEnergyUsage).toMatch("17 mW⋅h"); - expect(memoryEnergyUsage).toMatch("1 mW⋅h"); + expect(cpuEmissions).toMatch("8 g CO2e"); + expect(memoryEmissions).toMatch("295 mg CO2e"); + expect(cpuEnergyUsage).toMatch("17 mW⋅h"); + expect(memoryEnergyUsage).toMatch("1 mW⋅h"); }); it("does not render memory estimates when no value can be determined.", () => { const wrapper = mount(CarbonEmissions, { propsData: { - estimatedServerInstance: testServerInstance, - jobRuntime: 1, - coresAllocated: 1, + estimatedServerInstance: testServerInstance, + jobRuntime: 1, + coresAllocated: 1, }, localVue, }); - expect(wrapper.find("#memory-carbon-emissions").exists()).toBe(false); - expect(wrapper.find("#memory-energy-usage").exists()).toBe(false); + expect(wrapper.find("#memory-carbon-emissions").exists()).toBe(false); + expect(wrapper.find("#memory-energy-usage").exists()).toBe(false); }); }); diff --git a/client/src/components/CarbonEmissions/CarbonEmissions.vue b/client/src/components/CarbonEmissions/CarbonEmissions.vue index 48f846f169e..5e7af4e7f8c 100644 --- a/client/src/components/CarbonEmissions/CarbonEmissions.vue +++ b/client/src/components/CarbonEmissions/CarbonEmissions.vue @@ -14,10 +14,10 @@ export interface CarbonEmissionsProps { estimatedServerInstance: { name: string; cpuInfo: { - modelName: string; - totalAvailableCores: number; - tdp: number; - } + modelName: string; + totalAvailableCores: number; + tdp: number; + }; }; jobRuntimeInSeconds: number; coresAllocated: number; diff --git a/client/src/components/JobMetrics/AwsEstimate.test.js b/client/src/components/JobMetrics/AwsEstimate.test.js index 22008d49877..adc12ac1a6e 100644 --- a/client/src/components/JobMetrics/AwsEstimate.test.js +++ b/client/src/components/JobMetrics/AwsEstimate.test.js @@ -18,9 +18,9 @@ describe("JobMetrics/AwsEstimate.vue", () => { const wrapper = mount(AwsEstimate, { propsData: { jobId: "0", - jobRuntime: 0, + jobRuntimeInSeconds: 0, coresAllocated: -999, - memoryAllocated: -999, + memoryAllocatedInMebibyte: -999, }, localVue, }); @@ -37,9 +37,9 @@ describe("JobMetrics/AwsEstimate.vue", () => { localVue, propsData: { jobId: JOB_ID, - jobRuntime: Number(seconds), + jobRuntimeInSeconds: Number(seconds), coresAllocated: Number(cores), - memoryAllocated: Number(memory), + memoryAllocatedInMebibyte: Number(memory), }, }); diff --git a/client/src/components/JobMetrics/AwsEstimate.vue b/client/src/components/JobMetrics/AwsEstimate.vue index fab331cadae..7c8765615d1 100644 --- a/client/src/components/JobMetrics/AwsEstimate.vue +++ b/client/src/components/JobMetrics/AwsEstimate.vue @@ -3,21 +3,21 @@ import { computed } from "vue"; import ec2 from "./ec2.json"; export interface AwsEstimateProps { - jobRuntime: number; + jobRuntimeInSeconds: number; coresAllocated: number; - memoryAllocated?: number; + memoryAllocatedInMebibyte?: number; } const props = defineProps(); const computedAwsEstimate = computed(() => { - const { coresAllocated, jobRuntime, memoryAllocated } = props; + const { coresAllocated, jobRuntimeInSeconds, memoryAllocatedInMebibyte } = props; - if (coresAllocated <= 0 || jobRuntime <= 0) { + if (coresAllocated <= 0 || jobRuntimeInSeconds <= 0) { return; } - const adjustedMemoryAllocated = memoryAllocated ? memoryAllocated / 1024 : 0.5; + const adjustedMemoryAllocated = memoryAllocatedInMebibyte ? memoryAllocatedInMebibyte / 1024 : 0.5; // Estimate EC2 instance. Data is already sorted const ec2Instance = ec2.find((ec) => { @@ -29,11 +29,11 @@ const computedAwsEstimate = computed(() => { } return { - seconds: jobRuntime, - vcpus: coresAllocated, - memory: adjustedMemoryAllocated, - price: ((jobRuntime * ec2Instance.price) / 3600).toFixed(2), - instance: ec2Instance + seconds: jobRuntimeInSeconds, + vcpus: coresAllocated, + memory: adjustedMemoryAllocated, + price: ((jobRuntimeInSeconds * ec2Instance.price) / 3600).toFixed(2), + instance: ec2Instance, }; }); @@ -46,9 +46,8 @@ const computedAwsEstimate = computed(() => {
- This job requested {{ computedAwsEstimate.vcpus }} core(s) and - {{ computedAwsEstimate.memory.toFixed(3) }} GiB of memory. Given this - information, the smallest EC2 machine we could find is: + This job requested {{ computedAwsEstimate.vcpus }} core(s) and {{ computedAwsEstimate.memory.toFixed(3) }} GiB + of memory. Given this information, the smallest EC2 machine we could find is: {{ computedAwsEstimate.instance.name }} ({{ computedAwsEstimate.instance.mem }} GB / diff --git a/client/src/components/JobMetrics/JobMetrics.vue b/client/src/components/JobMetrics/JobMetrics.vue index f6c0cd3ce5d..6d5453baf92 100644 --- a/client/src/components/JobMetrics/JobMetrics.vue +++ b/client/src/components/JobMetrics/JobMetrics.vue @@ -20,7 +20,7 @@ const props = withDefaults(defineProps(), { datasetId: "", datasetType: "hda", includeTitle: true, - shouldShowAwsEstimate: false + shouldShowAwsEstimate: false, }); const jobMetricsStore = useJobMetricsStore(); @@ -67,7 +67,7 @@ const pluginsSortedByPluginType = computed(() => { return Object.keys(jobMetricsGroupedByPluginType.value).sort(); }); -const jobRuntime = computed(() => { +const jobRuntimeInSeconds = computed(() => { const runtime = getMetricByName("runtime_seconds"); return runtime ? parseInt(runtime) : undefined; @@ -79,7 +79,7 @@ const coresAllocated = computed(() => { return coreCount ? parseInt(coreCount) : undefined; }); -const memoryAllocated = computed(() => { +const memoryAllocatedInMebibyte = computed(() => { const memoryUsage = getMetricByName("galaxy_memory_mb"); return memoryUsage ? parseInt(memoryUsage) : undefined; @@ -91,17 +91,17 @@ const estimatedServerInstance = computed(() => { return; } - const memory = unref(memoryAllocated); + const memory = unref(memoryAllocatedInMebibyte); const adjustedMemory = memory ? memory / 1024 : 0; const serverInstance = ec2.find((ec) => { - if (adjustedMemory === 0) { - // Exclude memory from search criteria - return ec2.find((ec) => ec.vcpus >= cores); - } + if (adjustedMemory === 0) { + // Exclude memory from search criteria + return ec2.find((ec) => ec.vcpus >= cores); + } - // Search by all criteria - return ec.mem >= adjustedMemory && ec.vcpus >= cores + // Search by all criteria + return ec.mem >= adjustedMemory && ec.vcpus >= cores; }); if (!serverInstance) { @@ -116,10 +116,10 @@ const estimatedServerInstance = computed(() => { return { name: serverInstance.name, cpuInfo: { - modelName: cpu.cpuModel, - totalAvailableCores: cpu.coreCount, - tdp: cpu.tdp - } + modelName: cpu.cpuModel, + totalAvailableCores: cpu.coreCount, + tdp: cpu.tdp, + }, }; }); @@ -144,17 +144,17 @@ const estimatedServerInstance = computed(() => { + :memory-allocated-in-mebibyte="memoryAllocatedInMebibyte" /> + :memory-allocated-in-mebibyte="memoryAllocatedInMebibyte" />