Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support reading notes from services #590

Merged

Conversation

davidkopp
Copy link
Contributor

If merged, resolves #589

@davidkopp
Copy link
Contributor Author

The current proposal removes the argument -t from the docker logs command. So no timestamps are added as prefixes to the logs. This is required so that the regex is able to find the notes.
An alternative approach would be to still add the timestamps but to change the regex:

def parse_note(self, line):
    if match := fullmatch(r'^(\d{16}) (.+)', line):
        return int(match[1]), match[2]
    return None

https://github.com/green-coding-berlin/green-metrics-tool/blob/main/lib/notes.py#L28

Copy link
Member

@ribalba ribalba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great PR again. Minor thing but otherwise looks great

runner.py Outdated Show resolved Hide resolved
@ArneTR
Copy link
Member

ArneTR commented Dec 18, 2023

I like the issue you raised in #589 and do agree that SCI should readable from any output stream that the GMT orchestrates.

The issue I see with this implementation is that it does not distinguish at which phase the SCI values occur. In order to do that the values must also be sent to the correct phase.

This is a limitation that I opted for when implementing it to have a proof of concept. See also https://docs.green-coding.berlin/docs/measuring/sci/

When we want to now broaden this the SCI must be per phase as if we just collect the output stream from the service it can also generate values in the boot phase already and we have no means of discerning that from the runtime phase.

I have this task still in the backlog but am happy, if you are willing to take this on, to provide some guidance on the possible implementation.
The way it is currently is that we just have a carry that will later be attributed to a fixed phase. The time component has to be integrated in this carry too and in an optimal case the SCI should be a separate reporter.
To do that we have to think if the output streams of the containers can be redirected to a separate memory stream that we can attach to.

Please let me know how you feel about this task, then I am happy to draft a more detailed specification that can be discussed and also changed.

@davidkopp
Copy link
Contributor Author

This PR is only about supporting the reading of notes from all services, so they are shown in the graphs in the UI. This PR does not change anything about the reading of the SCI score. The reading of the SCI score from the logs of services is already part of the current GMT version.

@ArneTR I think your request about the separation of the reading of the SCI score by phase should be handled with a different issue & PR.

@ArneTR
Copy link
Member

ArneTR commented Dec 20, 2023

I do get the approach for the display in the charts. But wouldn't you find it heavily confusing if the values would show up in the chart but then are not in any form accounted for in the calculations?

I would argue that this is very clear to you, but a confusing feature to bring into for other users. When I see a value in the notes of the chart and also a metric that is called SCI I would expect to have this somehow be correlated / reflected. What do you say?

Happy to discuss this further, because maybe I am misunderstanding the extent of the PR at the moment.

@davidkopp
Copy link
Contributor Author

The reason for me to create this PR was to be able to see when async operations are ending by looking at the notes in the charts. In some of my measurement runs the async operations were ending after the end of the runtime phase. To improve that, the display of the notes from the service in the charts would be quite helpful.

I understand that the calculation of the SCI metric can be quite confusing at the moment because of the fixed phase. However, I don't understand why you want to fix this in this PR. This PR doesn't change anything about the reading of the SCI ticks.

Reading of the SCI ticks is already part of GMT (https://github.com/green-coding-berlin/green-metrics-tool/blob/main/runner.py#L1147-L1150):

if container_info['read-sci-stdout']:
    for line in log.stdout.splitlines():
        if match := re.findall(r'GMT_SCI_R=(\d+)', line):
            self._sci['R'] += int(match[0])

@ArneTR
Copy link
Member

ArneTR commented Dec 20, 2023

Thanks for clarifying that. I had a hunch that I was misunderstanding something.

I get the call for the logging option for container logs in general especially when you cannot produce the logs through the async processes.

The problematic regarding the SCI got onto my radar because I saw that you touched these lines in the PR. Now looking more closely the issue that I was talking about is actually already present and I misremembered the implementation.

So this PR is fine and happy to take it in. Will open a separate issue for the SCI fixing.

@ArneTR
Copy link
Member

ArneTR commented Dec 20, 2023

The check for the Github pipeline is failing but I validated locally. Tests run fine.

ty david!

@ArneTR ArneTR merged commit e0809eb into green-coding-solutions:main Dec 20, 2023
1 check failed
@davidkopp davidkopp deleted the 589-read-notes-from-services branch December 20, 2023 13:59
ArneTR added a commit that referenced this pull request Dec 22, 2023
* main:
  Hotfix for check on frequency provider
  Tests run_until must be guard-claused with cleanup routine (#616)
  Fix check if stderr is empty (#613)
  Bump uvicorn[standard] from 0.24.0.post1 to 0.25.0 (#612)
  Fxing the network provider stderror
  Branch and filename are now always not null (#602)
  Adds a more elaborate depends_on test
  Support reading notes from services (#590)
  docker build command in tests now checks reason for docker build failure. If it is a permission issue with the cache, it will continue the rest of the workflow (#576)
  Use depends_on for container startup order (refactored) (#593)
  Bump psycopg[binary] from 3.1.15 to 3.1.16 (#610)
  Added powercap info to hardware_info (#609)
  Changed wording for network infrastructure box (#608)
  Added SIGQUIT to nginx and initi to gunicorn, as we are using bash script in entrypoint (#605)
  Fix frontend flow menu to wrap automatically (#584)
  Bump psutil from 5.9.6 to 5.9.7 (#603)
  Disable Docker CLI hints (#555)
  Create codeql.yml
ArneTR added a commit that referenced this pull request Dec 23, 2023
* main: (26 commits)
  Disable tinyproxy systemd service (#623)
  Text change
  Value formatting on status page
  Normalized URL for machines endpoint
  Less confusing error messages
  Status has now a waiting time (#599)
  Run ID is now accessible even after fail and thus can be sent via ema… (#601)
  Switched from cmd to command (#615)
  Hotfix for check on frequency provider
  Tests run_until must be guard-claused with cleanup routine (#616)
  Fix check if stderr is empty (#613)
  Bump uvicorn[standard] from 0.24.0.post1 to 0.25.0 (#612)
  Fxing the network provider stderror
  Branch and filename are now always not null (#602)
  Adds a more elaborate depends_on test
  Support reading notes from services (#590)
  docker build command in tests now checks reason for docker build failure. If it is a permission issue with the cache, it will continue the rest of the workflow (#576)
  Use depends_on for container startup order (refactored) (#593)
  Bump psycopg[binary] from 3.1.15 to 3.1.16 (#610)
  Added powercap info to hardware_info (#609)
  ...
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.

Support reading notes from services stdout
3 participants