fairseq2.assets

        classDiagram
  ABC <|-- AssetDownloadManager
  ABC <|-- AssetMetadataProvider
  ABC <|-- AssetStore
  AbstractAssetMetadataProvider <|-- FileAssetMetadataProvider
  AbstractAssetMetadataProvider <|-- PackageAssetMetadataProvider
  AssetCardError <|-- AssetCardFieldNotFoundError
  AssetCardError <|-- AssetCardNotFoundError
  AssetDownloadManager <|-- InProcAssetDownloadManager
  AssetError <|-- AssetCardError
  AssetMetadataError <|-- AssetMetadataNotFoundError
  AssetMetadataProvider <|-- AbstractAssetMetadataProvider
  AssetMetadataProvider <|-- InProcAssetMetadataProvider
  AssetStore <|-- StandardAssetStore
  BaseException <|-- Exception
  Exception <|-- AssetDownloadError
  Exception <|-- AssetError
  Exception <|-- AssetMetadataError
  Generic <|-- Protocol
  Protocol <|-- EnvironmentResolver
    

Classes

class fairseq2.assets.AssetStore[source]

Bases: ABC

Represents a store of assets.

abstract retrieve_card(name, *, envs=None, scope='all')[source]

Retrieve the card of the specified asset.

Parameters:
  • name (str) – The name of the asset.

  • scope (Literal['all', 'global', 'user']) – The scope of retrieval.

Para env:

The environments, in order of precedence, in which to retrieve the card. If None, the available environments will be resolved automatically.

Return type:

AssetCard

abstract retrieve_names(*, scope='all')[source]

Retrieve the names of the assets contained in this store.

Parameters:

scope (Literal['all', 'global', 'user']) – The scope of retrieval.

Return type:

list[str]

class fairseq2.assets.AssetMetadataProvider[source]

Bases: ABC

Provides asset metadata.

abstract get_metadata(name)[source]

Return the metadata of the specified asset.

Parameters:

name (str) – The name of the asset.

Return type:

dict[str, object]

abstract get_names()[source]

Return the names of the assets for which this provider has metadata.

Return type:

list[str]

abstract clear_cache()[source]

Clear any cached asset metadata.

final class fairseq2.assets.AssetCard(name, metadata, base_card=None, base_path=None)[source]

Bases: object

Holds information about an asset.

Parameters:
  • metadata (MutableMapping[str, object]) – The metadata to be held in the card. Each key-value item should contain a specific piece of information about the asset.

  • base – The card that this card derives from.

field(name)[source]

Return a field of this card.

If the card does not contain the specified field, its base cards will be checked recursively.

Parameters:

name (str) – The name of the field.

Return type:

AssetCardField

flatten()[source]

Flattens the metadata of this card and all its bases into a single one.

Return type:

AssetCard

property name: str

The name of the asset.

property metadata: Mapping[str, object]

The metadata of the asset.

property base: AssetCard | None

The card that this card derives from.