Skip to content

Commit

Permalink
Less cahching warnings and closes #111
Browse files Browse the repository at this point in the history
  • Loading branch information
AKuederle committed Jun 14, 2024
1 parent a6b4127 commit 21ef6cc
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) (+ the Migration Guide),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.33.1] - 2024-06-14

- Only warning about global caching once.

## [0.33.0] - 2024-05-23

### Added
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "tpcp"
version = "0.33.0"
version = "0.33.1"
description = "Pipeline and Dataset helpers for complex algorithm evaluation."
authors = [
"Arne Küderle <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion tpcp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
)
from tpcp._pipeline import OptimizablePipeline, Pipeline

__version__ = "0.33.0"
__version__ = "0.33.1"


__all__ = [
Expand Down
9 changes: 7 additions & 2 deletions tpcp/caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,21 @@
from tpcp import Algorithm, get_action_methods_names, get_results, make_action_safe
from tpcp._hash import custom_hash

_ALREADY_WARNED = False


def _global_cache_warning():
if multiprocessing.parent_process() is None:
global _ALREADY_WARNED # noqa: PLW0603

if multiprocessing.parent_process() is None and not _ALREADY_WARNED:
# We want to avoid spamming the user with warnings if they are running multiple processes
warnings.warn(
"Global caching is a little tricky to get right and our implementation is not yet battle-tested. "
"Please double check that the results are correct and report any issues you find.",
UserWarning,
stacklevel=2,
stacklevel=3,
)
_ALREADY_WARNED = True


_instance_level_disk_cache_key = "__tpcp_disk_cached_action_method"
Expand Down

0 comments on commit 21ef6cc

Please sign in to comment.