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

More-threadsafe construction of metric functions. #486

Merged
merged 0 commits into from
Mar 8, 2023

Conversation

copybara-service[bot]
Copy link

More-threadsafe construction of metric functions.

Before, if multiple threads were accessing metric functions while they were uninitialized, there was a race condition, leading to instantiation multiple different times, possibly causing different metric functions to be stored inside e.g. score_metric_fns and predict_metric_fns that came from different instantiations.

Now, all of these are bottlenecked through a single cached_property, which is a cleaner design regardless of concurrency concerns.

functools.cached_property is not threadsafe[1], but this way, it shouldn't matter to us.

[1] https://discuss.python.org/t/finding-a-path-forward-for-functools-cached-property/23757

@copybara-service copybara-service bot force-pushed the test_514858048 branch 5 times, most recently from e290501 to 63ab80f Compare March 8, 2023 14:29
@copybara-service copybara-service bot closed this Mar 8, 2023
@copybara-service copybara-service bot merged commit ce28ad7 into main Mar 8, 2023
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.

0 participants