Skip to content

Commit

Permalink
Removing old API params and sending as uJ
Browse files Browse the repository at this point in the history
  • Loading branch information
ArneTR committed Oct 17, 2024
1 parent 65f1828 commit 5076787
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/test_carbondb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
api-endpoint-add: "http://api-478gtuzwbe72.green-coding.io:9142/v2/ci/measurement/add"

- name: Sleep step
run: sleep 2
Expand Down
1 change: 0 additions & 1 deletion scripts/display_results.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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:-}

Expand Down
16 changes: 7 additions & 9 deletions scripts/make_measurement.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down Expand Up @@ -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"
Expand All @@ -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:-""}\",
Expand Down

0 comments on commit 5076787

Please sign in to comment.