Skip to content

Conversation

@sfc-gh-jrose
Copy link
Contributor

@sfc-gh-jrose sfc-gh-jrose commented Dec 11, 2024

  1. Which Jira issue is this PR addressing? Make sure that there is an accompanying issue to your PR.

    Fixes SNOW-NNNNNNN

  2. Fill out the following pre-review checklist:

    • I am adding a new automated test(s) to verify correctness of my new code
      • If this test skips Local Testing mode, I'm requesting review from @snowflakedb/local-testing
    • I am adding new logging messages
    • I am adding a new telemetry message
    • I am adding new credentials
    • I am adding a new dependency
    • If this is a new feature/behavior, I'm adding the Local Testing parity changes.
    • I acknowledge that I have ensured my changes to be thread-safe. Follow the link for more information: Thread-safe Developer Guidelines
  3. Please describe how your code solves the related issue.

The goal of this refactor is to provide a central location for defining parameters and other snowpark-python configuration. This should make it easier to add additional parameters in the future as well as gate more deprecated or exerimental logic behind parameters.

Session parmeters are now all added in Session._initialize_config. All definition needed for them should happen there.
Package level confuguration settings should similarly all be defined in src/snowflake/snowpark/_internal/config.py

Parameters and package level configs can all be accessed via session.conf.

As part of this change I've moved all of the session level parameters over to the new settings style, but there are likely package level configuration options that I have missed. For now the parameters that are exposed as properties of the session object remain available in this manner, but in the future we should standardize the access method to be through the config object.

@sfc-gh-jrose sfc-gh-jrose added the NO-CHANGELOG-UPDATES This pull request does not need to update CHANGELOG.md label Dec 11, 2024
@sfc-gh-jrose sfc-gh-jrose force-pushed the jrose_snow_vation_config_refactor branch from 72c910b to 0f2d9d2 Compare December 12, 2024 19:40
@sfc-gh-jrose sfc-gh-jrose marked this pull request as ready for review December 14, 2024 00:02
@sfc-gh-jrose sfc-gh-jrose requested review from a team as code owners December 14, 2024 00:02
Comment on lines -763 to +820
def conf(self) -> RuntimeConfig:
def conf(self) -> SettingStore:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines -638 to 620
@pytest.mark.parametrize(
"parameter_name",
[
"_auto_clean_up_temp_table_enabled",
"_cte_optimization_enabled",
"_large_query_breakdown_enabled",
],
"parameter_name", ["auto_clean_up_temp_table_enabled", "cte_optimization_enabled"]
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merge artifact

Comment on lines +256 to +259
session.auto_clean_up_temp_table_enabled = True
assert session.auto_clean_up_temp_table_enabled is True
assert "auto_clean_up_temp_table_enabled is experimental" in caplog.text
session.auto_clean_up_temp_table_enabled = False
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we not raise warning only when we enable the param?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The warning is only raised when setting to a non-default value.

"""

name: str
description: str | None = field(default=None)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description: str | None = field(default=None)
description: Optional[str] = field(default=None)

nit: we follow this style in the repo.

@sfc-gh-aalam
Copy link
Contributor

would it be easy to cover changes made in this PR: #2673

@sfc-gh-jrose
Copy link
Contributor Author

would it be easy to cover changes made in this PR: #2673

That wouldn't be too hard. I think I'd recommend downgrading from an error to a warning though so that users can be aware that they should clean things up.

Copy link
Contributor

@sfc-gh-aalam sfc-gh-aalam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approving based on

  1. re-naming SettingStore to RuntimeConfig so that we don't change names of classes
  2. adding a simple how-to maybe in contributing.md or config.py

when all configuration needs to be accessible from a single object.
"""

import pkg_resources
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pkg_resources is kinda deprecated, check notes in https://setuptools.pypa.io/en/latest/pkg_resources.html
is it possible to switch to importlib as suggested?

Comment on lines +76 to +79
self._parent is not None
and (parent_value := self._parent.value) is not None
):
return parent_value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a chance of a multi layer setting such that we need recursion here to get the default value?
A.default = 1
B.parent = A , default = None
C.parent = B, default = None

Comment on lines +53 to +58
name (str): The name of the setting that is used to reference it.
description (str): A docstring that describes the function of the setting.
default: (Any): The default value that a setting takes when not otherwise configured.
read_only (bool): Disallows modification of the setting when set to True.
experimental_since (str): When set this will warn users that changing the value of this
setting is experimental and may not be ready for production environments.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it just came to my mind that do we want a field for "deprecation"?
not blocking this PR as we can add in the future

parameter_name (str): The name of the session parameter that holds the value for this setting.
synchronize (bool): When set to True the server side session parameter will be updated when
this settings value is changed.
telemetry_hook (Callable): A callback function that allows emitting telemetry when thissettings
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change
telemetry_hook (Callable): A callback function that allows emitting telemetry when thissettings
telemetry_hook (Callable): A callback function that allows emitting telemetry when this

return getattr(self._session._conn._conn, key)
return self._conf.get(key, default)

def is_mutable(self, key: str) -> bool:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see is_mutable is implemented the new config class?

Comment on lines -693 to -705
def is_feature_enabled_for_version(self, parameter_name: str) -> bool:
"""
This method checks if a feature is enabled for the current session based on
the server side parameter.
"""
version = self._conn._get_client_side_session_parameter(parameter_name, "")
return (
isinstance(version, str)
and version != ""
and pkg_resources.parse_version(self.version)
>= pkg_resources.parse_version(version)
)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we keep this? removing this is a BCR, also I feel this func can be helpful to users

@sfc-gh-yuwang sfc-gh-yuwang deleted the jrose_snow_vation_config_refactor branch February 13, 2025 22:52
@github-actions github-actions bot locked and limited conversation to collaborators Feb 13, 2025
@sfc-gh-jrose sfc-gh-jrose restored the jrose_snow_vation_config_refactor branch February 13, 2025 23:03
@sfc-gh-jrose sfc-gh-jrose reopened this Feb 13, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

NO-CHANGELOG-UPDATES This pull request does not need to update CHANGELOG.md snowpark-pandas

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants