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

[dagster-dbt] update usage of deprecated context methods #19806

Merged
merged 2 commits into from
Feb 15, 2024

Conversation

jamiedemaria
Copy link
Contributor

@jamiedemaria jamiedemaria commented Feb 14, 2024

Summary & Motivation

Some methods in the dbt integration use context methods that were deprecated in #19441 and #17339. The op-specific methods are meant to be replaced by calling context.op_execution_context.op rather than context.op. However, in some of the dbt methods, we don't know if the context is of type AssetExecutionContext or OpExecutionContext, so it is unclear if we need to call the underlying op_execution_context before op-specific methods.

This PR adds a check in some methods that will pull the op_execution_context from the context if the context is an AssetExecutionContext so that we are guaranteed to be working with an OpExecutionContext in the rest of the method.

How I Tested These Changes

@jamiedemaria
Copy link
Contributor Author

Current dependencies on/for this PR:

This stack of pull requests is managed by Graphite.

@jamiedemaria jamiedemaria marked this pull request as ready for review February 14, 2024 21:55
Comment on lines 971 to 980
op_context = (
context.op_execution_context if isinstance(context, AssetExecutionContext) else context
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Would prefer that we just keep this named context.

Can we move this to be after we instantiate assets_def, but before the if context and assets_def is not None?

Suggested change
op_context = (
context.op_execution_context if isinstance(context, AssetExecutionContext) else context
)
context: Optional[OpExecutionContext] = (
context.op_execution_context if isinstance(context, AssetExecutionContext) else context
)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure for the rename, but _get_unique_target_name needs the op context too and is called before we get the assets_def. I just moved fetching assets_def up, but lmk if you'd prefer something else

Copy link
Contributor

@rexledesma rexledesma left a comment

Choose a reason for hiding this comment

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

Looks good once tests pass

@jamiedemaria jamiedemaria merged commit 89b29b0 into master Feb 15, 2024
1 check passed
@jamiedemaria jamiedemaria deleted the jamie/deprecated-methods branch February 15, 2024 20:39
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.

2 participants