From 18639c7b5fa26899c7a9beee02de860e1d528709 Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Wed, 5 Nov 2025 14:24:46 -0500 Subject: [PATCH] Change FileStream to use absolute paths Currently, accessing a grib file first by a relative path then by an absolute path causes cfgrib to reject the index, as would acessing the file by a relative path from a different working directory. This change ensures the path stored in the index file is absolute, so the index file validator will find a match regardless of whether the file is accessed by a relative path or an absolute path. --- cfgrib/messages.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cfgrib/messages.py b/cfgrib/messages.py index 17a4e752..b68d991a 100644 --- a/cfgrib/messages.py +++ b/cfgrib/messages.py @@ -322,7 +322,9 @@ class FileStream(abc.MappingFieldset[OffsetType, Message]): 14760.0 """ - path: str + path: str = attr.field( + converter=os.path.abspath, eq=os.path.abspath, on_setattr=os.path.abspath + ) errors: str = attr.attrib( default="warn", validator=attr.validators.in_(["ignore", "warn", "raise"]) )