Skip to content

factory

mlte/store/catalog/factory.py

Top-level functions for catalog store creation.

create_catalog_store(uri, catalog_id=None)

Create a MLTE catalog store instance.

Parameters:

Name Type Description Default
uri str

The URI for the store instance

required
catalog_id Optional[str]

The id used to identify the catalog.

None

Returns:

Type Description
CatalogStore

The store instance

Source code in mlte/store/catalog/factory.py
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
def create_catalog_store(
    uri: str, catalog_id: Optional[str] = None
) -> CatalogStore:
    """
    Create a MLTE catalog store instance.
    :param uri: The URI for the store instance
    :param catalog_id: The id used to identify the catalog.
    :return: The store instance
    """
    parsed_uri = StoreURI.from_string(uri)
    if parsed_uri.type == StoreType.LOCAL_MEMORY:
        return InMemoryCatalogStore(uri=parsed_uri)
    if parsed_uri.type == StoreType.LOCAL_FILESYSTEM:
        return FileSystemCatalogStore(uri=parsed_uri, catalog_folder=catalog_id)
    if parsed_uri.type == StoreType.RELATIONAL_DB:
        return RelationalDBCatalogStore(uri=parsed_uri)
    if parsed_uri.type == StoreType.REMOTE_HTTP:
        return HttpCatalogGroupStore(uri=parsed_uri)

    raise Exception(f"Invalid store type: {uri}")