Skip to content

Commit

Permalink
Add log_warning kwarg to tables interface (#294)
Browse files Browse the repository at this point in the history
* add log warning kwarg

* remove tables warning

* fix query_view

---------

Co-authored-by: Casey Schneider-Mizell <[email protected]>
  • Loading branch information
bdpedigo and ceesem authored Jan 23, 2025
1 parent 884309e commit b197551
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
23 changes: 14 additions & 9 deletions caveclient/tools/table_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,7 @@ def query(
metadata: bool = True,
desired_resolution: Optional[list] = None,
get_counts: bool = False,
log_warning: bool = True,
):
"""Set data return options for the specified query
Expand All @@ -687,6 +688,8 @@ def query(
A three element vector setting the return resolution of position information, by default None
get_counts : bool, optional
If True, only return the number of rows that match the query, by default False
log_warning : bool, optional
Whether to log warnings associated with tables
Returns
-------
Expand All @@ -706,12 +709,10 @@ def query(
timestamp=timestamp,
get_counts=get_counts,
metadata=metadata,
log_warning=log_warning,
**self.filter_kwargs_mat,
)
elif timestamp is None:
logger.warning(
"The `client.materialize.tables` interface is experimental and might experience breaking changes before the feature is stabilized."
)
qry_table = self._reference_table
return client.materialize.join_query(
tables=self.basic_join,
Expand All @@ -723,6 +724,7 @@ def query(
desired_resolution=desired_resolution,
suffixes={self._reference_table: "_ref", self._base_table: ""},
metadata=metadata,
log_warning=log_warning,
**self.filter_kwargs_mat,
)
else:
Expand All @@ -734,6 +736,7 @@ def query(
metadata=metadata,
desired_resolution=desired_resolution,
allow_missing_lookups=False,
log_warning=log_warning,
**self.filter_kwargs_mat,
)

Expand All @@ -746,6 +749,7 @@ def live_query(
metadata: bool = True,
desired_resolution: Optional[list] = None,
allow_missing_lookups: bool = False,
log_warning: bool = True,
):
"""Set data return options for the specified live query
Expand All @@ -766,16 +770,15 @@ def live_query(
If True, will return values even if the database is still ingesting new information, by default False.
IMPORTANT: If set to True, the database could return different answers to the same query at the same timestamp.
Do not set to True if writing code you intended to give consistent answers every time.
log_warning : bool, optional
Whether to log warnings associated with tables
Returns
-------
pd.DataFrame
Query data
"""

logger.warning(
"The `client.materialize.tables` interface is experimental and might experience breaking changes before the feature is stabilized."
)
if self._reference_table is None:
qry_table = self._base_table
return client.materialize.live_live_query(
Expand All @@ -787,6 +790,7 @@ def live_query(
desired_resolution=desired_resolution,
allow_missing_lookups=allow_missing_lookups,
metadata=metadata,
log_warning=log_warning,
**self.filter_kwargs_live,
)
else:
Expand All @@ -801,6 +805,7 @@ def live_query(
suffixes={self._reference_table: "_ref", self._base_table: ""},
allow_missing_lookups=allow_missing_lookups,
metadata=metadata,
log_warning=log_warning,
**self.filter_kwargs_live,
**self.joins_kwargs,
)
Expand All @@ -819,6 +824,7 @@ def query(
metadata: bool = True,
desired_resolution: Optional[list] = None,
get_counts: bool = False,
log_warning: bool = True,
):
"""Query views through the table interface
Expand All @@ -842,10 +848,9 @@ def query(
If default, uses the values in the table directly.
get_counts : bool, optional
Only return number of rows in the query, by default False
log_warning : bool, optional
Whether to log warnings associated with tables
"""
logger.warning(
"The `client.materialize.views` interface is experimental and might experience breaking changes before the feature is stabilized."
)
return client.materialize.query_view(
self._base_table,
metadata=metadata,
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b197551

Please sign in to comment.