Skip to content
Open
Changes from all commits
Commits
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
26 changes: 17 additions & 9 deletions arviz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,23 @@ def _atomic_write_text(path: Path, text: str) -> None:
last_date = None

if last_date != today:
warn(
"\nArviZ is undergoing a major refactor to improve flexibility and extensibility "
"while maintaining a user-friendly interface."
"\nSome upcoming changes may be backward incompatible."
"\nFor details and migration guidance, visit: "
"https://python.arviz.org/en/latest/user_guide/migration_guide.html",
FutureWarning,
)
_atomic_write_text(stamp_file, today.isoformat())
try:
# Use a 'lock' file with today's date to ensure only one process warns
lock_file = stamp_file.with_suffix(f".{today}.lock")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am not sure accumulating these lockfiles over time is a very good idea. We don't want the warning to be too overbearing but if it shows multiple times when importing arviz in parallel it would be perfectly fine too. If it works it might be fine though, this is a backport fix on a frozen version so no need to overthink it too much

open(lock_file, "x", encoding="utf-8").close()
# If we get here, this process is the "winner"
warn(
"\nArviZ is undergoing a major refactor to improve flexibility and extensibility "
"while maintaining a user-friendly interface."
"\nSome upcoming changes may be backward incompatible."
"\nFor details and migration guidance, visit: "
"https://python.arviz.org/en/latest/user_guide/migration_guide.html",
FutureWarning,
)
_atomic_write_text(stamp_file, today.isoformat())
except FileExistsError:
# Another process already caught it and is warning/updating
pass


_warn_once_per_day()
Expand Down
Loading