-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Add history and workflow invocation carbon emissions reporting #17542
Open
Renni771
wants to merge
38
commits into
galaxyproject:dev
Choose a base branch
from
Renni771:add-history-and-workflow-invocation-carbon-emissions-reporting
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
b2ac178
Implement history carbon emissions reporting (WIP)
Renni771 6e1d992
Implement carbon emissions reporting for histories and workflow invoc…
Renni771 6c78cf0
Format code
Renni771 59902c0
Unify energy usage summary type in API schema
Renni771 1326742
Estimate server instance when collecting job metrics
Renni771 3fd2cdb
Calculate job carbon emissions directly using metrics.
Renni771 9e64c04
Do not display energy usage metrics in job metrics list
Renni771 bcce348
Clean up carbon emissions client markup and code
Renni771 4bdee2a
Revert HistoryView component to previous state using options API
Renni771 dcfdbc8
Use correct props and adjust code style
Renni771 945fa5b
Update tests
Renni771 1471dd6
Remove estimated server instance name. Refactor carbon emissions impo…
Renni771 8bfafec
Add history size to history statistics button
Renni771 4c635fc
Add types to useCarbonEmissions return values
Renni771 5c5a546
Add missing component import
Renni771 d281e44
Refactor CarbonEmissions.vue tests. Adjust and format markup and code
Renni771 697ec18
Use correct selector in HistoryView component tests
Renni771 0130d91
Convert snake-cased components to PascalCase ones and import them exp…
Renni771 f3013e0
Merge branch 'dev' into add-history-carbon-emissions
Renni771 3526d52
Remove unused imports and fix typing in job_metrics and jobs files
Renni771 d73ac7e
Remove unnecessary open mode parameters
Renni771 64fb89b
Update package imports
Renni771 69158fc
Update exported symbols
Renni771 409f4d3
Update import statement for load_aws_ec2_reference_data_json
Renni771 73fc760
Merge branch 'dev' into add-history-carbon-emissions
Renni771 4ef52c3
Resolve linting issues
Renni771 cf327d2
Use from typing module
Renni771 17039c7
Use List from typing module
Renni771 7e1551c
Remove unused code
Renni771 79be5f7
Update client API schema
Renni771 4155963
Combine energy usage query into a single one
Renni771 ad7bec1
Merge branch 'dev' into add-history-and-workflow-invocation-carbon-em…
Renni771 0d51f95
Update energy usage summary model and API endpoints
Renni771 399da83
Merge branch 'dev' into add-history-and-workflow-invocation-carbon-em…
Renni771 e8e7ace
Remove duplicate import
Renni771 3fd33f4
Remove use of TypedDict to support python 3.5.
Renni771 5a1a610
Only show carbon emissions reports when enabled in config
Renni771 c4919ea
Exclude energy usage flags from core plugin formatter
Renni771 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
84 changes: 84 additions & 0 deletions
84
client/src/components/CarbonEmissions/CarbonEmissions.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import { createTestingPinia } from "@pinia/testing"; | ||
import { mount } from "@vue/test-utils"; | ||
import { getLocalVue } from "tests/jest/helpers"; | ||
import { ref } from "vue"; | ||
|
||
import { worldwideCarbonIntensity } from "./carbonEmissionConstants"; | ||
|
||
import CarbonEmissions from "./CarbonEmissions.vue"; | ||
|
||
const carbonIntensity = ref(worldwideCarbonIntensity); | ||
const geographicalServerLocationName = ref("GLOBAL"); | ||
jest.mock("@/composables/carbonEmissions", () => ({ | ||
useCarbonEmissions: () => { | ||
return { | ||
carbonIntensity, | ||
geographicalServerLocationName, | ||
}; | ||
}, | ||
})); | ||
|
||
const localVue = getLocalVue(); | ||
const pinia = createTestingPinia(); | ||
const slots = { | ||
header: "<div>foo</div>", | ||
footer: "<div>bar</div>", | ||
}; | ||
|
||
describe("CarbonEmissions/CarbonEmissions.vue", () => { | ||
it("correctly calculates carbon emissions.", () => { | ||
const wrapper = mount(CarbonEmissions as any, { | ||
propsData: { | ||
energyNeededCPU: 0.015, | ||
energyNeededMemory: 0.005, | ||
}, | ||
pinia, | ||
slots, | ||
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(); | ||
|
||
expect(cpuEmissions).toMatch("7 g CO2e"); | ||
expect(memoryEmissions).toMatch("2 g CO2e"); | ||
expect(cpuEnergyUsage).toMatch("15 mW⋅h"); | ||
expect(memoryEnergyUsage).toMatch("5 mW⋅h"); | ||
}); | ||
|
||
it("does not render any data for memory if its memroy usage is 0.", () => { | ||
const wrapper = mount(CarbonEmissions as any, { | ||
propsData: { | ||
energyNeededCPU: 0, | ||
energyNeededMemory: 0, | ||
}, | ||
pinia, | ||
slots, | ||
localVue, | ||
}); | ||
|
||
expect(wrapper.find("#memory-energy-usage").exists()).toBe(false); | ||
expect(wrapper.find("#memroy-carbon-emissions").exists()).toBe(false); | ||
}); | ||
|
||
it("takes the configured `carbonIntensity` value into account.", () => { | ||
carbonIntensity.value = 0; | ||
const wrapper = mount(CarbonEmissions as any, { | ||
propsData: { | ||
energyNeededCPU: 1_000, | ||
energyNeededMemory: 1_000, | ||
}, | ||
pinia, | ||
slots, | ||
localVue, | ||
}); | ||
|
||
const cpuEmissions = wrapper.find("#cpu-carbon-emissions").text(); | ||
const memoryEmissions = wrapper.find("#memory-carbon-emissions").text(); | ||
|
||
expect(cpuEmissions).toMatch("0 g CO2e"); | ||
expect(memoryEmissions).toMatch("0 g CO2e"); | ||
}); | ||
}); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move that into another model ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have something like this in mind?: