Skip to content

Conversation

ribalba
Copy link
Member

@ribalba ribalba commented Sep 2, 2025

When I run the setup env python file and don't have access to my fingerprint reader I can't press CTRL-C to drop to the password entry prompt as the python process gets the interrupt. So I catch it and fail nicely.

$ python3 setup-test-env.py 
Copying SQL structure...
Creating test-config.yml...
Creating frontend test-config.js file...
Creating test-compose.yml...
Writing to /etc/hosts file...
Place your right index finger on the fingerprint reader

^C[sudo] password for didi: Traceback (most recent call last):
  File "/home/didi/code/green-metrics-tool/tests/setup-test-env.py", line 205, in <module>
    edit_etc_hosts()
    ~~~~~~~~~~~~~~^^
  File "/home/didi/code/green-metrics-tool/tests/setup-test-env.py", line 182, in edit_etc_hosts
    subprocess.run(['./edit-etc-hosts.sh'], check=True)
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.13/subprocess.py", line 556, in run
    stdout, stderr = process.communicate(input, timeout=timeout)
                     ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.13/subprocess.py", line 1214, in communicate
    self.wait()
    ~~~~~~~~~^^
  File "/usr/lib64/python3.13/subprocess.py", line 1280, in wait
    return self._wait(timeout=timeout)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.13/subprocess.py", line 2066, in _wait
    (pid, sts) = self._try_wait(0)
                 ~~~~~~~~~~~~~~^^^
  File "/usr/lib64/python3.13/subprocess.py", line 2024, in _try_wait
    (pid, sts) = os.waitpid(self.pid, wait_flags)
                 ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
KeyboardInterrupt

@ribalba ribalba requested a review from ArneTR September 2, 2025 11:19
@ArneTR
Copy link
Member

ArneTR commented Sep 2, 2025

Hmm, not directly a fan of this edit.

The problem is that the location when the first sudo hits is arbitrary. We can easily layer another instance before that and it will fail.

How about making a dummy sudo call as REALLY the first step of the script. Something like "sudo echo 'ok'". ?

@ribalba
Copy link
Member Author

ribalba commented Sep 2, 2025

Did a more robust version now. Also fixed a few things that stopped testing on Fedora

Copy link

github-actions bot commented Sep 2, 2025

Eco CI Output - Old Energy Estimation

Eco CI Output [RUN-ID: 17403646223]:

🌳 CO2 Data:
City: , Lat: , Lon:
IP:
CO₂ from energy is: 0.688422430 g
CO₂ from manufacturing (embodied carbon) is: 0.292363912 g
Carbon Intensity for this location: 167 gCO₂eq/kWh
SCI: 0.980786 gCO₂eq / pipeline run emitted


Total cost of whole PR so far:

Label🖥 avg. CPU utilization [%]🔋 Total Energy [Joules]🔌 avg. Power [Watts]Duration [Seconds]
Measurement #125.14774122.294.021024.71
Total Run25.154122.294.021024.71
Additional overhead from Eco CIN/A11.284.122.74

Copy link

github-actions bot commented Sep 2, 2025

Eco CI Output - Old Energy Estimation

Eco CI Output [RUN-ID: 17403680993]:

🌳 CO2 Data:
City: , Lat: , Lon:
IP:
CO₂ from energy is: 0.664665010 g
CO₂ from manufacturing (embodied carbon) is: 0.283242430 g
Carbon Intensity for this location: 167 gCO₂eq/kWh
SCI: 0.947907 gCO₂eq / pipeline run emitted


Total cost of whole PR so far:

Label🖥 avg. CPU utilization [%]🔋 Total Energy [Joules]🔌 avg. Power [Watts]Duration [Seconds]
Measurement #125.11783980.034.01992.74
Total Run25.123980.034.01992.74
Additional overhead from Eco CIN/A10.454.022.60

Copy link

github-actions bot commented Sep 2, 2025

Eco CI Output - Old Energy Estimation

Eco CI Output [RUN-ID: 17403700046]:

🌳 CO2 Data:
City: , Lat: , Lon:
IP:
CO₂ from energy is: 2.218305000 g
CO₂ from manufacturing (embodied carbon) is: 0.330245027 g
Carbon Intensity for this location: 500 gCO₂eq/kWh
SCI: 2.548550 gCO₂eq / pipeline run emitted


Total cost of whole PR so far:

