-
Notifications
You must be signed in to change notification settings - Fork 467
feat: Add environment variable setting for default retention policy #8178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @fjcasti1 - I've reviewed your changes - here's some feedback:
- The docstring for get_env_default_retention_policy_days is incorrect (mentions a boolean and cert verification); please update it to accurately describe the integer days and default behavior.
- Using assert for validating the env var can be skipped in optimized runs—consider raising a ValueError or handling negative values more explicitly.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The docstring for get_env_default_retention_policy_days is incorrect (mentions a boolean and cert verification); please update it to accurately describe the integer days and default behavior.
- Using assert for validating the env var can be skipped in optimized runs—consider raising a ValueError or handling negative values more explicitly.
## Individual Comments
### Comment 1
<location> `src/phoenix/config.py:463` </location>
<code_context>
return _bool_val(ENV_PHOENIX_TLS_VERIFY_CLIENT, False)
+def get_env_default_retention_policy_days() -> int:
+ """
+ Gets the value of the PHOENIX_DEFAULT_RETENTION_POLICY_DAYS environment variable.
</code_context>
<issue_to_address>
The docstring for get_env_default_retention_policy_days is inaccurate.
Update the docstring to state that the function returns the number of days for the default retention policy, defaulting to 0 if not set.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
"""
Gets the value of the PHOENIX_DEFAULT_RETENTION_POLICY_DAYS environment variable.
Returns:
int: True if client certificate verification is enabled, False otherwise. Defaults to False
if the environment variable is not set.
""" # noqa: E501
=======
"""
Returns the number of days for the default retention policy as set by the
PHOENIX_DEFAULT_RETENTION_POLICY_DAYS environment variable, defaulting to 0 if not set.
Returns:
int: Number of days for the default retention policy. Defaults to 0 if the environment variable is not set.
""" # noqa: E501
>>>>>>> REPLACE
</suggested_fix>
### Comment 2
<location> `src/phoenix/config.py:472` </location>
<code_context>
+ if the environment variable is not set.
+ """ # noqa: E501
+ days = _int_val(ENV_PHOENIX_DEFAULT_RETENTION_POLICY_DAYS, 0)
+ assert days >= 0
+ return days
+
</code_context>
<issue_to_address>
Using assert for input validation may not be reliable in production.
Assertions can be disabled at runtime, so use an explicit exception (e.g., raise ValueError) to enforce this check reliably.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
days = _int_val(ENV_PHOENIX_DEFAULT_RETENTION_POLICY_DAYS, 0)
assert days >= 0
return days
=======
days = _int_val(ENV_PHOENIX_DEFAULT_RETENTION_POLICY_DAYS, 0)
if days < 0:
raise ValueError("PHOENIX_DEFAULT_RETENTION_POLICY_DAYS must be non-negative")
return days
>>>>>>> REPLACE
</suggested_fix>
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
src/phoenix/config.py
Outdated
Returns: | ||
int: True if client certificate verification is enabled, False otherwise. Defaults to False | ||
if the environment variable is not set. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docstring for get_env_default_retention_policy_days()
contains incorrect return value documentation. It appears to be copied from another function and describes boolean behavior related to client certificate verification, but this function actually returns an integer representing days.
The return documentation should be updated to:
Returns:
int: The default retention policy in days. Defaults to 0 if the environment variable is not set.
Returns: | |
int: True if client certificate verification is enabled, False otherwise. Defaults to False | |
if the environment variable is not set. | |
Returns: | |
int: The default retention policy in days. Defaults to 0 if the environment variable is not set. |
Spotted by Diamond
Is this helpful? React 👍 or 👎 to let us know.
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Summary by Sourcery
Add an environment variable to configure the default trace retention policy and apply it in the database facilitator
New Features:
Enhancements: