From 3133cc1dae139b810880b407b9019d5379793f3d Mon Sep 17 00:00:00 2001 From: Arne Tarara Date: Thu, 17 Oct 2024 20:12:44 +0200 Subject: [PATCH] Removing old API params and sending as uJ --- .github/workflows/test_carbondb.yml | 5 ++--- scripts/display_results.sh | 1 - scripts/make_measurement.sh | 16 +++++++--------- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test_carbondb.yml b/.github/workflows/test_carbondb.yml index 76ee3301..95bc66ce 100644 --- a/.github/workflows/test_carbondb.yml +++ b/.github/workflows/test_carbondb.yml @@ -42,11 +42,10 @@ jobs: with: task: start-measurement # type should be auto set to machine.ci - company: "My cool company" project: "CI Testing" machine: "ubuntu-latest" - tags: '["That-os-one","That-is-number-two"]' - api-endpoint: "http://api-478gtuzwbe72.green-coding.io:9142/v2/ci/measurement/add" + tags: '[\"That-os-one\",\"That-is-number-two\"]' + api-endpoint-add: "http://api-478gtuzwbe72.green-coding.io:9142/v2/ci/measurement/add" - name: Sleep step run: sleep 2 diff --git a/scripts/display_results.sh b/scripts/display_results.sh index 81659f41..19cbc436 100755 --- a/scripts/display_results.sh +++ b/scripts/display_results.sh @@ -14,7 +14,6 @@ function display_results { MEASUREMENT_RAN=${MEASUREMENT_RAN:-} MEASUREMENT_COUNT=${MEASUREMENT_COUNT:-} WORKFLOW_ID=${WORKFLOW_ID:-} - API_ENDPOINT_BADGE_GET=${API_ENDPOINT_BADGE_GET:-} JSON_OUTPUT=${JSON_OUTPUT:-} GITHUB_STEP_SUMMARY=${GITHUB_STEP_SUMMARY:-} diff --git a/scripts/make_measurement.sh b/scripts/make_measurement.sh index e0c373bb..db340c0e 100755 --- a/scripts/make_measurement.sh +++ b/scripts/make_measurement.sh @@ -39,7 +39,6 @@ function make_measurement() { MODEL_NAME=${MODEL_NAME:-} MEASUREMENT_COUNT=${MEASUREMENT_COUNT:-} WORKFLOW_ID=${WORKFLOW_ID:-} - API_ENDPOINT_ADD=${API_ENDPOINT_ADD:-} # capture time step_time=$(($(date +%s) - $(cat /tmp/eco-ci/timer-step.txt))) @@ -77,6 +76,7 @@ function make_measurement() { if [[ $SEND_DATA == 'true' ]]; then + echo "Sending data to ${API_ENDPOINT_ADD}" source "$(dirname "$0")/misc.sh" get_energy_co2 "$step_energy" @@ -91,29 +91,27 @@ function make_measurement() { CO2EQ=$(echo "$CO2EQ_EMBODIED $CO2EQ_ENERGY" | awk '{printf "%.9f", $1 + $2}') fi - value_mJ=$(echo "$step_energy 1000" | awk '{printf "%.9f", $1 * $2}' | cut -d '.' -f 1) + value_uJ=$(echo "$step_energy 1000000" | awk '{printf "%.9f", $1 * $2}' | cut -d '.' -f 1) unit="mJ" model_name_uri=$(echo $MODEL_NAME | jq -Rr @uri) curl -X POST "${API_ENDPOINT_ADD}" -H 'Content-Type: application/json' -d "{ - \"energy_value\":\"${value_mJ}\", - \"energy_unit\":\"${unit}\", + \"energy_uj\":\"${value_uJ}\", \"cpu\":\"${model_name_uri}\", \"commit_hash\":\"${COMMIT_HASH}\", \"repo\":\"${REPOSITORY}\", \"branch\":\"${BRANCH}\", \"workflow\":\"${WORKFLOW_ID}\", \"run_id\":\"${RUN_ID}\", - \"project_id\":\"\", \"label\":\"${label}\", \"source\":\"${SOURCE}\", \"cpu_util_avg\":\"${cpu_avg}\", \"duration\":\"${step_time}\", \"workflow_name\":\"${WORKFLOW_NAME}\", - \"filter_type\":\"${CB_COMPANY_UUID}\", - \"filter_project\":\"${CB_PROJECT_UUID}\", - \"filter_machine\":\"${CB_MACHINE_UUID}\", - \"filter_tags\":\"${CB_MACHINE_UUID}\", + \"filter_type\":\"${FILTER_TYPE}\", + \"filter_project\":\"${FILTER_PROJECT}\", + \"filter_machine\":\"${FILTER_MACHINE}\", + \"filter_tags\":${FILTER_TAGS}, \"lat\":\"${LAT:-""}\", \"lon\":\"${LON:-""}\", \"city\":\"${CITY:-""}\",