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

[4/n][dagster-sling] Mark DagsterSlingTranslator.get_* methods as superseded #27142

Open
wants to merge 2 commits into
base: maxime/sling-asset-spec-3
Choose a base branch
from

Conversation

maximearmstrong
Copy link
Contributor

@maximearmstrong maximearmstrong commented Jan 16, 2025

Summary & Motivation

As title.

@cmpadden
Copy link
Contributor

cmpadden commented Jan 16, 2025

@maximearmstrong , I'm curious if it's necessary to deprecate the get_ methods, with get_asset_spec being the favored approach. Is this being standardized across all integrations, dbt, dlt, etc?

I just want to be cognizant of the impact it has on our users who having working pipelines, and want them to continue to work with little to no changes. I could imagine us having warnings on their usage, and updating all learning material to prefer get_asset_spec but avoid deprecation.

@OwenKephart
Copy link
Contributor

I agree with @cmpadden 's points here -- I think maybe superseded is a better decorator here? At the very least the deprecation cycle should be longer

I think the maintenance burden of these extra methods isn't too high on our side (even if they're a bit unsightly)

Copy link
Contributor

@OwenKephart OwenKephart left a comment

Choose a reason for hiding this comment

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

Following up now that I've looked at the downstack PR, I think there's a way to delete these methods without breaking users and without having to keep these in code forever

Also having thought about it more, I'm not sure there's a good way for us to actually mark these as deprecated even if we wanted to -- the user is overriding these functions not calling them, so marking them this way won't really alert the user that anything is "wrong"

@maximearmstrong maximearmstrong force-pushed the maxime/sling-asset-spec-3 branch from 9fb0324 to 71ad256 Compare January 17, 2025 16:57
@maximearmstrong maximearmstrong force-pushed the maxime/sling-asset-spec-4 branch from f881d04 to dc036e5 Compare January 17, 2025 16:57
@maximearmstrong maximearmstrong changed the title [4/n][dagster-sling] Deprecate DagsterSlingTranslator.get_* methods [4/n][dagster-sling] Mark DagsterSlingTranslator.get_* methods as superseded Jan 17, 2025
@maximearmstrong
Copy link
Contributor Author

Also having thought about it more, I'm not sure there's a good way for us to actually mark these as deprecated even if we wanted to -- the user is overriding these functions not calling them, so marking them this way won't really alert the user that anything is "wrong"

@OwenKephart I updated the decorator to mark methods as superseded. I think keeping the decorators and methods are important:

  • This will ensure that get_* methods are marked as superseded in the docs.
  • These methods can be manually called by users.
    • Nothing prevents users to do something like DagsterSlingTranslator().get_asset_key(stream_definition) in their code to recreate an asset key - it's not best practice, but not forbidden.

To make sure users get the supersession warning, I updated _resolve_back_compat_method to emit a warning if a get_* method is used.

@maximearmstrong
Copy link
Contributor Author

I'm curious if it's necessary to deprecate the get_ methods, with get_asset_spec being the favored approach. Is this being standardized across all integrations, dbt, dlt, etc?

@cmpadden This thread can give you more context on why we think get_ methods should be deprecated.

The main problem is that users can override get_asset_key without using the correct and new implementation in get_asset_spec. This caused many problems in the past, where users would have asset key with different prefixes, or asset duplication, because of that.

The conclusion was that only get_asset_spec should be implemented, and then attributes could be accessed from the AssetSpec object.

Copy link
Contributor

@OwenKephart OwenKephart left a comment

Choose a reason for hiding this comment

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

Note my comment on the warning message

supersession_warning(
subject=method_name,
additional_warn_text=(
"Use `DagsterSlingTranslator.get_asset_spec(...)` to access the attribute instead."
Copy link
Contributor

Choose a reason for hiding this comment

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

so this warning comes up specifically in cases where users are overriding the method on the base class, so maybe the warning should reference that? i.e. Instead of overriding X, override DagsterSlingTranslator.get_asset_spec()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants