fairseq2.assets

        classDiagram
  ABC <|-- AssetDownloadManager
  ABC <|-- AssetMetadataFileLoader
  ABC <|-- AssetMetadataProvider
  ABC <|-- AssetStore
  ABC <|-- PackageFileLister
  AssetCardError <|-- AssetCardFieldNotFoundError
  AssetDownloadManager <|-- InProcAssetDownloadManager
  AssetMetadataFileLoader <|-- StandardAssetMetadataFileLoader
  AssetMetadataProvider <|-- CachedAssetMetadataProvider
  AssetStore <|-- StandardAssetStore
  BaseException <|-- Exception
  Enum <|-- AssetLookupScope
  Exception <|-- AssetCardError
  Exception <|-- AssetCardNotFoundError
  Exception <|-- AssetDownloadError
  Exception <|-- AssetMetadataLoadError
  Exception <|-- AssetMetadataNotFoundError
  Exception <|-- AssetMetadataSaveError
  Generic <|-- Protocol
  PackageFileLister <|-- WheelPackageFileLister
  Protocol <|-- EnvironmentResolver
    

Classes

class fairseq2.assets.AssetStore[source]

Bases: ABC

Represents a store of assets.

abstract retrieve_card(name, *, envs=None, scope=AssetLookupScope.ALL)[source]

Retrieve the card of the specified asset.

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

  • scope (AssetLookupScope) – 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=AssetLookupScope.ALL)[source]

Retrieve the names of the assets contained in this store.

Parameters:

scope (AssetLookupScope) – 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]

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

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.