whylogs.api.writer.writer#

Module Contents#

Classes#

Writable

A Writable is an object that contains data to write to a file or files.

Writer

Helper class that provides a standard way to create an ABC using

WriterWrapper

Elide the Writable argument

Writers

class whylogs.api.writer.writer.Writable#

Bases: abc.ABC

A Writable is an object that contains data to write to a file or files. These might be temporary files intended to be passed on to another consumer (e.g., WhyLabs servers) via a Writer.

abstract write(path: Optional[str] = None, filename: Optional[str] = None, **kwargs: Any) Tuple[bool, Union[str, List[str]]]#

Writes the Writable’s data to file(s) under path (excluding filename(s)) if specified, else under _get_default_path(). filename specifies the file to write there. Writables can generate a default filename if None is specified. Returns a bool that’s True iff all files were written successfully and a list of the filenames (including path) written.

Parameters
  • path (Optional[str]) –

  • filename (Optional[str]) –

  • kwargs (Any) –

Return type

Tuple[bool, Union[str, List[str]]]

writer(name: str = 'local', **kwargs: Any) WriterWrapper#

Utility method to create a Writer of the specified type

Parameters
  • name (str) –

  • kwargs (Any) –

Return type

WriterWrapper

class whylogs.api.writer.writer.Writer#

Bases: abc.ABC

Helper class that provides a standard way to create an ABC using inheritance.

check_interval(interval_seconds: int) None#

Validate an interval configuration for a given writer.

Some writers only accepts certain interval configuration. Raise BadConfigError for an unacceptable interval.

Parameters

interval_seconds (int) –

Return type

None

abstract write(file: Writable, dest: Optional[str] = None, **kwargs: Any) Tuple[bool, Union[str, List[Tuple[bool, str]]]]#

Calls Writable::write() to serialize the Wriable file to temporary file(s), then “sends” the temporary file(s) to dest according to the type of Writer. If dest is None, it uses the Writer’s default destination.

kwargs:

zip: bool Create a ZipFile containing the Writable’s file(s) if the Writer supports it zip_name: str Name of the ZipFile, will be auto-generated if None

Parameters
  • file (Writable) –

  • dest (Optional[str]) –

  • kwargs (Any) –

Return type

Tuple[bool, Union[str, List[Tuple[bool, str]]]]

abstract option(**kwargs: Any) Writer#
Parameters

kwargs (Any) –

Return type

Writer

class whylogs.api.writer.writer.WriterWrapper(writable: Writable, writer: Writer)#

Elide the Writable argument

Parameters
check_interval(interval_seconds: int) None#
Parameters

interval_seconds (int) –

Return type

None

write(dest: Optional[str] = None, **kwargs: Any) Tuple[bool, Union[str, List[Tuple[bool, str]]]]#
Parameters
  • dest (Optional[str]) –

  • kwargs (Any) –

Return type

Tuple[bool, Union[str, List[Tuple[bool, str]]]]

option(**kwargs: Any) WriterWrapper#
Parameters

kwargs (Any) –

Return type

WriterWrapper

class whylogs.api.writer.writer.Writers#
static get(name: str, writable: Optional[Writable] = None, **kwargs) Union[Writer, WriterWrapper]#
Parameters
Return type

Union[Writer, WriterWrapper]