From a4561ca319b59b1e3ccdf07fe9f13753f9f557c6 Mon Sep 17 00:00:00 2001 From: Yogaditya Date: Tue, 3 Mar 2026 19:53:38 +0530 Subject: [PATCH 1/6] fix: handle race condition in daily warning write --- arviz/__init__.py | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/arviz/__init__.py b/arviz/__init__.py index f0d572d612..8b2772a513 100644 --- a/arviz/__init__.py +++ b/arviz/__init__.py @@ -47,15 +47,25 @@ 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") + with open(lock_file, "x") as f: + f.write("1") + + # 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() From 922d0d0819746c726f1c9cdcca990affa50affa9 Mon Sep 17 00:00:00 2001 From: Yogaditya Date: Tue, 3 Mar 2026 21:44:50 +0530 Subject: [PATCH 2/6] fix: revert version and fix import order --- arviz/utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arviz/utils.py b/arviz/utils.py index 9182fe25fc..434d8231f2 100644 --- a/arviz/utils.py +++ b/arviz/utils.py @@ -1,11 +1,13 @@ # pylint: disable=too-many-nested-blocks """General utilities.""" +import datetime import functools import importlib import importlib.resources import re import warnings from functools import lru_cache +from pathlib import Path # Added this for Path() import matplotlib.pyplot as plt import numpy as np From 7efe039d658d61ca299645d653ee3e93371d13cf Mon Sep 17 00:00:00 2001 From: Yogaditya Date: Tue, 3 Mar 2026 22:08:42 +0530 Subject: [PATCH 3/6] style: fix encoding and trailing whitespace in __init__ --- arviz/__init__.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/arviz/__init__.py b/arviz/__init__.py index 8b2772a513..c015e2ac71 100644 --- a/arviz/__init__.py +++ b/arviz/__init__.py @@ -1,6 +1,6 @@ # pylint: disable=wildcard-import,invalid-name,wrong-import-position """ArviZ is a library for exploratory analysis of Bayesian models.""" -__version__ = "0.23.4" +__version__ = "0.23.3" import logging import os @@ -50,9 +50,8 @@ def _atomic_write_text(path: Path, text: str) -> None: try: # Use a 'lock' file with today's date to ensure only one process warns lock_file = stamp_file.with_suffix(f".{today}.lock") - with open(lock_file, "x") as f: + with open(lock_file, "x", encoding="utf-8") as f: f.write("1") - # If we get here, this process is the "winner" warn( "\nArviZ is undergoing a major refactor to improve flexibility and extensibility " From 4862abc0e8822bd7d0b89b2d9296180bc4e9e3e2 Mon Sep 17 00:00:00 2001 From: Yogaditya Date: Tue, 3 Mar 2026 22:14:39 +0530 Subject: [PATCH 4/6] style: remove unused imports --- arviz/utils.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/arviz/utils.py b/arviz/utils.py index 434d8231f2..9182fe25fc 100644 --- a/arviz/utils.py +++ b/arviz/utils.py @@ -1,13 +1,11 @@ # pylint: disable=too-many-nested-blocks """General utilities.""" -import datetime import functools import importlib import importlib.resources import re import warnings from functools import lru_cache -from pathlib import Path # Added this for Path() import matplotlib.pyplot as plt import numpy as np From f959096a40e94ad967ac7e7dd8aab8e727a19307 Mon Sep 17 00:00:00 2001 From: Yogaditya Giduturi Date: Thu, 5 Mar 2026 02:16:21 +0530 Subject: [PATCH 5/6] Update arviz/__init__.py Co-authored-by: Oriol Abril-Pla --- arviz/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arviz/__init__.py b/arviz/__init__.py index c015e2ac71..1db2303ed3 100644 --- a/arviz/__init__.py +++ b/arviz/__init__.py @@ -50,8 +50,7 @@ def _atomic_write_text(path: Path, text: str) -> None: try: # Use a 'lock' file with today's date to ensure only one process warns lock_file = stamp_file.with_suffix(f".{today}.lock") - with open(lock_file, "x", encoding="utf-8") as f: - f.write("1") + 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 " From 81f6bcbdcff344a26ac108755ead672cdbd17bb1 Mon Sep 17 00:00:00 2001 From: Yogaditya Giduturi Date: Thu, 5 Mar 2026 02:19:05 +0530 Subject: [PATCH 6/6] chore: bump version to 0.23.4 --- arviz/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arviz/__init__.py b/arviz/__init__.py index 1db2303ed3..c197a79cc2 100644 --- a/arviz/__init__.py +++ b/arviz/__init__.py @@ -1,6 +1,6 @@ # pylint: disable=wildcard-import,invalid-name,wrong-import-position """ArviZ is a library for exploratory analysis of Bayesian models.""" -__version__ = "0.23.3" +__version__ = "0.23.4" import logging import os