Skip to content

Commit 203af14

Browse files
committed
docs(getting-started): Fix option for UID/GUID
1 parent b91e44d commit 203af14

File tree

4 files changed

+37
-26
lines changed

4 files changed

+37
-26
lines changed

Diff for: docs/script/getting_started/.env

-22
Original file line numberDiff line numberDiff line change
@@ -1,22 +0,0 @@
1-
# Sensor image
2-
SENSOR_IMAGE=powerapi/hwpc-sensor:${HWPC_SENSOR_VERSION:-latest}
3-
4-
# Formula image
5-
FORMULA_IMAGE=powerapi/smartwatts-formula:${SMARTWATTS_VERSION:-latest}
6-
7-
# Source selection
8-
# Available options: mongodb, socket
9-
POWERAPI_SOURCE=mongodb
10-
11-
# Destination selection
12-
# Available options: influxdb2, prometheus, mongodb, csv
13-
POWERAPI_DESTINATION=csv
14-
15-
# Third party images
16-
MONGO_IMAGE=mongo:latest
17-
MONGOEXPRESS_IMAGE=mongo-express:latest
18-
INFLUXDB_IMAGE=influxdb:latest
19-
CSV_IMAGE=busybox:stable-glibc
20-
21-
# Docker compose profiles
22-
COMPOSE_PROFILES=${POWERAPI_SOURCE},${POWERAPI_DESTINATION}

Diff for: docs/script/getting_started/docker-compose.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ services:
4242

4343
# PowerAPI Formula
4444
formula:
45-
user: $UID:$GUID
45+
user: ${UID}:${GUID}
4646
container_name: formula
4747
image: ${FORMULA_IMAGE}
4848
command:

Diff for: docs/script/getting_started/env_template

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Sensor image
2+
SENSOR_IMAGE=powerapi/hwpc-sensor:${HWPC_SENSOR_VERSION:-latest}
3+
4+
# Formula image
5+
FORMULA_IMAGE=powerapi/smartwatts-formula:${SMARTWATTS_VERSION:-latest}
6+
7+
# Source selection
8+
# Available options: mongodb, socket
9+
POWERAPI_SOURCE=mongodb
10+
11+
# Destination selection
12+
# Available options: influxdb2, prometheus, mongodb, csv
13+
POWERAPI_DESTINATION=csv
14+
15+
# Third party images
16+
MONGO_IMAGE=mongo:latest
17+
MONGOEXPRESS_IMAGE=mongo-express:latest
18+
INFLUXDB_IMAGE=influxdb:latest
19+
CSV_IMAGE=busybox:stable-glibc
20+
21+
# Docker compose profiles
22+
COMPOSE_PROFILES=${POWERAPI_SOURCE},${POWERAPI_DESTINATION}
23+

Diff for: docs/script/getting_started/start.py

+13-3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import subprocess
3737
import json
3838

39+
3940
# List of available processor architectures Template: "n - Arch name"
4041
# If an arch is added, the case statement in the
4142
# start_demo function should be updated accordingly with the proper core events
@@ -54,8 +55,14 @@ def signal_handler(sig, frame):
5455
def docker_start(time):
5556
id1 = os.popen("id -u").read()
5657
id2 = os.popen("id -g").read()
57-
print("UID=" + id1[:-1] + " GUID=" + id2[:-1] + " docker compose up -d")
58-
os.system("UID=" + id1[:-1] + " GUID=" + id2[:-1] + " docker compose up -d")
58+
with open('env_template', 'r') as firstfile, open('.env', 'a') as secondfile:
59+
for line in firstfile:
60+
secondfile.write(line)
61+
secondfile.write("UID=" + id1)
62+
secondfile.write("GUID=" + id2)
63+
64+
print("docker compose up -d")
65+
os.system("docker compose up -d")
5966
os.system("docker compose logs sensor -f &")
6067
os.system("docker compose logs formula -f &")
6168
os.system("sleep " + str(time))
@@ -66,6 +73,7 @@ def docker_stop():
6673
os.system("set -ueo pipefail")
6774
os.system("set +x")
6875
os.system("docker compose down")
76+
open('.env', 'w').close()
6977

7078

7179
def load_data():
@@ -154,6 +162,7 @@ def start_pretty_print():
154162

155163
print("\nFor more precise evaluation, consult the PowerAPI documentation to adjust configurations.\n")
156164

165+
157166
def find_cpu(data):
158167
"""
159168
Find the cpu in the list of compatible cpu
@@ -312,10 +321,11 @@ def start_demo():
312321
"processor architecture\n")
313322
else:
314323
print("\nThe demo has ended, "
315-
"you can see the result under the /csv directory"
324+
"you can see the result under the /csv directory, but"
316325
" here is a quick summary\n")
317326

318327
start_pretty_print()
319328

329+
320330
if __name__ == '__main__':
321331
start_demo()

0 commit comments

Comments
 (0)