Skip to content

Commit c39c8d1

Browse files
authored
feat(fsspec): FsspecStore.modified() (#517)
* FsspecStore.modified() * import: datetime --> TYPE_CHECKING * ruff formatting
1 parent 4271b4f commit c39c8d1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

obstore/python/obstore/fsspec.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
if TYPE_CHECKING:
5151
import sys
5252
from collections.abc import Coroutine, Iterable
53+
from datetime import datetime
5354
from typing import Any
5455

5556
from obstore import Attributes, Bytes, ReadableFile, WritableFile
@@ -591,6 +592,13 @@ def _open(
591592

592593
return BufferedFile(self, path, mode, **kwargs)
593594

595+
def modified(self, path: str) -> datetime:
596+
"""Return the modified timestamp of a file as a `datetime.datetime`."""
597+
bucket, path_no_bucket = self._split_path(path)
598+
store = self._construct_store(bucket)
599+
head = obs.head(store, path_no_bucket)
600+
return head["last_modified"]
601+
594602

595603
class BufferedFile(fsspec.spec.AbstractBufferedFile):
596604
"""A buffered readable or writable file.

0 commit comments

Comments
 (0)