Label🖥 avg. CPU utilization [%]🔋 Total Energy [Joules]🔌 avg. Power [Watts]Duration [Seconds]
Measurement #122.55944436.613.831157.48
Total Run22.564436.613.831157.48
Additional overhead from Eco CIN/A13.734.223.25

Copy link

github-actions bot commented Sep 2, 2025

Eco CI Output [RUN-ID: 17403736538]:

🌳 CO2 Data:
City: , Lat: , Lon:
IP:
CO₂ from energy is: 1.484147280 g
CO₂ from manufacturing (embodied carbon) is: 0.310372920 g
Carbon Intensity for this location: 343 gCO₂eq/kWh
SCI: 1.794520 gCO₂eq / pipeline run emitted


Total cost of whole PR so far:

Label🖥 avg. CPU utilization [%]🔋 Total Energy [Joules]🔌 avg. Power [Watts]Duration [Seconds]
Measurement #124.12714326.963.981087.83
Total Run24.134326.963.981087.83
Additional overhead from Eco CIN/A12.514.163.01

@ArneTR
Copy link
Member

ArneTR commented Sep 3, 2025

Looks cleaner now.

For my understanding: This error techically also happens when you install GMT, not?

If so: I think it makes sense to also bring this code to the install_shared.sh ... what do you think?

@ArneTR
Copy link
Member

ArneTR commented Sep 6, 2025

@ribalba Ping

@ribalba
Copy link
Member Author

ribalba commented Sep 16, 2025

No, because the install is a shell script which understands the CTRL-C. But when calling a shell script from python the python process gets the signal.

@ArneTR ArneTR merged commit a95f012 into main Sep 16, 2025
2 checks passed
@ArneTR ArneTR deleted the fixes-sudo-promt branch September 16, 2025 16:52
ArneTR added a commit that referenced this pull request Sep 19, 2025
* main: (66 commits)
  Remove network from sci (#1352)
  Updated Cloud Energy
  Relaxed test due to noise of host OS network management. See #1322 for details
  tcpdump will report errors for now instead of except
  Remaned wait_time to proper name idle_time
  Bump psutil from 7.0.0 to 7.1.0 (#1349)
  Refactor logs structure to json (#1341)
  Removed proxy passing into docker gunicorn container
  Changed jobs endpoint to deliver http 202
  (fix): After moving to /lib folder the __main__ check was not relevant anymore. Checking for tty now which should not conflict when running in cluster mode
  fixes the problem with updates not being installed (#1346)
  Bump fastapi[standard] from 0.116.1 to 0.116.2 (#1342)
  Saves the existing config files on install (#1311)
  Fixes sudo bug when creating test env (#1310)
  Bump pydantic from 2.11.7 to 2.11.9 (#1340)
  Bump pytest-randomly from 4.0.0 to 4.0.1 (#1339)
  Bump actions/github-script from 7.0.1 to 8.0.0 in /.github/workflows (#1338)
  Bump actions/create-github-app-token in /.github/workflows (#1337)
  Added powermetrics carbon entries for config.js
  Added more key metrics to frontend display tests
  ...
ArneTR added a commit that referenced this pull request Sep 19, 2025
* main: (84 commits)
  Allow to stream stdout connected output (#1353)
  Catching exception in tcpdump
  Showing test duration
  Remove network from sci (#1352)
  Updated Cloud Energy
  Relaxed test due to noise of host OS network management. See #1322 for details
  tcpdump will report errors for now instead of except
  Remaned wait_time to proper name idle_time
  Bump psutil from 7.0.0 to 7.1.0 (#1349)
  Refactor logs structure to json (#1341)
  Removed proxy passing into docker gunicorn container
  Changed jobs endpoint to deliver http 202
  (fix): After moving to /lib folder the __main__ check was not relevant anymore. Checking for tty now which should not conflict when running in cluster mode
  fixes the problem with updates not being installed (#1346)
  Bump fastapi[standard] from 0.116.1 to 0.116.2 (#1342)
  Saves the existing config files on install (#1311)
  Fixes sudo bug when creating test env (#1310)
  Bump pydantic from 2.11.7 to 2.11.9 (#1340)
  Bump pytest-randomly from 4.0.0 to 4.0.1 (#1339)
  Bump actions/github-script from 7.0.1 to 8.0.0 in /.github/workflows (#1338)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants