Skip to content

Handler

handler

ArtifactMetadata

Bases: MutableDict[str, Any]

handler_ref = weakref.ref(handler) instance-attribute

handler: ArtifactHandler property

__init__(handler: ArtifactHandler) -> None

ArtifactHandlerType

Bases: ABCMeta

name: str property

__new__(*args, **kwargs)

ArtifactHandler

path: Path = Path(path) instance-attribute

metadata = ArtifactMetadata(self) instance-attribute

__init__(path: Union[str, Path]) -> None

Parameters:

Name Type Description Default
path str

The path to the artifact

required

load() -> Any abstractmethod

Load the artifact from the path.

Returns:

Type Description
Any

The loaded artifact.

save(obj: Any, *args, **kwargs) abstractmethod

Save the given artifact to the path.

Parameters:

Name Type Description Default
obj Any

The artifact to save.

required
args tuple

Additional positional arguments.

()
kwargs dict

Additional keyword arguments.

{}

Returns:

Type Description
None

can_handle(obj: object) -> bool abstractmethod classmethod

Return True if this handler can handle the given object type.

Parameters:

Name Type Description Default
obj object

The object to check.

required

Returns:

Type Description
bool

True if this handler can handle the given object type.

exists() -> bool

Return True if the artifact exists.

Returns:

Type Description
bool

True if the artifact exists.

Unlink/delete the artifact.

Returns:

Type Description
None

None

get_handler_type(name: str) -> Type[ArtifactHandler]

get_handler_type_by_object(obj: Any) -> Type[ArtifactHandler]

list_handler_types() -> List[str]