Skip to content

factory

mlte/store/artifact/factory.py

Top-level functions for artifact store creation.

create_user_store(uri)

Create a MLTE user store instance.

Parameters:

Name Type Description Default
uri str

The URI for the store instance

required

Returns:

Type Description
UserStore

The store instance

Source code in mlte/store/user/factory.py
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
def create_user_store(uri: str) -> UserStore:
    """
    Create a MLTE user store instance.
    :param uri: The URI for the store instance
    :return: The store instance
    """
    parsed_uri = StoreURI.from_string(uri)
    if parsed_uri.type == StoreType.LOCAL_MEMORY:
        return InMemoryUserStore(parsed_uri)
    if parsed_uri.type == StoreType.RELATIONAL_DB:
        return RelationalDBUserStore(parsed_uri)
    if parsed_uri.type == StoreType.LOCAL_FILESYSTEM:
        return FileSystemUserStore(parsed_uri)
    else:
        raise Exception(
            f"Store can't be created, unknown or unsupported URI prefix received for uri {parsed_uri}"
        )