Skip to content

Writer Factory

get_writer(writer_type, **auth)

Factory function to get the appropriate writer based on the type.

Parameters:

Name Type Description Default
writer_type str

The type of writer to create. Supported values are "local" and "azure".

required
**auth

Additional authentication parameters for the writer, if needed.

{}

Returns:

Name Type Description
Writer LocalWriter | AzureBlobWriter

An instance of the specified writer type.

Raises:

Type Description
ValueError

If the specified writer type is not supported.

Source code in WriterFactory.py
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
def get_writer(writer_type: str, **auth) -> LocalWriter | AzureBlobWriter:
    """Factory function to get the appropriate writer based on the type.

    Args:
        writer_type (str): The type of writer to create. Supported values are "local" and "azure".
        **auth: Additional authentication parameters for the writer, if needed.

    Returns:
        Writer: An instance of the specified writer type.

    Raises:
        ValueError: If the specified writer type is not supported.
    """
    if writer_type == "local":
        return LocalWriter()
    elif writer_type == "azure":
        # return AzureBlobWriter(auth.get("connection_string"))
        return ModuleNotFoundError("AzureBlobWriter is not implemented yet.")
    else:
        raise ValueError(f"Unknown writer type: {writer_type}")