Skip to content

Commit

Permalink
add missing operator_cache decorator (#80)
Browse files Browse the repository at this point in the history
mssing decorator and doc updates
  • Loading branch information
StanChan03 authored Jan 14, 2025
1 parent 4d4ca82 commit 17b8d63
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
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

0 comments on commit 17b8d63

Please sign in to comment.