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

Propagate automation condition information through the UI for user code conditions #25211

Conversation

OwenKephart
Copy link
Contributor

Summary & Motivation

It is not possible to serialize the full automation condition object if it is user-defined. In these cases, we only persist the snapshot.

Updates the graphql code to use this snapshot instead of the raw condition, and adds e2e test ensuring we can execute / get the correct label for these objects.

How I Tested These Changes

Changelog

NOCHANGELOG

Copy link
Contributor Author

OwenKephart commented Oct 11, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @OwenKephart and the rest of your teammates on Graphite Graphite

@OwenKephart OwenKephart force-pushed the 10-10-export_automationcontext_and_automationresult branch from d2572a5 to 5c39c20 Compare October 11, 2024 00:30
@OwenKephart OwenKephart force-pushed the 10-10-propagate_automation_condition_information_through_the_ui_for_user_code_conditions branch from 11b2b09 to 7a838b5 Compare October 11, 2024 00:30
@OwenKephart OwenKephart requested a review from bengotow October 11, 2024 00:40
Copy link
Contributor Author

@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.

@gibsondan flagging this PR as at one point we removed this data from the snapshot due to (iirc?) unfounded beliefs that it was blowing up the workspace size -- just confirming that this was actually unfounded

@gibsondan
Copy link
Member

gibsondan commented Oct 11, 2024 via email

Copy link
Member

@gibsondan gibsondan left a comment

Choose a reason for hiding this comment

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

is there a world where we only persist this new thing once you opt in to user-defined automation condition sensors? or does that make things way more complicated?

Copy link
Member

@gibsondan gibsondan left a comment

Choose a reason for hiding this comment

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

sounds like that world is indeed possible

@OwenKephart OwenKephart force-pushed the 10-10-propagate_automation_condition_information_through_the_ui_for_user_code_conditions branch from 7a838b5 to 10e5e25 Compare October 11, 2024 16:47
@OwenKephart OwenKephart requested a review from gibsondan October 11, 2024 16:47
@OwenKephart OwenKephart force-pushed the 10-10-export_automationcontext_and_automationresult branch from 5c39c20 to 8acc87b Compare October 11, 2024 17:18
@OwenKephart OwenKephart force-pushed the 10-10-propagate_automation_condition_information_through_the_ui_for_user_code_conditions branch from 10e5e25 to 2734223 Compare October 11, 2024 17:18
@OwenKephart OwenKephart force-pushed the 10-10-export_automationcontext_and_automationresult branch from 8acc87b to 66d4fe6 Compare October 11, 2024 19:46
@OwenKephart OwenKephart force-pushed the 10-10-propagate_automation_condition_information_through_the_ui_for_user_code_conditions branch from 2734223 to 404dcbf Compare October 11, 2024 19:46
@OwenKephart OwenKephart force-pushed the 10-10-export_automationcontext_and_automationresult branch from 66d4fe6 to 3a1e7c1 Compare October 11, 2024 20:01
@OwenKephart OwenKephart force-pushed the 10-10-propagate_automation_condition_information_through_the_ui_for_user_code_conditions branch from c02046f to 12ccaf1 Compare October 15, 2024 17:55
Comment on lines 340 to 339
item.description,
item.children,
)
elif isinstance(item, AutomationConditionSnapshot):
label, name, description, children = (
item.node_snapshot.label,
item.node_snapshot.name,
item.node_snapshot.description,
item.children,
)
Copy link
Member

Choose a reason for hiding this comment

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

[Re: lines +336 to +349]

can we not just _always_ use the snapshot?

See this comment inline on Graphite.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah we need to use the AutomationConditionEvaluation in the history UI, as we don't store the full snapshot there. We could put a method on AutomationConditionEvaluation that reconstructs an AutomationConditionSnapshot though, just seems out of scope for this PR. Can stack one a PR for that on top though

Copy link
Member

@schrockn schrockn left a comment

Choose a reason for hiding this comment

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

Why don't we just always use the snapshots?

@OwenKephart OwenKephart force-pushed the 10-10-export_automationcontext_and_automationresult branch from 5c31e88 to ddc6079 Compare October 15, 2024 18:54
@OwenKephart OwenKephart force-pushed the 10-10-propagate_automation_condition_information_through_the_ui_for_user_code_conditions branch from 12ccaf1 to 3bd0f6e Compare October 15, 2024 18:54
@OwenKephart OwenKephart force-pushed the 10-10-export_automationcontext_and_automationresult branch from ddc6079 to ebe651d Compare October 15, 2024 20:08
Base automatically changed from 10-10-export_automationcontext_and_automationresult to master October 15, 2024 20:10
@OwenKephart OwenKephart force-pushed the 10-10-propagate_automation_condition_information_through_the_ui_for_user_code_conditions branch 2 times, most recently from 700d7e4 to b9a4a6e Compare October 15, 2024 21:08
Copy link
Contributor Author

