whylogs.api.store.local_store
#
Module Contents#
Classes#
The LocalStore is the implementation of the base :class:ProfileStore |
Attributes#
- whylogs.api.store.local_store.DEFAULT_DIR = 'profile_store/'#
- whylogs.api.store.local_store.logger#
- class whylogs.api.store.local_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.
- 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
profile_view (whylogs.core.DatasetProfileView) –
dataset_id (str) –
- Return type