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

Threaded telemetry #436

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
cb64a78
Move telemetry code to own subpackage
AdrianSosic Nov 22, 2024
cc1a6e2
Use existing is_enable utility
AdrianSosic Nov 22, 2024
e2cf05f
Remove dead code
AdrianSosic Nov 22, 2024
d62b087
Split code into public and private parts
AdrianSosic Nov 22, 2024
9a1af1d
Add class for lazy loading of telemetry objects
AdrianSosic Nov 26, 2024
0771897
Move constants to top level
AdrianSosic Nov 26, 2024
417e0e4
Add transmission queue
AdrianSosic Nov 26, 2024
7b3b0a7
Extract connection test into function
AdrianSosic Nov 26, 2024
895dd2c
Transmit telemetry events from daeman thread
AdrianSosic Nov 26, 2024
d7d30af
Start the daemon only when connection test is successful
AdrianSosic Nov 26, 2024
f5c3cad
Run connection test from daemon thread
AdrianSosic Nov 27, 2024
e4f3512
Suppress mypy warning for lazy attribute
AdrianSosic Nov 27, 2024
671832d
Drop unused constants
AdrianSosic Nov 27, 2024
2440d73
Polish docstrings
AdrianSosic Nov 27, 2024
4e4fdb9
Close queue immediately when telemetry is deactivated
AdrianSosic Nov 27, 2024
8a5e1ef
Print telemetry warning only for developers
AdrianSosic Nov 27, 2024
201b52c
Update CHANGELOG.md
AdrianSosic Nov 27, 2024
f1721bf
Merge remote-tracking branch 'origin/main' into feature/threaded_tele…
AdrianSosic Feb 19, 2025
7917af8
Rename TELEM_LABELS to TELEMETRY_LABELS for consistency
AdrianSosic Feb 19, 2025
2186ecf
Break infinite recursion
AdrianSosic Feb 19, 2025
19520e4
Avoid the term daemon since we use a regular background thread
AdrianSosic Feb 19, 2025
fbfe21d
Update telemetry test script
Scienfitz Feb 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Turning your comment into a thread:

TBH, it's hard for me to exactly explain the problem. All I can say: I can't reproduce it at home, but I regularly encounter the problem on the train, probably during the moments where the mobile connection is slow / lost. So my mac still "sees" a connection, but can't reach then endpoint. And the process is always the same:

  • I'm working on the code
  • Suddenly, stuff does not execute anymore
  • I think I broke something and start debugging
  • A few mins later, I realize: connection problems.
  • I simply disable WIFI and execution works again.

So the problem is not telemetry itself but some of our code parts that are blocking. I can try to reproduce and figure out next time I'm on the train and run into the problem.

But regardless of whether we keep the threading approach or not, we can still leverage some of the improvements of this PR, i.e. deletion of dead code, lazy telemetry loading, cleanup into small functions, ...

Copy link
Collaborator

Choose a reason for hiding this comment

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

not being able to reproduce and not knowing the exact source of the issue, were you already able to verify the new solution fixes your issue?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Well, I think it cannot "not" fix the issue since there is no nothing left that could be blocking. At least in principle, the entire execution of the original telemetry.py was in the main thread, so whatever happened there would block the further execution of the baybe code (not talking about the actual telemetry calls but the pure import of the module). This is now all gone.

But we can delay the discussion until I have more evidence, if you prefer

Copy link
Collaborator

Choose a reason for hiding this comment

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

I really dont like this approach coding auf sicht

if you know the issue we can merge without test, based on clearly seeing the cause being fixed in the code

if we dont know the code its not even clear any of the code in this PR addresses anything relevant

Copy link
Collaborator

Choose a reason for hiding this comment

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

Imo, this should be discussed in our meeting instead of here.

Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `CustomDiscreteParameter` does not allow duplicated rows in `data` anymore
- De-/activating Polars via `BAYBE_DEACTIVATE_POLARS` now requires passing values
compatible with `strtobool`
- Telemetry now runs in a daemon thread

### Fixed
- Rare bug arising from degenerate `SubstanceParameter.comp_df` rows that caused
Expand Down
262 changes: 0 additions & 262 deletions baybe/telemetry.py

This file was deleted.

22 changes: 22 additions & 0 deletions baybe/telemetry/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""Telemetry functionality for BayBE.

For more details, see https://emdgroup.github.io/baybe/stable/userguide/envvars.html#telemetry
"""

from baybe.telemetry.api import (
TELEM_LABELS,
VARNAME_TELEMETRY_ENABLED,
VARNAME_TELEMETRY_HOSTNAME,
VARNAME_TELEMETRY_USERNAME,
telemetry_record_recommended_measurement_percentage,
telemetry_record_value,
)

__all__ = [
"TELEM_LABELS",
"VARNAME_TELEMETRY_ENABLED",
"VARNAME_TELEMETRY_HOSTNAME",
"VARNAME_TELEMETRY_USERNAME",
"telemetry_record_recommended_measurement_percentage",
"telemetry_record_value",
]
Loading
Loading