whylogs.api.store#

Submodules#

Package Contents#

Classes#

LocalStore

The LocalStore is the implementation of the base :class:ProfileStore

ProfileStore

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

DatasetIdQuery

DateQuery

SQLiteStore

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

class whylogs.api.store.LocalStore#

Bases: whylogs.api.store.profile_store.ProfileStore

The LocalStore is the implementation of the base :class:ProfileStore that will manage reading and writing profiles on the local file system.

In order to instantiate the object, you will need to define a dataset_id, which is related to the name of the model or dataset you’re profiling. To properly use the LocalStore to generate files, you should append it to your existing Rolling Logger, as the below example demonstrates.

```python import whylogs as why from whylogs.api.store.local import LocalStore

logger = why.logger(mode=”rolling”, interval=10, when=”S”, base_name=”my_model”) logger.append_store(store=LocalStore())

new_df = model.predict(input_data) logger.log(new_df) ```

The above piece of code will make sure to write the logged profiles to the correct location that can be further fetched using the same LocalStore, like so:

```python from datetime import datetime, timedelta

from whylogs.api.store.date_config import DateConfig

store = LocalStore() query = DateQuery(

dataset_id=”my_model”, start_date = datetime.now(timezone.utc) - timedelta(days=7), end_date = datetime.now(timezone.utc)

)

profile_view = store.get(query=query) ```

This will fetch all existing profiles from my_model from the past 7 days in a single merged DatasetProfileView.

To list existing profiles on your local ProfileStore, you can do:

`python store = LocalStore() store.list() `

>**NOTE**: The parameter dataset_id should always use the snake_case pattern, and it must also be unique to your existing dataset/ML model. If you use the same dataset_id to store different profiles, you will end up mixing those profiles and not being able to fetch and get them properly again.

list() List[str]#
Return type

List[str]

get(query: Union[whylogs.api.store.query.DateQuery, whylogs.api.store.query.DatasetIdQuery]) Optional[whylogs.core.DatasetProfileView]#
Parameters

query (Union[whylogs.api.store.query.DateQuery, whylogs.api.store.query.DatasetIdQuery]) –

Return type

Optional[whylogs.core.DatasetProfileView]

write(profile_view: whylogs.core.DatasetProfileView, dataset_id: str) None#
Parameters
Return type

None

class whylogs.api.store.ProfileStore#

Bases: abc.ABC

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

abstract list() List[str]#
Return type

List[str]

abstract get(query: whylogs.api.store.query.BaseQuery) whylogs.core.DatasetProfileView#
Parameters

query (whylogs.api.store.query.BaseQuery) –

Return type

whylogs.core.DatasetProfileView

abstract write(profile_view: whylogs.core.DatasetProfileView, dataset_id: str) None#
Parameters
Return type

None

class whylogs.api.store.DatasetIdQuery#
dataset_id: str#
segment_tag: Optional[str]#
class whylogs.api.store.DateQuery#
dataset_id: str#
start_date: datetime.datetime#
end_date: Optional[datetime.datetime]#
segment_tag: Optional[str]#
class whylogs.api.store.SQLiteStore#

Bases: whylogs.api.store.ProfileStore

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

list()#
get(query: whylogs.api.store.query.BaseQuery) whylogs.core.DatasetProfileView#
Parameters

query (whylogs.api.store.query.BaseQuery) –

Return type

whylogs.core.DatasetProfileView

write(profile_view: whylogs.core.DatasetProfileView, dataset_id: str)#
Parameters