Skip to content

Conversation

ArneTR
Copy link
Member

@ArneTR ArneTR commented Sep 12, 2025

This PR introduces the concept of having playwright commands directly in the usage scenario.

This was made based on an idea of @davidkopp

To make the commands work we need IPC between playwright and GMT.

To make this low overhead we use native I/O blocking from the linux subsystem by creating two files:

  • /tmp/playwright-ipc-ready
    • This is used to signal to GMT that playwright is ready for the next command
  • /tmp/playwright-ipc-commands
    • This is used for playwright to ingest the command

The functionality is kept hidden from the user only exposing a simple string based YML syntax.

Example can be seen here:
https://github.com/green-coding-solutions/branch-magazine-energy-tests/blob/2741f206385a5280bb275da1b5bf2db46f148185/usage_scenario_normal.yml#L66

@davidkopp How do you like this interface?

Copy link

Eco CI Output [RUN-ID: 17671748212]:

🌳 CO2 Data:
City: Boydton, Lat: 36.6694, Lon: -78.3877
IP: 172.200.183.242
CO₂ from energy is: 1.445271660 g
CO₂ from manufacturing (embodied carbon) is: 0.271039558 g
Carbon Intensity for this location: 378 gCO₂eq/kWh
SCI: 1.716311 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.40043823.474.02949.97
Total Run25.403823.474.02949.97
Additional overhead from Eco CIN/A11.224.112.73

@davidkopp
Copy link
Collaborator

davidkopp commented Sep 13, 2025

I like the playwright command type!

Two questions...

Playwright API variant

The interface currently only supports the asynchronous API of Playwright, due to :

await eval(`(async () => { ${data} })()`);

Is it sufficient to only support the asynchronous API of Playwright? If so, you might implement a check if the playwright command is missing the await keyword and through an error if it is missing.
If both, the synchronous and asynchronous API of Playwright should be supported, the interface needs a modification.

Notes collection

How to use read-notes-stdout: true in conjunction with the playwright command type? Or would you consider this not relevant, as the flow names are already visible in the graphs?
If read-notes-stdout: true should be supported with the playwright command type, I think there needs to be some modification because of the asynchronous execution (I have not tested it).

btw: The synchronous function logNote(message) is currently unused in playwright-ipc.js. Should it be made async so it can be used with the current asynchronous interface?

@davidkopp
Copy link
Collaborator

Regarding the Playwright API variant: The node.js implementation of Playwright only supports the asynchronous variant (the Python implementation supports both). So the question is not relevant anymore. But probably it needs to be documented, that the Node.js implementation is used under the hood and await is necessary for all Playwright commands. And maybe a check if the keyword is missing could still make sense.

@ArneTR
Copy link
Member Author

ArneTR commented Sep 13, 2025

Good input!

  • In async loops sync functions can still be executed. Executing logNote should not be an issue. The function is there for general compatibility in other projects
  • Jap, it needs documentation :)

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