Skip to content

Commit

Permalink
Merge branch 'main' into ssl
Browse files Browse the repository at this point in the history
* main:
  Refactor reporters and install script (#920)
  Makes the disk optional (#926)
  Added uninstall script (#927)
  Bump aiohttp from 3.10.6 to 3.10.8 (#925)
  Bump psycopg[binary] from 3.2.2 to 3.2.3 (#924)
  Bump uvicorn[standard] from 0.30.6 to 0.31.0 (#923)
  Bump redis from 5.0.8 to 5.1.0 (#922)
  Adding dev requirements again
  Typo
  Catching response failure for API request and handling gracefully
  Changing default to ip_api_com as this has shown to be more reliable
  Added timeline_project to demo data
  Changed to -solutions
  Changed to -solutions in container cache and gitmodules
  Groupby error in API
  • Loading branch information
ArneTR committed Oct 1, 2024
2 parents 4755676 + 876081f commit bf221f9
Show file tree
Hide file tree
Showing 23 changed files with 103 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-codespace-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ jobs:
context: .
file: /.devcontainer/containerized/Dockerfile # Path to the Dockerfile
push: true
tags: ghcr.io/green-coding-berlin/codespace-container:latest
tags: ghcr.io/green-coding-solutions/codespace-container:latest
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "lib/sgx-software-enable"]
path = lib/sgx-software-enable
url = https://github.com/green-coding-berlin/sgx-software-enable
url = https://github.com/green-coding-solutions/sgx-software-enable
[submodule "metric_providers/psu/energy/ac/xgboost/machine/model"]
path = metric_providers/psu/energy/ac/xgboost/machine/model
url = https://github.com/green-coding-berlin/spec-power-model
path = metric_providers/psu/energy/ac/xgboost/machine/model
url = https://github.com/green-coding-solutions/spec-power-model
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ authors:
family-names: Hoffmann
email: [email protected]
affiliation: Green Coding Solutions GmbH
repository-code: 'https://github.com/green-coding-berlin/green-metrics-tool'
repository-code: 'https://github.com/green-coding-solutions/green-metrics-tool'
url: 'https://www.green-coding.io/'
repository: 'https://github.com/green-coding-berlin/'
repository: 'https://github.com/green-coding-solutions/'
abstract: >-
The Green Metrics Tool is a developer tool indented for
measuring the energy and CO2 consumption of software
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Tests Status - Main](https://github.com/green-coding-berlin/green-metrics-tool/actions/workflows/tests-vm-main.yml/badge.svg)](https://github.com/green-coding-berlin/green-metrics-tool/actions/workflows/tests-vm-main.yml)
[![Tests Status - Main](https://github.com/green-coding-solutions/green-metrics-tool/actions/workflows/tests-vm-main.yml/badge.svg)](https://github.com/green-coding-solutions/green-metrics-tool/actions/workflows/tests-vm-main.yml)


[![Energy Used](https://api.green-coding.io/v1/ci/badge/get/?repo=green-coding-solutions/green-metrics-tool&branch=main&workflow=45267393)](https://metrics.green-coding.io/ci.html?repo=green-coding-solutions/green-metrics-tool&branch=main&workflow=45267393) (This is the energy cost of running our CI-Pipelines on Github. [Find out more about Eco-CI](https://www.green-coding.io/projects/eco-ci/))
Expand All @@ -15,7 +15,7 @@ Key features are:
- API - [DEMO](https://api.green-coding.io)
- [Cluster setup](https://docs.green-coding.io/docs/installation/installation-cluster/)
- [Free Hosted service for more precise measurements](https://docs.green-coding.io/docs/measuring/measurement-cluster/)
- Timeline-View: Monitor software projects over time - [DEMO for Wagtail](https://metrics.green-coding.io/timeline.html?uri=https://github.com/green-coding-berlin/bakerydemo-gold-benchmark&filename=usage_scenario_warm.yml&branch=&machine_id=7) / [DEMO Overview](https://metrics.green-coding.io/energy-timeline.html)
- Timeline-View: Monitor software projects over time - [DEMO for Wagtail](https://metrics.green-coding.io/timeline.html?uri=https://github.com/green-coding-solutions/bakerydemo-gold-benchmark&filename=usage_scenario_warm.yml&branch=&machine_id=7) / [DEMO Overview](https://metrics.green-coding.io/energy-timeline.html)
- [Energy-ID Score-Cards](https://www.green-coding.io/projects/energy-id/) for software (Also see below)

It is designed to re-use existing infrastructure and testing files as much as possible to be easily integrateable into every software repository and create transparency around software energy consumption.
Expand Down Expand Up @@ -48,7 +48,7 @@ To see the the documentation and how to install and use the tool please go to [G
![](https://www.green-coding.io/img/projects/gmt-screenshot-6.webp)

# Energy-ID Scorecards
<img width="1034" alt="Screenshot 2023-10-24 at 10 43 28 AM" src="https://github.com/green-coding-berlin/green-metrics-tool/assets/250671/7e3e3faa-5452-4722-af70-a65114f930ac">
<img width="1034" alt="Screenshot 2023-10-24 at 10 43 28 AM" src="https://github.com/green-coding-solutions/green-metrics-tool/assets/250671/7e3e3faa-5452-4722-af70-a65114f930ac">

Details: [Energy-ID project page](https://www.green-coding.io/projects/energy-id/
)
Expand Down
25 changes: 20 additions & 5 deletions api/api_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,10 +623,10 @@ def get_geo(ip):
if db_data is not None and len(db_data) != 0:
return (db_data[0][1].get('latitude'), db_data[0][1].get('longitude'))

latitude, longitude = get_geo_ipapi_co(ip)
latitude, longitude = get_geo_ip_api_com(ip)

if not latitude:
latitude, longitude = get_geo_ip_api_com(ip)
latitude, longitude = get_geo_ipapi_co(ip)
if not latitude:
latitude, longitude = get_geo_ip_ipinfo(ip)
if not latitude:
Expand All @@ -637,7 +637,12 @@ def get_geo(ip):

def get_geo_ipapi_co(ip):

response = requests.get(f"https://ipapi.co/{ip}/json/", timeout=10)
print(f"Accessing https://ipapi.co/{ip}/json/")
try:
response = requests.get(f"https://ipapi.co/{ip}/json/", timeout=10)
except Exception as exc: #pylint: disable=broad-exception-caught
error_helpers.log_error('API request to ipapi.co failed ...', exception=exc)
return (False, False)

if response.status_code == 200:
resp_data = response.json()
Expand All @@ -658,8 +663,13 @@ def get_geo_ipapi_co(ip):

def get_geo_ip_api_com(ip):

response = requests.get(f"http://ip-api.com/json/{ip}", timeout=10)
print(f"Accessing http://ip-api.com/json/{ip}")
try:
response = requests.get(f"http://ip-api.com/json/{ip}", timeout=10)
except Exception as exc: #pylint: disable=broad-exception-caught
error_helpers.log_error('API request to ip-api.com failed ...', exception=exc)
return (False, False)

if response.status_code == 200:
resp_data = response.json()

Expand All @@ -681,8 +691,13 @@ def get_geo_ip_api_com(ip):

def get_geo_ip_ipinfo(ip):

response = requests.get(f"https://ipinfo.io/{ip}/json", timeout=10)
print(f"Accessing https://ipinfo.io/{ip}/json")
try:
response = requests.get(f"https://ipinfo.io/{ip}/json", timeout=10)
except Exception as exc: #pylint: disable=broad-exception-caught
error_helpers.log_error('API request to ipinfo.io failed ...', exception=exc)
return (False, False)

if response.status_code == 200:
resp_data = response.json()

Expand Down
8 changes: 4 additions & 4 deletions api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ async def get_repositories(uri: str | None = None, branch: str | None = None, ma
FROM runs as r
LEFT JOIN machines as m on r.machine_id = m.id
WHERE 1=1
GROUP BY r.uri
"""
params = []

Expand All @@ -244,6 +243,8 @@ async def get_repositories(uri: str | None = None, branch: str | None = None, ma
query = f"{query} AND m.description LIKE %s \n"
params.append(f"%{machine}%")

query = f"{query} GROUP BY r.uri\n"

if sort_by == 'name':
query = f"{query} ORDER BY r.uri ASC"
else:
Expand Down Expand Up @@ -1294,9 +1295,8 @@ async def post_ci_measurement_add(

try:
carbondb_add(client_ip, [energydata], user._id)
#pylint: disable=broad-except
except Exception as exc:
error_helpers.log_error('CI Measurement was successfully added, but CarbonDB did failed', exception=exc)
except Exception as exc: #pylint: disable=broad-except
error_helpers.log_error('CI Measurement was successfully added, but CarbonDB did fail', exception=exc)
return ORJSONResponse({
'success': False,
'err': f"CI Measurement was successfully added, but CarbonDB did respond with exception: {str(exc)}"},
Expand Down
2 changes: 1 addition & 1 deletion api/object_specifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Measurement(BaseModel):
coalitions: List[Coalition]
all_tasks: Dict
network: Optional[Dict] = None # network is optional when system is in flight mode / network turned off
disk: Dict
disk: Optional[Dict] = None # No idea what system would not have a disk but we are seeing this in production
interrupts: List
processor: Processor
thermal_pressure: str
Expand Down
6 changes: 5 additions & 1 deletion data/demo_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9260,4 +9260,8 @@ VALUES
(12,E'3e6554a4-10bc-46d6-93a1-e61bfd1d9808',E'You are not using CPU limits definitions on gcb-alpine-stress',E'container_cpu_utilization',E'blue',E'utilization',E'tachometer alternate',E'Even if you want to use all CPUs you should explicitely specify it',NULL,E'2024-09-12 16:59:19.52914+00',NULL),
(13,E'af76f822-c042-4bf1-a5aa-5566761ef351',E'Why am I not seeing more data',E'message_optimization',E'blue',E'GMT core',E'diagnoses',E'\n The Green Metrics Tool is a FOSS software that empowers users to make software more sustainable\n by measuring energy and carbon. We believe that FOSS is the most beneficial way to go here as\n transparency is key to create trust, adoption and awareness of the carbon emissions of software.\n Some features like hosting, automated measurements and also optimizations we use as our angle\n to support the free continuous development of the tool. So if you use this tool professionally\n and want to take the step from awareness and measurement to optimization maybe consider\n supporting us. If you want to use this tool for research, are an NGO or a student please reach\n out to us - We have special free and reduced priced options. If you don\'t want to see this\n message and you are running your own cluster just add the message_optimization to the ignore\n list into your config file.\n ',E'https://www.green-coding.io/projects/green-metrics-tool/',E'2024-09-12 17:01:39.320399+00',NULL),
(14,E'af76f822-c042-4bf1-a5aa-5566761ef351',E'You are not using Memory limits definitions on gcb-alpine-stress',E'container_memory_utilization',E'blue',E'utilization',E'tachometer alternate',E'Even if you want to use all memory you should explicitely specify it',NULL,E'2024-09-12 17:01:39.321833+00',NULL),
(15,E'af76f822-c042-4bf1-a5aa-5566761ef351',E'You are not using CPU limits definitions on gcb-alpine-stress',E'container_cpu_utilization',E'blue',E'utilization',E'tachometer alternate',E'Even if you want to use all CPUs you should explicitely specify it',NULL,E'2024-09-12 17:01:39.322704+00',NULL);
(15,E'af76f822-c042-4bf1-a5aa-5566761ef351',E'You are not using CPU limits definitions on gcb-alpine-stress',E'container_cpu_utilization',E'blue',E'utilization',E'tachometer alternate',E'Even if you want to use all CPUs you should explicitely specify it',NULL,E'2024-09-12 17:01:39.322704+00',NULL);

INSERT INTO "public"."timeline_projects"("id","name","url","categories","branch","filename","machine_id","schedule_mode","last_scheduled","user_id","created_at","updated_at")
VALUES
(1,E'Stress Demo Timeline',E'/home/arne/Sites/green-coding/example-applications/',NULL,E'main',E'stress/usage_scenario.yml',1,E'daily',NULL,1,E'2024-09-29 11:28:41.788281+00',E'2024-09-29 11:29:32.07175+00');
4 changes: 2 additions & 2 deletions docker/docker-compose-cache.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"target": {
"test-green-coding-gunicorn": {
"cache-from": [
"type=registry,ref=ghcr.io/green-coding-berlin/gunicorn-container-cache:cache"
"type=registry,ref=ghcr.io/green-coding-solutions/gunicorn-container-cache:cache"
],
"cache-to": [
"type=registry,ref=ghcr.io/green-coding-berlin/gunicorn-container-cache:cache"
"type=registry,ref=ghcr.io/green-coding-solutions/gunicorn-container-cache:cache"
],
"output": [
"type=docker"
Expand Down
6 changes: 3 additions & 3 deletions docker/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
gunicorn==23.0.0
psycopg[binary]==3.2.2
psycopg[binary]==3.2.3
psycopg_pool==3.2.3
fastapi[standard]==0.115.0
starlette>=0.35
uvicorn[standard]==0.30.6
uvicorn[standard]==0.31.0
pandas==2.2.3
PyYAML==6.0.2
anybadge==1.14.0
orjson==3.10.7
scipy==1.14.1
schema==0.7.7
deepdiff==8.0.1
redis==5.0.8
redis==5.1.0
hiredis==3.0.0
requests==2.32.3
uvicorn-worker==0.2.0
2 changes: 1 addition & 1 deletion frontend/js/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ $(document).ready(function () {
{ data: 6, title: 'GMT version', render: function(el, type, row) {
if (el == null) return '-';

return `<a href="https://github.com/green-coding-berlin/green-metrics-tool/commit/${el}" title="${dateToYMD(new Date(row[7]))}">${`${el.substr(0,3)}...${el.substr(-3,3)}`}</a>`;
return `<a href="https://github.com/green-coding-solutions/green-metrics-tool/commit/${el}" title="${dateToYMD(new Date(row[7]))}">${`${el.substr(0,3)}...${el.substr(-3,3)}`}</a>`;

}},
{ data: 13, title: 'Details', render: function(el, type, row) {
Expand Down
2 changes: 1 addition & 1 deletion frontend/js/timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ const loadCharts = async () => {
value: ${numberFormatter.format(series[params.seriesName].values[params.dataIndex].value)}<br>
commit_timestamp: ${series[params.seriesName].notes[params.dataIndex].commit_timestamp}<br>
commit_hash: <a href="${$("#uri").text()}/commit/${series[params.seriesName].notes[params.dataIndex].commit_hash}" target="_blank">${series[params.seriesName].notes[params.dataIndex].commit_hash}</a><br>
gmt_hash: <a href="https://github.com/green-coding-berlin/green-metrics-tool/commit/${series[params.seriesName].notes[params.dataIndex].gmt_hash}" target="_blank">${series[params.seriesName].notes[params.dataIndex].gmt_hash}</a><br>
gmt_hash: <a href="https://github.com/green-coding-solutions/green-metrics-tool/commit/${series[params.seriesName].notes[params.dataIndex].gmt_hash}" target="_blank">${series[params.seriesName].notes[params.dataIndex].gmt_hash}</a><br>
<br>
👉 <a href="/compare.html?ids=${series[params.seriesName].notes[params.dataIndex].run_id},${series[params.seriesName].notes[params.dataIndex].prun_id}" target="_blank">Diff with previous run</a>
Expand Down
2 changes: 1 addition & 1 deletion frontend/request.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ <h1 class="ui header float left">
to the statistics.</p>
<p>Your run will be put in a queue and processed in the next free slot.</p>
<p>The Green Metrics Tool expects a schema-correct
<a href="https://docs.green-coding.io/docs/measuring/usage-scenario/">usage_scenario.yml</a> file in your repository root. Please check the <a href="https://github.com/green-coding-berlin/simple-example-application">Demo
<a href="https://docs.green-coding.io/docs/measuring/usage-scenario/">usage_scenario.yml</a> file in your repository root. Please check the <a href="https://github.com/green-coding-solutions/simple-example-application">Demo
Software Repository</a> for example and documentation.<br/>
Override the usage scenario file name or provide relative path if it is not in the repository root with the optional filename field.
</p>
Expand Down
2 changes: 1 addition & 1 deletion metric_providers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def start_profiling(self, containers=None):
call_string += ' ' # space at start
call_string += ' '.join(self._extra_switches)

# This needs refactoring see https://github.com/green-coding-berlin/green-metrics-tool/issues/45
# This needs refactoring see https://github.com/green-coding-solutions/green-metrics-tool/issues/45
if (self._metrics.get('container_id') is not None) and (containers is not None):
call_string += ' -s '
call_string += ','.join(containers.keys())
Expand Down
2 changes: 1 addition & 1 deletion metric_providers/lmsensors/abstract_provider.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# We need to separate the lm sensor providers into multiple files as the frontend has the conversion and
# unit hardcoded. So it is currently not possible to have one provider return temperature and fan speed.
# Discussion is here https://github.com/green-coding-berlin/green-metrics-tool/issues/39
# Discussion is here https://github.com/green-coding-solutions/green-metrics-tool/issues/39

import os
import subprocess
Expand Down
4 changes: 2 additions & 2 deletions metric_providers/powermetrics/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ def stop_profiling(self):

try:
# We try calling the parent method which should work see
# https://github.com/green-coding-berlin/green-metrics-tool/pull/566#discussion_r1429891190
# https://github.com/green-coding-solutions/green-metrics-tool/pull/566#discussion_r1429891190
# but we keep the try to make sure that if we ever change the sudo call it still works
super().stop_profiling()
except PermissionError:
# We will land here in any case as stated before (root permissions missing). When we trigger *killall* now
# the process will be terminated. We opted for this implementation as other processes on the system, like
# for instance the power hog (https://github.com/green-coding-berlin/hog) should not be affected too much.
# for instance the power hog (https://github.com/green-coding-solutions/hog) should not be affected too much.
# They restart the process anyway when it gets killed. However manual processes that the user might have
# started will also be killed, so we issue a notice.
# There is really no better way of doing this as of now. Keeping the process id for instance in a hash and
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
PyYAML==6.0.2
pandas==2.2.3
psycopg[binary]==3.2.2
psycopg[binary]==3.2.3
psycopg_pool==3.2.3
pyserial==3.5
psutil==6.0.0
schema==0.7.7
aiohttp==3.10.6
aiohttp==3.10.8

# calibration script dep
tqdm==4.66.5
Expand Down
2 changes: 1 addition & 1 deletion runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -1447,7 +1447,7 @@ def save_stdout_logs(self):


def cleanup(self, continue_measurement=False):
#https://github.com/green-coding-berlin/green-metrics-tool/issues/97
#https://github.com/green-coding-solutions/green-metrics-tool/issues/97
print(TerminalColors.OKCYAN, '\nStarting cleanup routine', TerminalColors.ENDC)

if continue_measurement is False:
Expand Down
2 changes: 1 addition & 1 deletion test-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ cluster:
shutdown_on_job_no: false
control_workload:
name: Measurement control Workload
uri: https://github.com/green-coding-berlin/measurement-control-workload
uri: https://github.com/green-coding-solutions/measurement-control-workload
filename: usage_scenario.yml
branch: main
comparison_window: 5
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

def test_simple_cluster_run():
name = utils.randomword(12)
url = 'https://github.com/green-coding-berlin/pytest-dummy-repo'
url = 'https://github.com/green-coding-solutions/pytest-dummy-repo'
filename = 'usage_scenario.yml'
branch = 'main'
machine_id = 1
Expand Down
Loading

0 comments on commit bf221f9

Please sign in to comment.