Skip to content
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

Add deprecation warnings to results classes and methods #15323

Merged
merged 8 commits into from
Sep 11, 2024

Conversation

desertaxle
Copy link
Member

@desertaxle desertaxle commented Sep 10, 2024

This PR adds deprecation warning to following because they have been superseded by new results mechanics:

  • ResultStore.create_result
  • BaseResult
  • PersistedResult

This PR also updates our testing logic to fail whenever a PrefectDeprecationWarning is raised. A fixture ignore_prefect_deprecation_warnings can suppress failures until the deprecation period has passed. Once the deprecation period has passed, the warnings will cause test failures again, prompting us to remove the deprecated code.

Related to #15208

Checklist

  • This pull request references any related issue by including "closes <link to issue>"
    • If no issue exists and your change is not a small fix, please create an issue first.
  • If this pull request adds new functionality, it includes unit tests that cover the changes
  • If this pull request removes docs files, it includes redirect settings in mint.json.
  • If this pull request adds functions or classes, it includes helpful docstrings.

Copy link

codspeed-hq bot commented Sep 10, 2024

CodSpeed Performance Report

Merging #15323 will not alter performance

Comparing deprecate-persisted-result (4fb1d6c) with main (b53bb90)

Summary

✅ 3 untouched benchmarks

Comment on lines +759 to 765
@deprecated.deprecated_callable(
start_date="Sep 2024",
end_date="Nov 2024",
help="Use `create_result_record` instead.",
)
@sync_compatible
async def create_result(
Copy link
Member Author

Choose a reason for hiding this comment

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

Deprecation warning for create_reuslt

Comment on lines +1106 to 1109
@deprecated.deprecated_class(
start_date="Sep 2024", end_date="Nov 2024", help="Use `ResultRecord` instead."
)
class PersistedResult(BaseResult):
Copy link
Member Author

Choose a reason for hiding this comment

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

Deprecation warning for PersistedResult

Comment on lines +1053 to 1057
@deprecated.deprecated_class(
start_date="Sep 2024", end_date="Nov 2024", help="Use `ResultRecord` instead."
)
@register_base_type
class BaseResult(BaseModel, abc.ABC, Generic[R]):
Copy link
Member Author

Choose a reason for hiding this comment

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

Deprecation warning for BaseResult

Comment on lines +15 to +36
def should_reraise_warning(warning):
"""
Determine if a deprecation warning should be reraised based on the date.

Deprecation warnings that have passed the date threshold should be reraised to
ensure the deprecated code paths are removed.
"""
message = str(warning.message)
try:
# Extract the date from the new message format
date_str = message.split("not be available in new releases after ")[1].strip(
"."
)
# Parse the date
deprecation_date = datetime.strptime(date_str, "%b %Y").date().replace(day=1)

# Check if the current date is after the start of the month following the deprecation date
current_date = datetime.now().date().replace(day=1)
return current_date > deprecation_date
except Exception:
# Reraise in cases of failure
return True
Copy link
Member Author

Choose a reason for hiding this comment

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

I added this check to know when the deprecated code is ready to be removed. As a result, code path that raise deprecation warnings in tests will need to use the ignore_prefect_deprecation_warnings fixture directly.

@desertaxle desertaxle added the development Tech debt, refactors, CI, tests, and other related work. label Sep 11, 2024
@desertaxle desertaxle marked this pull request as ready for review September 11, 2024 19:52
@desertaxle desertaxle merged commit f5d9917 into main Sep 11, 2024
38 checks passed
@desertaxle desertaxle deleted the deprecate-persisted-result branch September 11, 2024 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
development Tech debt, refactors, CI, tests, and other related work.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants