Skip to content

factory

Top-level functions for artifact store creation.

create_artifact_store(parsed_uri)

Create a MLTE artifact store instance.

Parameters:

Name Type Description Default
parsed_uri StoreURI

The URI for the store instance

required

Returns:

Type Description
ArtifactStore

The store instance

Source code in mlte/store/artifact/factory.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
def create_artifact_store(parsed_uri: StoreURI) -> ArtifactStore:
    """
    Create a MLTE artifact store instance.
    :param parsed_uri: The URI for the store instance
    :return: The store instance
    """
    if parsed_uri.type == StoreType.LOCAL_MEMORY:
        return InMemoryStore(parsed_uri)
    if parsed_uri.type == StoreType.LOCAL_FILESYSTEM:
        return LocalFileSystemStore(parsed_uri)
    if parsed_uri.type == StoreType.REMOTE_HTTP:
        return HttpArtifactStore(uri=parsed_uri)
    if parsed_uri.type == StoreType.RELATIONAL_DB:
        # Import is here to avoid importing SQL libraries if they have not been installed.
        from mlte.store.artifact.underlying.rdbs.store import (
            RelationalDBArtifactStore,
        )

        return RelationalDBArtifactStore(parsed_uri)
    else:
        raise Exception(
            f"Artifact store can't be created, unknown or unsupported URI type received for uri {parsed_uri}"
        )