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.FSReader

Override that closes the file too.

close()None[source]

Release any resources held open by this reader instance.

class uv.fs.reader.FSReader(fs: Union[fs.base.FS, str])[source]

Bases: uv.reader.base.AbstractReader, uv.reader.base.IterableReader

AbstractReader implementation backed by an instance of pyfilesystem2’s FS abstraction.

Parameters

fs – Either an fs URI string, or an actual fs.base.FS object.

close()None[source]

Release any resources held open by this reader instance.

keys() → Iterable[Any][source]

Returns all files in the filesystem that plausibly contains metrics in jsonl format.

read(k: str) → List[Any][source]

Returns a list of all metrics ever logged for the supplied t.MetricKey, or an empty list if the backing store has no record.

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.AbstractReporter

AbstractReporter 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.

close()None[source]

Release any resources held open by this reporter instance.

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: object

Class 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.

clear()None[source]
close()None[source]
open(path: str, mode: str)[source]
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.

uv.fs.util.persist_to_cas_via_memory(cfs, source_fs)[source]

Example call:

persist_to_cas_via_memory(

CASFS(“/Users/samritchie/casfs”), “/Users/samritchie/tester” # metrics directory

)

uv.fs.util.to_bytes(item: Union[str, bytes])bytes[source]

Accepts either a bytes instance or a string; if str, returns a bytes instance, else acts as identity.

Module contents