-
AWS estimate
+
AWS estimate
{{ computedAwsEstimate.price }} USD
diff --git a/client/src/components/JobMetrics/CarbonEmissions/CarbonEmissions.test.js b/client/src/components/JobMetrics/CarbonEmissions/CarbonEmissions.test.js
index 0900dfdf3173..a9cd95acdbc8 100644
--- a/client/src/components/JobMetrics/CarbonEmissions/CarbonEmissions.test.js
+++ b/client/src/components/JobMetrics/CarbonEmissions/CarbonEmissions.test.js
@@ -1,6 +1,7 @@
import { mount } from "@vue/test-utils";
import { getLocalVue } from "tests/jest/helpers";
+import { worldwideCarbonIntensity, worldwidePowerUsageEffectiveness } from "./carbonEmissionConstants.js";
import CarbonEmissions from "./CarbonEmissions";
const localVue = getLocalVue();
@@ -17,13 +18,15 @@ const testServerInstance = {
};
describe("CarbonEmissions/CarbonEmissions.vue", () => {
- it("correctly calculates carbon emissions.", async () => {
+ it("correctly calculates carbon emissions.", () => {
const wrapper = mount(CarbonEmissions, {
propsData: {
+ carbonIntensity: worldwideCarbonIntensity,
+ coresAllocated: 1,
estimatedServerInstance: testServerInstance,
jobRuntimeInSeconds: oneHourInSeconds,
- coresAllocated: 1,
memoryAllocatedInMebibyte: oneGibibyteMemoryInMebibyte,
+ powerUsageEffectiveness: worldwidePowerUsageEffectiveness,
},
localVue,
});
@@ -42,9 +45,9 @@ describe("CarbonEmissions/CarbonEmissions.vue", () => {
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,
+ jobRuntimeInSeconds: 1,
},
localVue,
});
@@ -52,4 +55,108 @@ describe("CarbonEmissions/CarbonEmissions.vue", () => {
expect(wrapper.find("#memory-carbon-emissions").exists()).toBe(false);
expect(wrapper.find("#memory-energy-usage").exists()).toBe(false);
});
+
+ it("takes the configured `powerUsageEffectiveness` value into account.", () => {
+ const wrapper = mount(CarbonEmissions, {
+ propsData: {
+ carbonIntensity: 1,
+ coresAllocated: 1,
+ estimatedServerInstance: testServerInstance,
+ jobRuntimeInSeconds: 1,
+ memoryAllocatedInMebibyte: 1,
+ powerUsageEffectiveness: 0,
+ },
+ localVue,
+ });
+
+ const cpuEmissions = wrapper.find("#cpu-carbon-emissions").text();
+ const cpuEnergyUsage = wrapper.find("#cpu-energy-usage").text();
+ const memoryEmissions = wrapper.find("#memory-carbon-emissions").text();
+ const memoryEnergyUsage = wrapper.find("#memory-energy-usage").text();
+
+ expect(cpuEmissions).toMatch("0 g CO2e");
+ expect(cpuEnergyUsage).toMatch("0 kW⋅h");
+ expect(memoryEmissions).toMatch("0 g CO2e");
+ expect(memoryEnergyUsage).toMatch("0 kW⋅h");
+ });
+
+ it("takes the configured `carbonIntensity` value into account.", () => {
+ const wrapper = mount(CarbonEmissions, {
+ propsData: {
+ carbonIntensity: 0,
+ coresAllocated: 1,
+ estimatedServerInstance: testServerInstance,
+ jobRuntimeInSeconds: 1,
+ memoryAllocatedInMebibyte: 1,
+ powerUsageEffectiveness: 1,
+ },
+ 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");
+ });
+
+ it("displays text saying that global values were used when the `geographicalServerLocationName` prop is set to `GLOBAL`.", () => {
+ const carbonIntensity = worldwideCarbonIntensity;
+ const wrapper = mount(CarbonEmissions, {
+ propsData: {
+ carbonIntensity,
+ coresAllocated: 2,
+ estimatedServerInstance: testServerInstance,
+ jobRuntimeInSeconds: 2,
+ geographicalServerLocationName: "GLOBAL",
+ },
+ localVue,
+ });
+ const locationText = wrapper.find("#location-explanation").element;
+ expect(locationText).toHaveTextContent(
+ `1. Based off of the global carbon intensity value of ${carbonIntensity}.`
+ );
+ });
+
+ it("displays text saying that the carbon intensity value corresponding to `geographicalServerLocationName` was used.", () => {
+ const locationName = "Italy";
+ const carbonIntensity = worldwideCarbonIntensity;
+ const wrapper = mount(CarbonEmissions, {
+ propsData: {
+ carbonIntensity,
+ coresAllocated: 2,
+ estimatedServerInstance: testServerInstance,
+ jobRuntimeInSeconds: 2,
+ memoryAllocatedInMebibyte: oneGibibyteMemoryInMebibyte,
+ powerUsageEffectiveness: worldwideCarbonIntensity,
+ geographicalServerLocationName: locationName,
+ },
+ localVue,
+ });
+
+ const locationElement = wrapper.find("#location-explanation").element;
+ expect(locationElement).toHaveTextContent(
+ `1. based off of this galaxy instance's configured location of ${locationName}, which has a carbon intensity value of ${carbonIntensity} gCO2/kWh.`
+ );
+ });
+
+ it("displays text saying that global average values for PUE where used when `powerUsageEffectiveness` matches the global average.", () => {
+ const powerUsageEffectiveness = worldwidePowerUsageEffectiveness;
+ const wrapper = mount(CarbonEmissions, {
+ propsData: {
+ carbonIntensity: 1,
+ coresAllocated: 1,
+ estimatedServerInstance: testServerInstance,
+ jobRuntimeInSeconds: 1,
+ memoryAllocatedInMebibyte: 1,
+ powerUsageEffectiveness,
+ },
+ localVue,
+ });
+
+ const locationElement = wrapper.find("#pue").element;
+ expect(locationElement).toHaveTextContent(
+ `2. Using the global default power usage effectiveness value of ${powerUsageEffectiveness}.`
+ );
+ });
});
diff --git a/client/src/components/JobMetrics/CarbonEmissions/CarbonEmissions.vue b/client/src/components/JobMetrics/CarbonEmissions/CarbonEmissions.vue
index a65def3db122..0dad853859bd 100644
--- a/client/src/components/JobMetrics/CarbonEmissions/CarbonEmissions.vue
+++ b/client/src/components/JobMetrics/CarbonEmissions/CarbonEmissions.vue
@@ -24,7 +24,10 @@ interface CarbonEmissionsProps {
};
jobRuntimeInSeconds: number;
coresAllocated: number;
+ powerUsageEffectiveness: number;
+ geographicalServerLocationName: string;
memoryAllocatedInMebibyte?: number;
+ carbonIntensity: number;
}
const props = withDefaults(defineProps
(), {
@@ -32,7 +35,6 @@ const props = withDefaults(defineProps(), {
});
const carbonEmissions = computed(() => {
- const powerUsageEffectiveness = carbonEmissionsConstants.worldwidePowerUsageEffectiveness;
const memoryPowerUsed = carbonEmissionsConstants.memoryPowerUsage;
const runtimeInHours = props.jobRuntimeInSeconds / (60 * 60); // Convert to hours
const memoryAllocatedInGibibyte = props.memoryAllocatedInMebibyte / 1024; // Convert to gibibyte
@@ -42,8 +44,8 @@ const carbonEmissions = computed(() => {
const normalizedTdpPerCore = tdpPerCore * props.coresAllocated;
// Power needed in Watt
- const powerNeededCpu = powerUsageEffectiveness * normalizedTdpPerCore;
- const powerNeededMemory = powerUsageEffectiveness * memoryAllocatedInGibibyte * memoryPowerUsed;
+ const powerNeededCpu = props.powerUsageEffectiveness * normalizedTdpPerCore;
+ const powerNeededMemory = props.powerUsageEffectiveness * memoryAllocatedInGibibyte * memoryPowerUsed;
const totalPowerNeeded = powerNeededCpu + powerNeededMemory;
// Energy needed. Convert Watt to kWh
@@ -52,7 +54,7 @@ const carbonEmissions = computed(() => {
const totalEnergyNeeded = (runtimeInHours * totalPowerNeeded) / 1000;
// Carbon emissions (carbon intensity is in grams/kWh so emissions results are in grams of CO2)
- const carbonIntensity = carbonEmissionsConstants.worldwideCarbonIntensity;
+ const carbonIntensity = props.carbonIntensity;
const cpuCarbonEmissions = energyNeededCPU * carbonIntensity;
const memoryCarbonEmissions = energyNeededMemory * carbonIntensity;
const totalCarbonEmissions = totalEnergyNeeded * carbonIntensity;
@@ -266,9 +268,9 @@ function getEnergyNeededText(energyNeededInKiloWattHours: number) {
}
-
-
-
Carbon Footprint
+
+
+
Carbon Footprint
@@ -307,8 +309,8 @@ function getEnergyNeededText(energyNeededInKiloWattHours: number) {
Component |
- Carbon Emissions 1. 2. |
- Energy Usage 1. |
+ Carbon Emissions 1. 2. 3. |
+ Energy Usage 2. 3. |
@@ -333,16 +335,34 @@ function getEnergyNeededText(energyNeededInKiloWattHours: number) {
- 1. based off of the closest AWS EC2 instance comparable to the server that ran this
- job. Estimates depend on the core count, allocated memory and the job runtime. The closest estimate
- is a {{ estimatedServerInstance.name }} instance.
+
+ 1. Based off of the global carbon intensity value of
+ {{ carbonEmissionsConstants.worldwideCarbonIntensity }}.
+
+
+ 1. based off of this galaxy instance's configured location of
+ {{ geographicalServerLocationName }}, which has a carbon intensity value of {{ carbonIntensity }} gCO2/kWh.
+
- 2. CO2e represents other types of greenhouse gases the have similar global warming
- potential as a metric unit amount of CO2 itself.
+
+ 2. Using the global default power usage effectiveness value of
+ {{ carbonEmissionsConstants.worldwidePowerUsageEffectiveness }}.
+
+
+ 2. using the galaxy instance's configured power usage effectiveness ratio value
+ of of {{ powerUsageEffectiveness }}.
+
+
+ 3. based off of the closest AWS EC2 instance comparable to the server that ran this
+ job. Estimates depend on the core count, allocated memory and the job runtime. The closest estimate
+ is a {{ estimatedServerInstance.name }} instance.
{
:memory-allocated-in-mebibyte="memoryAllocatedInMebibyte" />
CarbonIntensityEntry:
+ """
+ Gets the name and carbon intensity value of the geographical location corresponding to
+ 'geographical_server_location_code'.
+ """
+ carbon_emissions_dir = os.path.join(os.path.dirname(__file__), "carbon_intensity.csv")
+
+ for location_entry in _load_locations(carbon_emissions_dir):
+ location_code, location_name = location_entry[0], location_entry[2]
+
+ is_region = len(location_code) > 2
+ if is_region:
+ region_name = location_entry[3]
+ location_name = f"{region_name} ({location_name})"
+
+ if location_code == geographical_server_location_code:
+ return {"location_name": location_name, "carbon_intensity": float(location_entry[4])}
+
+ log.warning("No corresponding location name exists for location code: %s.", geographical_server_location_code)
+ log.info("Using global default values for location name and carbon intensity...")
+ return {"location_name": "GLOBAL", "carbon_intensity": 475.0}
+
+
+def _load_locations(path: str):
+ with open(path, newline="") as f:
+ csv_reader = csv.reader(f, delimiter=",")
+ yield from csv_reader
diff --git a/lib/galaxy/carbon_emissions/carbon_intensity.csv b/lib/galaxy/carbon_emissions/carbon_intensity.csv
new file mode 100644
index 000000000000..62de63aa4573
--- /dev/null
+++ b/lib/galaxy/carbon_emissions/carbon_intensity.csv
@@ -0,0 +1,133 @@
+index,,,,in gCO2e/kWh,,"Country, Region or World",
+location,continentName,countryName,regionName,carbonIntensity,Type,source,comments
+GLOBAL,GLOBAL,Any,Any,475,World,https://www.iea.org/reports/global-energy-co2-status-report-2019/emissions,Data from 2019
+TW,Asia,China,Taiwan,509,Region,https://energypedia.info/wiki/Energy_Transition_in_Taiwan,
+IL,Asia,Israel,Any,558,Country,https://www.electricitymap.org,Data from April 2022
+ZA,Africa,South Africa,Any,900.6,Country,carbonfootprint (March 2022) and Climate Transparency (2021 Report) (data from 2020),Emissions intensity of the power sector
+CN,Asia,China,Any,537.4,Country,carbonfootprint (March 2022) and Climate Transparency (2021 Report) (data from 2020),Emissions intensity of the power sector
+CN-HK,Asia,China,Hong Kong (HK Electricity Company),710,Region,carbonfootprint (March 2022) and Hong Kong Electric Company (2020) (data from 2020),Combined generation and T&D factor
+CN-HK2,Asia,China,Hong Kong (CLP Group),650,Region,carbonfootprint (March 2022) and CLP Group (2020) (data from 2020),Combined generation and T&D factor
+IN,Asia,India,Any,708.2,Country,carbonfootprint (March 2022) and Climate Transparency (2021 Report) (data from 2020),Emissions intensity of the power sector
+ID,Asia,Indonesia,Any,717.7,Country,carbonfootprint (March 2022) and Climate Transparency (2021 Report) (data from 2020),Emissions intensity of the power sector
+JP,Asia,Japan,Any,465.8,Country,carbonfootprint (March 2022) and Climate Transparency (2021 Report) (data from 2020),Emissions intensity of the power sector
+KR,Asia,Korea,Any,415.6,Country,carbonfootprint (March 2022) and Climate Transparency (2021 Report) (data from 2020),Emissions intensity of the power sector
+SA,Asia,Saudi Arabia,Any,505.9,Country,carbonfootprint (March 2022) and Climate Transparency (2021 Report) (data from 2020),Emissions intensity of the power sector
+SG,Asia,Singapore,Any,408,Country,carbonfootprint (March 2022) and Singapore Energy Market Authority (EMA) (data from 2020),Electricity Grid Emissions Factors
+TH,Asia,Thailand,Any,481,Country,carbonfootprint (March 2022) and Energy Policy and Planning Office (EPPO) Thai Government Ministry of Energy (data from 2020),Combined generation and T&D factor
+TR,Asia,Turkey,Any,375,Country,carbonfootprint (March 2022) and Climate Transparency (2021 Report) (data from 2020),Emissions intensity of the power sector
+AE,Asia,United Arab Emirates,Any,417.89,Country,carbonfootprint (March 2022) and Dubai Electricity & Water Authority (sustainability report 2020) (data from 2020),Generation factor only
+AT,Europe,Austria,Any,111.18,Country,carbonfootprint (March 2022) and Association of Issuing Bodies (AIB) 2021 (data from 2020),Production mix factor
+BE,Europe,Belgium,Any,161.89,Country,carbonfootprint (March 2022) and Association of Issuing Bodies (AIB) 2021 (data from 2020),Production mix factor
+BG,Europe,Bulgaria,Any,372.12,Country,carbonfootprint (March 2022) and Association of Issuing Bodies (AIB) 2021 (data from 2020),Production mix factor
+HR,Europe,Croatia,Any,226.96,Country,carbonfootprint (March 2022) and Association of Issuing Bodies (AIB) 2021 (data from 2020),Production mix factor
+CY,Europe,Cyprus,Any,642.9,Country,carbonfootprint (March 2022) and Association of Issuing Bodies (AIB) 2021 (data from 2020),Production mix factor
+CZ,Europe,Czech Republic,Any,495.49,Country,carbonfootprint (March 2022) and Association of Issuing Bodies (AIB) 2021 (data from 2020),Production mix factor
+DK,Europe,Denmark,Any,142.52,Country,carbonfootprint (March 2022) and Association of Issuing Bodies (AIB) 2021 (data from 2020),Production mix factor
+EE,Europe,Estonia,Any,598.69,Country,carbonfootprint (March 2022) and Association of Issuing Bodies (AIB) 2021 (data from 2020),Production mix factor
+FI,Europe,Finland,Any,95.32,Country,carbonfootprint (March 2022) and Association of Issuing Bodies (AIB) 2021 (data from 2020),Production mix factor
+FR,Europe,France,Any,51.28,Country,carbonfootprint (March 2022) and Association of Issuing Bodies (AIB) 2021 (data from 2020),Production mix factor
+DE,Europe,Germany,Any,338.66,Country,carbonfootprint (March 2022) and Association of Issuing Bodies (AIB) 2021 (data from 2020),Production mix factor
+GR,Europe,Greece,Any,410.01,Country,carbonfootprint (March 2022) and Association of Issuing Bodies (AIB) 2021 (data from 2020),Production mix factor
+HU,Europe,Hungary,Any,243.75,Country,carbonfootprint (March 2022) and Association of Issuing Bodies (AIB) 2021 (data from 2020),Production mix factor
+IS,Europe,Iceland,Any,0.13,Country,carbonfootprint (March 2022) and Association of Issuing Bodies (AIB) 2021 (data from 2020),Production mix factor
+IE,Europe,Ireland,Any,335.99,Country,carbonfootprint (March 2022) and Association of Issuing Bodies (AIB) 2021 (data from 2020),Production mix factor
+IT,Europe,Italy,Any,323.84,Country,carbonfootprint (March 2022) and Association of Issuing Bodies (AIB) 2021 (data from 2020),Production mix factor
+LV,Europe,Latvia,Any,215.67,Country,carbonfootprint (March 2022) and Association of Issuing Bodies (AIB) 2021 (data from 2020),Production mix factor
+LT,Europe,Lithuania,Any,253.56,Country,carbonfootprint (March 2022) and Association of Issuing Bodies (AIB) 2021 (data from 2020),Production mix factor
+LU,Europe,Luxembourg,Any,101.36,Country,carbonfootprint (March 2022) and Association of Issuing Bodies (AIB) 2021 (data from 2020),Production mix factor
+MT,Europe,Malta,Any,390.62,Country,carbonfootprint (March 2022) and Association of Issuing Bodies (AIB) 2021 (data from 2020),Production mix factor
+NL,Europe,Netherlands,Any,374.34,Country,carbonfootprint (March 2022) and Association of Issuing Bodies (AIB) 2021 (data from 2020),Production mix factor
+NO,Europe,Norway,Any,7.62,Country,carbonfootprint (March 2022) and Association of Issuing Bodies (AIB) 2021 (data from 2020),Production mix factor
+PL,Europe,Poland,Any,759.62,Country,carbonfootprint (March 2022) and Association of Issuing Bodies (AIB) 2021 (data from 2020),Production mix factor
+PT,Europe,Portugal,Any,201.55,Country,carbonfootprint (March 2022) and Association of Issuing Bodies (AIB) 2021 (data from 2020),Production mix factor
+RO,Europe,Romania,Any,261.84,Country,carbonfootprint (March 2022) and Association of Issuing Bodies (AIB) 2021 (data from 2020),Production mix factor
+RU,Europe,Russian Federation,Any,310.2,Country,carbonfootprint (March 2022) and Climate Transparency (2021 Report) (data from 2020),Emissions intensity of the power sector
+RS,Europe,Serbia,Any,776.69,Country,carbonfootprint (March 2022) and Association of Issuing Bodies (AIB) 2021 (data from 2020),Production mix factor
+SK,Europe,Slovakia,Any,155.48,Country,carbonfootprint (March 2022) and Association of Issuing Bodies (AIB) 2021 (data from 2020),Production mix factor
+SI,Europe,Slovenia,Any,224.05,Country,carbonfootprint (March 2022) and Association of Issuing Bodies (AIB) 2021 (data from 2020),Production mix factor
+ES,Europe,Spain,Any,171.03,Country,carbonfootprint (March 2022) and Association of Issuing Bodies (AIB) 2021 (data from 2020),Production mix factor
+SE,Europe,Sweden,Any,5.67,Country,carbonfootprint (March 2022) and Association of Issuing Bodies (AIB) 2021 (data from 2020),Production mix factor
+CH,Europe,Switzerland,Any,11.52,Country,carbonfootprint (March 2022) and Association of Issuing Bodies (AIB) 2021 (data from 2020),Production mix factor
+GB,Europe,United Kingdom,Any,231.12,Country,carbonfootprint (March 2022) and UK Govt - Defra/BEIS 2021 (report from 2021 using 2019/20 data),Generation & transmission & distribution factors
+CA,North America,Canada,Any,120,Country,carbonfootprint (March 2022) and UN Framework Convention on Climate Change (report from 2021 based on 2019 data),Combined generation and T&D factor
+CA-AB,North America,Canada,Alberta,670,Region,carbonfootprint (March 2022) and Canada's submission to UN Framework convention on Climate Change (2021) (data from 2019 published in 2021),
+CA-BC,North America,Canada,British Columbia,19.7,Region,carbonfootprint (March 2022) and Canada's submission to UN Framework convention on Climate Change (2021) (data from 2019 published in 2021),
+CA-MT,North America,Canada,Manitoba,1.3,Region,carbonfootprint (March 2022) and Canada's submission to UN Framework convention on Climate Change (2021) (data from 2019 published in 2021),
+CA-NB,North America,Canada,New Brunswick,270,Region,carbonfootprint (March 2022) and Canada's submission to UN Framework convention on Climate Change (2021) (data from 2019 published in 2021),
+CA-NL,North America,Canada,Newfoundland and Labrador,29,Region,carbonfootprint (March 2022) and Canada's submission to UN Framework convention on Climate Change (2021) (data from 2019 published in 2021),
+CA-NS,North America,Canada,Nova Scotia,810,Region,carbonfootprint (March 2022) and Canada's submission to UN Framework convention on Climate Change (2021) (data from 2019 published in 2021),
+CA-NT,North America,Canada,Northwest Territories,200,Region,carbonfootprint (March 2022) and Canada's submission to UN Framework convention on Climate Change (2021) (data from 2019 published in 2021),
+CA-NU,North America,Canada,Nunavut,900,Region,carbonfootprint (March 2022) and Canada's submission to UN Framework convention on Climate Change (2021) (data from 2019 published in 2021),
+CA-ON,North America,Canada,Ontario,30,Region,carbonfootprint (March 2022) and Canada's submission to UN Framework convention on Climate Change (2021) (data from 2019 published in 2021),
+CA-PE,North America,Canada,Prince Edward Island,2,Region,carbonfootprint (March 2022) and Canada's submission to UN Framework convention on Climate Change (2021) (data from 2019 published in 2021),
+CA-QC,North America,Canada,Quebec,1.5,Region,carbonfootprint (March 2022) and Canada's submission to UN Framework convention on Climate Change (2021) (data from 2019 published in 2021),
+CA-SK,North America,Canada,Saskatchewan,710,Region,carbonfootprint (March 2022) and Canada's submission to UN Framework convention on Climate Change (2021) (data from 2019 published in 2021),
+CA-YT,North America,Canada,Yukon Territory,111,Region,carbonfootprint (March 2022) and Canada's submission to UN Framework convention on Climate Change (2021) (data from 2019 published in 2021),
+MX,North America,Mexico,Any,431.4,Country,carbonfootprint (March 2022) and Climate Transparency (2021 Report) (data from 2020),Emissions intensity of the power sector
+US,North America,United States of America,Any,423.94,Country,carbonfootprint (March 2022) and US Env Protection Agency (EPA) eGrid (data from 2019),Combined generation and T&D factor
+US-AK,North America,United States of America,Alaska,462.33,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-AL,North America,United States of America,Alabama,344.37,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-AR,North America,United States of America,Arkansas,454.4,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-AZ,North America,United States of America,Arizona,351.99,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-CA,North America,United States of America,California,216.43,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-CO,North America,United States of America,Colorado,582.34,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-CT,North America,United States of America,Connecticut,253,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-DC,North America,United States of America,Washington DC,382.68,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-DE,North America,United States of America,Delaware,360.68,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-FL,North America,United States of America,Florida,402.2,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-GA,North America,United States of America,Georgia,345.58,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-HI,North America,United States of America,Hawaii,731.21,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-IA,North America,United States of America,Iowa,293.85,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-ID,North America,United States of America,Idaho,101.89,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-IL,North America,United States of America,Illinois,265.8,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-IN,North America,United States of America,Indiana,740.02,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-KS,North America,United States of America,Kansas,384.08,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-KY,North America,United States of America,Kentucky,804.75,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-LA,North America,United States of America,Louisiana,363.82,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-MA,North America,United States of America,Massachusetts,420.32,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-MD,North America,United States of America,Maryland,308.21,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-ME,North America,United States of America,Maine,109,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-MI,North America,United States of America,Michigan,448.08,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-MN,North America,United States of America,Minnesota,367.93,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-MO,North America,United States of America,Missouri,773,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-MS,North America,United States of America,Mississip,427.07,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-MT,North America,United States of America,Montana,435.87,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-NC,North America,United States of America,North Carolina,309.73,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-ND,North America,United States of America,North Dakota,663.05,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-NE,North America,United States of America,Nebraska,573.51,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-NH,North America,United States of America,New Hampshire,118.44,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-NJ,North America,United States of America,New Jersey,235.1,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-NM,North America,United States of America,New Mexico,601.77,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-NV,North America,United States of America,Nevada,342.25,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-NY,North America,United States of America,New York,199.01,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-OH,North America,United States of America,Ohio,598.58,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-OK,North America,United States of America,Oklahoma,338.44,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-OR,North America,United States of America,Oregon,163.15,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-PA,North America,United States of America,Pennsylvania,333.19,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-RI,North America,United States of America,Rhode Island,395.27,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-SC,North America,United States of America,South Carolina,245.48,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-SD,North America,United States of America,South Dakota,162.69,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-TN,North America,United States of America,Tennessee,272.89,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-TX,North America,United States of America,Texas,409.16,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-UT,North America,United States of America,Utah,747.82,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-VA,North America,United States of America,Virginia,308,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-VT,North America,United States of America,Vermont,14.45,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-WA,North America,United States of America,Washington,101.84,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-WI,North America,United States of America,Wisconsin,569.39,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-WV,North America,United States of America,West Virginia,919.34,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+US-WY,North America,United States of America,Wyoming,950.5,Region,carbonfootprint (March 2022) (data from 2020 published in 2022),
+AU,Oceania,Australia,Any,840,Country,carbonfootprint (June 2022 v1.1) and Australian Government (data from 2019 published in August 2021),
+AU-ACT,Oceania,Australia,Australian Capital Territory,870,Region,carbonfootprint (March 2022) and the Australian government (data from 2019 published in 2021),
+AU-NSW,Oceania,Australia,New South Wales,870,Region,carbonfootprint (March 2022) and the Australian government (data from 2019 published in 2021),
+AU-NT,Oceania,Australia,Northern Territory,620,Region,carbonfootprint (March 2022) and the Australian government (data from 2019 published in 2021),
+AU-NT2,Oceania,Australia,Northern Territory (Darwin Katherine Interconnected System),540,Region,carbonfootprint (March 2022) and the Australian government (data from 2019 published in 2021),
+AU-QLD,Oceania,Australia,Queensland,920,Region,carbonfootprint (March 2022) and the Australian government (data from 2019 published in 2021),
+AU-SA,Oceania,Australia,South Australia,420,Region,carbonfootprint (March 2022) and the Australian government (data from 2019 published in 2021),
+AU-TAS,Oceania,Australia,Tasmania,180,Region,carbonfootprint (March 2022) and the Australian government (data from 2019 published in 2021),
+AU-VIC,Oceania,Australia,Victoria,1060,Region,carbonfootprint (March 2022) and the Australian government (data from 2019 published in 2021),
+AU-WA1,Oceania,Australia,Western Australia (North Western Interconnected System),580,Region,carbonfootprint (March 2022) and the Australian government (data from 2019 published in 2021),
+AU-WA2,Oceania,Australia,Western Australia (South West Interconnected System),700,Region,carbonfootprint (March 2022) and the Australian government (data from 2019 published in 2021),
+NZ,Oceania,New Zealand,Any,110.1,Country,carbonfootprint (March 2022) and Ministry for the Environment https://www.mfe.govt.nz/node/18670/ (data from 2018),"Emission factors published in 2020, based on 2018 national inventory."
+AR,South America,Argentina,Any,307,Country,carbonfootprint (March 2022) and Climate Transparency (2021 Report) (data from 2020),Emissions intensity of the power sector
+BR,South America,Brazil,Any,61.7,Country,carbonfootprint (March 2022) and Climate Transparency (2021 Report) (data from 2020),Emissions intensity of the power sector
+UY,South America,Uruguay,Any,129,Country,https://app.electricitymaps.com/zone/UY,Data from 2021
diff --git a/lib/galaxy/config/__init__.py b/lib/galaxy/config/__init__.py
index 9bc573842d66..e6a381a64da3 100644
--- a/lib/galaxy/config/__init__.py
+++ b/lib/galaxy/config/__init__.py
@@ -34,6 +34,7 @@
import yaml
+from galaxy.carbon_emissions import get_carbon_intensity_entry
from galaxy.config.schema import AppSchema
from galaxy.exceptions import ConfigurationError
from galaxy.util import (
@@ -691,49 +692,52 @@ class GalaxyAppConfiguration(BaseAppConfiguration, CommonConfigurationMixin):
"tool_data_table_config_path",
"tool_config_file",
}
+
+ allowed_origin_hostnames: List[str]
+ builds_file_path: str
+ carbon_intensity: float
+ container_resolvers_config_file: str
database_connection: str
- tool_path: str
- tool_data_path: str
- new_file_path: str
drmaa_external_runjob_script: str
- track_jobs_in_database: bool
- monitor_thread_join_timeout: int
- manage_dependency_relationships: bool
+ email_from: Optional[str]
enable_tool_shed_check: bool
- builds_file_path: str
- len_file_path: str
- integrated_tool_panel_config: str
- toolbox_filter_base_modules: List[str]
- tool_filters: List[str]
- tool_label_filters: List[str]
- tool_section_filters: List[str]
- user_tool_filters: List[str]
- user_tool_section_filters: List[str]
- user_tool_label_filters: List[str]
- password_expiration_period: timedelta
- shed_tool_data_path: str
- hours_between_check: int
galaxy_data_manager_data_path: str
- use_remote_user: bool
- preserve_python_environment: str
- email_from: Optional[str]
- workflow_resource_params_mapper: str
- sanitize_allowlist_file: str
- allowed_origin_hostnames: List[str]
- trust_jupyter_notebook_conversion: bool
- user_library_import_symlink_allowlist: List[str]
- user_library_import_dir_auto_creation: bool
- container_resolvers_config_file: str
- tool_dependency_dir: Optional[str]
+ galaxy_infrastructure_url: str
+ geographical_server_location_name: str
+ hours_between_check: int
+ integrated_tool_panel_config: str
involucro_path: str
+ len_file_path: str
+ manage_dependency_relationships: bool
+ monitor_thread_join_timeout: int
mulled_channels: List[str]
+ new_file_path: str
nginx_upload_store: str
- tus_upload_store: str
+ password_expiration_period: timedelta
+ preserve_python_environment: str
pretty_datetime_format: str
- visualization_plugins_directory: str
- galaxy_infrastructure_url: str
+ sanitize_allowlist_file: str
+ shed_tool_data_path: str
themes: Dict[str, Dict[str, str]]
themes_by_host: Dict[str, Dict[str, Dict[str, str]]]
+ tool_data_path: str
+ tool_dependency_dir: Optional[str]
+ tool_filters: List[str]
+ tool_label_filters: List[str]
+ tool_path: str
+ tool_section_filters: List[str]
+ toolbox_filter_base_modules: List[str]
+ track_jobs_in_database: bool
+ trust_jupyter_notebook_conversion: bool
+ tus_upload_store: str
+ use_remote_user: bool
+ user_library_import_dir_auto_creation: bool
+ user_library_import_symlink_allowlist: List[str]
+ user_tool_filters: List[str]
+ user_tool_label_filters: List[str]
+ user_tool_section_filters: List[str]
+ visualization_plugins_directory: str
+ workflow_resource_params_mapper: str
def __init__(self, **kwargs):
super().__init__(**kwargs)
@@ -836,6 +840,11 @@ def _process_config(self, kwargs: Dict[str, Any]) -> None:
else:
self.version_extra = extra_info
+ # Carbon emissions configuration
+ carbon_intensity_entry = get_carbon_intensity_entry(kwargs.get("geographical_server_location_code", ""))
+ self.carbon_intensity = carbon_intensity_entry["carbon_intensity"]
+ self.geographical_server_location_name = carbon_intensity_entry["location_name"]
+
# Database related configuration
self.check_migrate_databases = string_as_bool(kwargs.get("check_migrate_databases", True))
if not self.database_connection: # Provide default if not supplied by user
diff --git a/lib/galaxy/config/sample/galaxy.yml.sample b/lib/galaxy/config/sample/galaxy.yml.sample
index 506300418a4f..0482e2d2e165 100644
--- a/lib/galaxy/config/sample/galaxy.yml.sample
+++ b/lib/galaxy/config/sample/galaxy.yml.sample
@@ -1249,6 +1249,33 @@ galaxy:
# pricing table. Please note, that those numbers are only estimates.
#aws_estimate: false
+ # This flag enables carbon emissions estimates for every job based on
+ # its runtime metrics. CPU and RAM usage and the total job runtime are
+ # used to determine an estimate value. These estimates and are based
+ # off of the work of the Green Algorithms Project and the United
+ # States Environmental Protection Agency (EPA). Visit
+ # https://www.green-algorithms.org/ and
+ # https://www.epa.gov/energy/greenhouse-gas-equivalencies-calculator.
+ # for more detals.
+ #carbon_emission_estimates: true
+
+ # The estimated geographical location of the server hosting your
+ # galaxy instance given as an ISO 3166 code. This is used to make
+ # carbon emissions estimates more accurate as the location effects the
+ # carbon intensity values used in the estimate calculation. This
+ # defaults to "GLOBAL" if not set or the
+ # `geographical_server_location_code` value is invalid or unsupported.
+ # To see a full list of supported locations, visit
+ # https://galaxyproject.org/admin/carbon_emissions
+ #geographical_server_location_code: GLOBAL
+
+ # The estimated power usage effectiveness of the data centre housing
+ # the server your galaxy instance is running on. This can make carbon
+ # emissions estimates more accurate. For more information on how to
+ # calculate a PUE value, visit
+ # https://en.wikipedia.org/wiki/Power_usage_effectiveness
+ #power_usage_effectiveness: 1.67
+
# Enable InteractiveTools.
#interactivetools_enable: false
diff --git a/lib/galaxy/config/schemas/config_schema.yml b/lib/galaxy/config/schemas/config_schema.yml
index 175e792996d8..e9059f4d94c3 100644
--- a/lib/galaxy/config/schemas/config_schema.yml
+++ b/lib/galaxy/config/schemas/config_schema.yml
@@ -1384,6 +1384,39 @@ mapping:
CPU, RAM and runtime usage is mapped against AWS pricing table.
Please note, that those numbers are only estimates.
+ carbon_emission_estimates:
+ type: bool
+ default: true
+ required: false
+ desc: |
+ This flag enables carbon emissions estimates for every job based on its runtime metrics.
+ CPU and RAM usage and the total job runtime are used to determine an estimate value.
+ These estimates and are based off of the work of the Green Algorithms Project and
+ the United States Environmental Protection Agency (EPA).
+ Visit https://www.green-algorithms.org/ and https://www.epa.gov/energy/greenhouse-gas-equivalencies-calculator.
+ for more detals.
+
+ geographical_server_location_code:
+ type: str
+ default: "GLOBAL"
+ required: false
+ desc: |
+ The estimated geographical location of the server hosting your galaxy instance given as an ISO 3166 code.
+ This is used to make carbon emissions estimates more accurate as the location effects the
+ carbon intensity values used in the estimate calculation. This defaults to "GLOBAL" if not set or the
+ `geographical_server_location_code` value is invalid or unsupported. To see a full list of supported locations,
+ visit https://galaxyproject.org/admin/carbon_emissions
+
+ power_usage_effectiveness:
+ type: float
+ default: 1.67
+ required: false
+ desc: |
+ The estimated power usage effectiveness of the data centre housing the server your galaxy
+ instance is running on. This can make carbon emissions estimates more accurate.
+ For more information on how to calculate a PUE value, visit
+ https://en.wikipedia.org/wiki/Power_usage_effectiveness
+
interactivetools_enable:
type: bool
default: false
diff --git a/lib/galaxy/managers/configuration.py b/lib/galaxy/managers/configuration.py
index d104893b64c2..d9bcf001e3e2 100644
--- a/lib/galaxy/managers/configuration.py
+++ b/lib/galaxy/managers/configuration.py
@@ -175,6 +175,11 @@ def _config_is_truthy(item, key, **context):
"visualizations_visible": _use_config,
"interactivetools_enable": _use_config,
"aws_estimate": _use_config,
+ "carbon_emission_estimates": _defaults_to(True),
+ "carbon_intensity": _use_config,
+ "geographical_server_location_name": _use_config,
+ "geographical_server_location_code": _use_config,
+ "power_usage_effectiveness": _use_config,
"message_box_content": _use_config,
"message_box_visible": _use_config,
"message_box_class": _use_config,
diff --git a/packages/app/galaxy/carbon_emissions b/packages/app/galaxy/carbon_emissions
new file mode 120000
index 000000000000..9e176e540041
--- /dev/null
+++ b/packages/app/galaxy/carbon_emissions
@@ -0,0 +1 @@
+../../../lib/galaxy/carbon_emissions
\ No newline at end of file
diff --git a/test/unit/carbon_emissions/__init__.py b/test/unit/carbon_emissions/__init__.py
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/test/unit/carbon_emissions/test_get_carbon_intensity_entry.py b/test/unit/carbon_emissions/test_get_carbon_intensity_entry.py
new file mode 100644
index 000000000000..0a67c37d61cf
--- /dev/null
+++ b/test/unit/carbon_emissions/test_get_carbon_intensity_entry.py
@@ -0,0 +1,20 @@
+from galaxy.carbon_emissions import get_carbon_intensity_entry
+
+
+def test_get_carbon_intensity_entry():
+ """
+ Test if `get_carbon_intensity_entry` retrieves the correct name and carbon
+ intensity value for a country or region
+ """
+ country_entry = get_carbon_intensity_entry("US")
+ region_entry = get_carbon_intensity_entry("US-NY")
+ invalid_entry = get_carbon_intensity_entry("Raya Lucaria")
+
+ assert country_entry["location_name"] == "United States of America"
+ assert country_entry["carbon_intensity"] == 423.94
+
+ assert region_entry["location_name"] == "New York (United States of America)"
+ assert region_entry["carbon_intensity"] == 199.01
+
+ assert invalid_entry["location_name"] == "GLOBAL"
+ assert invalid_entry["carbon_intensity"] == 475.0