uv.fs package¶
Submodules¶
uv.fs.reader module¶
Reader implementation that relies on the PyFilesystem2 abstraction for filesystems. See https://github.com/PyFilesystem/pyfilesystem2 for more information on the library.
-
class
uv.fs.reader.CASReader(cas: casfs.base.CASFS, k: Union[str, casfs.util.HashAddress])[source]¶ Bases:
uv.fs.reader.FSReaderOverride that closes the file too.
-
class
uv.fs.reader.FSReader(fs: Union[fs.base.FS, str])[source]¶ Bases:
uv.reader.base.AbstractReader,uv.reader.base.IterableReaderAbstractReader implementation backed by an instance of pyfilesystem2’s FS abstraction.
- Parameters
fs – Either an fs URI string, or an actual fs.base.FS object.
uv.fs.reporter module¶
Reporter implementation that relies on the PyFilesystem2 abstraction for filesystems. See https://github.com/PyFilesystem/pyfilesystem2 for more information on the library.
-
class
uv.fs.reporter.FSReporter(fs: Union[fs.base.FS, str])[source]¶ Bases:
uv.reporter.base.AbstractReporterAbstractReporter implementation backed by an instance of pyfilesystem2’s FS abstraction. See https://docs.pyfilesystem.org/en/latest/ for more information.
FSReporter serializes each metric as JSON
TODO add a pluggable serializer, with a default jsonl implementation.
- Parameters
fs – Either an fs URI string, or an actual fs.base.FS object.
-
reader() → uv.reader.base.AbstractReader[source]¶ Returns an implementation of AbstractReader that can access the data in this store.
Returns None by default; extending classes are encouraged, but not required, to override.
-
report_all(step: int, m: Dict[str, Any]) → None[source]¶ Accepts a step (an ordered int referencing some timestep) and a dictionary of metric key => metric value, and persists the metric into some underlying store.
Extending classes are expected to perform some side effect that’s either visually useful, as in a live-plot, or recoverable via some matching extension of AbstractReader.
uv.fs.util module¶
Utilities shared by functions that interact with pyfilesystem2.
-
class
uv.fs.util.HandleCache(fs: fs.base.FS)[source]¶ Bases:
objectClass that opens file-handles and maintains an internal cache of those handles. On close, closes the supplied filesystem, closes all handles and clears the cache.
-
uv.fs.util.get_cas(cas_input)[source]¶ Version of the CASFS constructor that creates directories that don’t exist. TODO delete this once we get that idea merged back into CASFS.
-
uv.fs.util.jsonl_bytes(v: Any) → bytes[source]¶ Returns a bytes instance containing a single line of json with a newline appended.
-
uv.fs.util.jsonl_path(k: str) → str[source]¶ Returns an absolute path with an appropriate suffix for a jsonl file.
-
uv.fs.util.load_fs(root: Union[fs.base.FS, str]) → fs.base.FS[source]¶ If str is supplied, returns an instance of OSFS, backed by the local filesystem; else, returns the filesystem argument directly. Errors if supplied with an invalid argument.