earth2studio.models.auto.Package#

class earth2studio.models.auto.Package(root, fs=None, cache=True, cache_options={})[source]#

A generic file system abstraction with local caching, uses Fsspec WholeFileCacheFileSystem to manage files. Designed to be used for accessing remote resources, particularly checkpoint files for pre-trained models. Presently supports public folders on NGC, huggingface repos, s3 and any other built in file system Fsspec supports.

Parameters:
  • root (str) – Root directory for file system

  • fs (AbstractFileSystem | None, optional) – The target filesystem to run underneath. If none is provided a fsspec filesystem will get initialized based on the protocal of the root url, by default None

  • cache (bool, optional) – Toggle local caching, typically you want this to be true unless the package is a local file system, by default True

  • cache_options (dict, optional) – Caching options provided to Fsspec. See CachingFileSystem in fsspec for valid options https://filesystem-spec.readthedocs.io/en/latest/api.html#fsspec.implementations.cached.CachingFileSystem, by default {}

property cache: str#

Cache path

classmethod default_blocksize()[source]#

Default remote store block size

Returns:

Download block size in bytes

Return type:

int

classmethod default_cache(path='')[source]#

Default cache location for packages located in ~/.cache/earth2studio

Parameters:

path (str, optional) – Sub-path in cache direction, by default “”

Returns:

Local cache path

Return type:

str

classmethod default_timeout()[source]#

Default remote store timeout in seconds

Returns:

Time out in seconds

Return type:

int

get(file_path)[source]#

Modulus / backwards compatibility

Parameters:
  • path (str) – local path of file in package directory

  • file_path (str)

Returns:

File path inside cache

Return type:

str

open(file_path)[source]#

Open file inside package, caching it to local cache store in the process

Parameters:

file_path (str) – Local file path in package directory

Returns:

Opened file, can get file path with BufferedReader.name

Return type:

io.BufferedReader

resolve(file_path)[source]#

Resolves current relative file path to absolute path inside Package cache

Parameters:
  • path (str) – local path of file in package directory

  • file_path (str)

Returns:

File path inside cache

Return type:

str