In general, because we need to be able to execute the conditions on the daemon side of the process if executing in daemon mode. In the code sample you linked to, no good reason (and I removed it).

Comment on lines +847 to +857
automation_condition = (
self._asset_node_snap.automation_condition_snapshot
or self._asset_node_snap.automation_condition
)
if automation_condition:
return GrapheneAutomationCondition(
# we only store one of automation_condition or automation_condition_snapshot
automation_condition
if isinstance(automation_condition, AutomationConditionSnapshot)
else automation_condition.get_snapshot()
)
Copy link
Member

Choose a reason for hiding this comment

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

Don't see why we don't unconditionally use the snapshot in the graphql server

Copy link
Member

Choose a reason for hiding this comment

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

As in why can't the asset_node_snap just have the snapshot?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Responded to this above

Copy link
Member

@schrockn schrockn left a comment

Choose a reason for hiding this comment

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

This is just a weird mental model in my mind.

Seems like there should be just a snapshot but we should have special logic to reconstruct the "real" automation condition in the asset daemon from the snapshot.

Copy link
Collaborator

@bengotow bengotow left a comment

Choose a reason for hiding this comment

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

Just reviewed the UI + graphql portions of this but it looks good to me! Left one inline comment, might be nice to remove the autoMaterializePolicy fields from the graphql queries if we can.

@OwenKephart OwenKephart force-pushed the 10-10-propagate_automation_condition_information_through_the_ui_for_user_code_conditions branch 2 times, most recently from 8bf74fd to 12f4f07 Compare October 16, 2024 23:45
Copy link
Contributor Author

@schrockn The snapshot is designed to only contain information that's relevant to displaying a condition in the UI to a user. This means that it reduces down a lot of the complexity of the parameters etc. of a given condition to being just a simple string (e.g. the any_deps_match condition can have an "allow" or "ignore" parameter, which are rendered in the string like so: https://sourcegraph.com/github.com/dagster-io/dagster@a118eeb03d2c9a6f2a8ff1c152f4a0acc52e4a7a/-/blob/python_modules/dagster/dagster/_core/definitions/declarative_automation/operators/dep_operators.py?L76

In general, this means that we don't enforce any contract on how those names should be generated, and so trying to deserialize them is impossible, and much more the job of the serdes framework.

So if we wanted to avoid having both an AutomationCondition field and an AutomationConditionSnapshot field on the asset_node_snap, then we'd need to go the route of only populating the AutomationCondition field, which would necessitate having a special "NonExecutableAutomationCondition" or something that we could transform user-defined conditions into, whose purpose would be to allow us to get the parts of user-defined automation conditions that are necessary to render it in the UI across the serdes boundary. I explored this approach in a previous PR but we deemed that to be a confusing system, so that approach was abandoned, but I could be convinced to go back to that setup.

@OwenKephart OwenKephart requested a review from schrockn October 16, 2024 23:57
@OwenKephart OwenKephart force-pushed the 10-10-propagate_automation_condition_information_through_the_ui_for_user_code_conditions branch from 12f4f07 to cab309b Compare October 17, 2024 16:38
@OwenKephart OwenKephart force-pushed the 10-10-propagate_automation_condition_information_through_the_ui_for_user_code_conditions branch from cab309b to fad7f9a Compare October 21, 2024 23:04
@OwenKephart OwenKephart force-pushed the 10-10-propagate_automation_condition_information_through_the_ui_for_user_code_conditions branch from fad7f9a to 9a74d41 Compare October 22, 2024 16:48
Copy link
Contributor Author

OwenKephart commented Oct 22, 2024

Merge activity

  • Oct 22, 12:50 PM EDT: A user started a stack merge that includes this pull request via Graphite.
  • Oct 22, 12:50 PM EDT: A user merged this pull request with Graphite.

@OwenKephart OwenKephart merged commit fd9ffdc into master Oct 22, 2024
0 of 2 checks passed
@OwenKephart OwenKephart deleted the 10-10-propagate_automation_condition_information_through_the_ui_for_user_code_conditions branch October 22, 2024 16:50
Grzyblon pushed a commit to Grzyblon/dagster that referenced this pull request Oct 26, 2024
…de conditions (dagster-io#25211)

## Summary & Motivation

It is not possible to serialize the full automation condition object if it is user-defined. In these cases, we only persist the snapshot.

Updates the graphql code to use this snapshot instead of the raw condition, and adds e2e test ensuring we can execute / get the correct label for these objects.

## How I Tested These Changes

## Changelog

NOCHANGELOG
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.

4 participants