From 2e8683d602dff49520f8dba575db9e4dd1b351cd Mon Sep 17 00:00:00 2001 From: Colin Ho Date: Mon, 13 Nov 2023 12:50:17 -0800 Subject: [PATCH] use warnings.warn --- daft/dataframe/dataframe.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/daft/dataframe/dataframe.py b/daft/dataframe/dataframe.py index e701640b76..36b70c5774 100644 --- a/daft/dataframe/dataframe.py +++ b/daft/dataframe/dataframe.py @@ -4,7 +4,6 @@ # in order to support runtime typechecking across different Python versions. # For technical details, see https://github.com/Eventual-Inc/Daft/pull/630 -import logging import pathlib from dataclasses import dataclass from functools import reduce @@ -21,6 +20,7 @@ TypeVar, Union, ) +import warnings from daft.api_annotations import DataframePublicAPI from daft.context import get_context @@ -47,8 +47,6 @@ from daft.logical.schema import Schema -logger = logging.getLogger(__name__) - UDFReturnType = TypeVar("UDFReturnType", covariant=True) ColumnInputType = Union[Expression, str] @@ -854,7 +852,7 @@ def sum(self, *cols: ColumnInputType) -> "DataFrame": DataFrame: Globally aggregated sums. Should be a single row. """ if len(cols) == 0: - logger.warning( + warnings.warn( "No columns specified; performing sum on all columns. Specify columns using df.sum('col1', 'col2', ...)." ) cols = tuple(self.columns) @@ -870,7 +868,7 @@ def mean(self, *cols: ColumnInputType) -> "DataFrame": DataFrame: Globally aggregated mean. Should be a single row. """ if len(cols) == 0: - logger.warning( + warnings.warn( "No columns specified; performing mean on all columns. Specify columns using df.mean('col1', 'col2', ...)." ) cols = tuple(self.columns) @@ -886,7 +884,7 @@ def min(self, *cols: ColumnInputType) -> "DataFrame": DataFrame: Globally aggregated min. Should be a single row. """ if len(cols) == 0: - logger.warning( + warnings.warn( "No columns specified; performing min on all columns. Specify columns using df.min('col1', 'col2', ...)." ) cols = tuple(self.columns) @@ -902,7 +900,7 @@ def max(self, *cols: ColumnInputType) -> "DataFrame": DataFrame: Globally aggregated max. Should be a single row. """ if len(cols) == 0: - logger.warning( + warnings.warn( "No columns specified; performing max on all columns. Specify columns using df.max('col1', 'col2', ...)." ) cols = tuple(self.columns) @@ -918,7 +916,7 @@ def count(self, *cols: ColumnInputType) -> "DataFrame": DataFrame: Globally aggregated count. Should be a single row. """ if len(cols) == 0: - logger.warning( + warnings.warn( "No columns specified; performing count on all columns. Specify columns using df.count('col1', 'col2', ...) or use df.count_rows() for row counts." ) cols = tuple(self.columns) @@ -934,7 +932,7 @@ def agg_list(self, *cols: ColumnInputType) -> "DataFrame": DataFrame: Globally aggregated list. Should be a single row. """ if len(cols) == 0: - logger.warning( + warnings.warn( "No columns specified; performing agg_list on all columns. Specify columns using df.agg_list('col1', 'col2', ...)." ) cols = tuple(self.columns) @@ -950,7 +948,7 @@ def agg_concat(self, *cols: ColumnInputType) -> "DataFrame": DataFrame: Globally aggregated list. Should be a single row. """ if len(cols) == 0: - logger.warning( + warnings.warn( "No columns specified; performing agg_concat on all columns. Specify columns using df.agg_concat('col1', 'col2', ...)." ) cols = tuple(self.columns)