Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add missing operator_cache decorator #80

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions docs/configurations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ Using the Settings module
Configurable Parameters
--------------------------

1. enable_message_cache:
* Description: Enables or Disables cahcing mechanisms
1. enable_cache:
* Description: Enables or Disables caching mechanisms
* Default: False
* Parameters:
- cache_type: Type of caching (SQLITE or In_MEMORY)
Expand All @@ -31,6 +31,12 @@ Configurable Parameters
* Note: It is recommended to enable caching
.. code-block:: python

import pandas as pd

import lotus
from lotus.models import LM
from lotus.cache import CacheFactory, CacheConfig, CacheType

cache_config = CacheConfig(cache_type=CacheType.SQLITE, max_size=1000)
cache = CacheFactory.create_cache(cache_config)

Expand Down
2 changes: 2 additions & 0 deletions lotus/sem_ops/sem_dedup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import pandas as pd

import lotus
from lotus.cache import operator_cache


@pd.api.extensions.register_dataframe_accessor("sem_dedup")
Expand All @@ -19,6 +20,7 @@ def _validate(obj: Any) -> None:
if not isinstance(obj, pd.DataFrame):
raise AttributeError("Must be a DataFrame")

@operator_cache
def __call__(
self,
col_name: str,
Expand Down
2 changes: 2 additions & 0 deletions lotus/sem_ops/sem_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pandas as pd

import lotus
from lotus.cache import operator_cache


@pd.api.extensions.register_dataframe_accessor("sem_index")
Expand All @@ -19,6 +20,7 @@ def _validate(obj: Any) -> None:
if not isinstance(obj, pd.DataFrame):
raise AttributeError("Must be a DataFrame")

@operator_cache
def __call__(self, col_name: str, index_dir: str) -> pd.DataFrame:
"""
Index a column in the DataFrame.
Expand Down
3 changes: 3 additions & 0 deletions lotus/sem_ops/sem_partition_by.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import pandas as pd

from lotus.cache import operator_cache


@pd.api.extensions.register_dataframe_accessor("sem_partition_by")
class SemPartitionByDataframe:
Expand All @@ -16,6 +18,7 @@ def _validate(obj: Any) -> None:
if not isinstance(obj, pd.DataFrame):
raise AttributeError("Must be a DataFrame")

@operator_cache
def __call__(
self,
partition_fn: Callable[[pd.DataFrame], list[int]],
Expand Down
Loading