From 001ee3006f1db7b1a91537a63dae7cde856a3279 Mon Sep 17 00:00:00 2001 From: Garrett Wu Date: Fri, 16 May 2025 20:17:32 +0000 Subject: [PATCH 1/2] feat: add bpd.options.reset() method --- bigframes/_config/__init__.py | 9 +++++++++ bigframes/_config/experiment_options.py | 2 ++ samples/snippets/quickstart.py | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/bigframes/_config/__init__.py b/bigframes/_config/__init__.py index 775ef70bc7..52b47e3e9a 100644 --- a/bigframes/_config/__init__.py +++ b/bigframes/_config/__init__.py @@ -56,12 +56,21 @@ class Options: """Global options affecting BigQuery DataFrames behavior.""" def __init__(self): + self.reset() + + def reset(self) -> Options: + """Reset the option settings to defaults. + + Returns: + bigframes._config.Options: Options object with default values. + """ self._local = ThreadLocalConfig() # BigQuery options are special because they can only be set once per # session, so we need an indicator as to whether we are using the # thread-local session or the global session. self._bigquery_options = bigquery_options.BigQueryOptions() + return self def _init_bigquery_thread_local(self): """Initialize thread-local options, based on current global options.""" diff --git a/bigframes/_config/experiment_options.py b/bigframes/_config/experiment_options.py index 024de392c0..2bf8b7f021 100644 --- a/bigframes/_config/experiment_options.py +++ b/bigframes/_config/experiment_options.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import dataclasses from typing import Optional import warnings @@ -19,6 +20,7 @@ import bigframes.exceptions as bfe +@dataclasses.dataclass class ExperimentOptions: """ Encapsulates the configration for experiments diff --git a/samples/snippets/quickstart.py b/samples/snippets/quickstart.py index 8b3b08884a..bc05cd2512 100644 --- a/samples/snippets/quickstart.py +++ b/samples/snippets/quickstart.py @@ -74,4 +74,4 @@ def run_quickstart(project_id: str) -> None: # close session and reset option so not to affect other tests bpd.close_session() - bpd.options.bigquery.ordering_mode = "strict" + bpd.options.reset() From 99e547452fd61b95fab45a3256e7286d3cd86406 Mon Sep 17 00:00:00 2001 From: Garrett Wu Date: Fri, 16 May 2025 20:25:25 +0000 Subject: [PATCH 2/2] reset experimental flag --- bigframes/_config/experiment_options.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/bigframes/_config/experiment_options.py b/bigframes/_config/experiment_options.py index 2bf8b7f021..024de392c0 100644 --- a/bigframes/_config/experiment_options.py +++ b/bigframes/_config/experiment_options.py @@ -12,7 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import dataclasses from typing import Optional import warnings @@ -20,7 +19,6 @@ import bigframes.exceptions as bfe -@dataclasses.dataclass class ExperimentOptions: """ Encapsulates the configration for experiments