Source code for signal_dataset.storage.staging.contracts
"""The contract for making a stored shard openable by a native reader.The ArrayRecord binding takes a *path*, not a file object, and its compileddriver table registers exactly one remote scheme, ``gs://``. So a shard heldanywhere else has to become a path before a record can be read out of it.A staging area is that step. Which implementation serves a scheme decides thecost model: yielding the URI untouched costs nothing, while materializing theobject trades a download for the ability to read at all."""from__future__importannotationsfromabcimportABC,abstractmethodfromcontextlibimportAbstractContextManager
[docs]classShardStagingArea(ABC):"""Makes a stored shard openable by a path-only indexed reader."""
[docs]@abstractmethoddefstage(self,uri:str,*,generation:int|None=None)->AbstractContextManager[str]:"""Return a context manager yielding a path the reader may open. The path is valid only while the context is active. On exit, including on an exception, the implementation releases everything it acquired for this call. """