-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[DA][testing] RFC: Create AutomationConditionTester class #22292
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. Join @OwenKephart and the rest of your teammates on Graphite |
d217f3f
to
8aba3a2
Compare
I think this is too complicated for a public API. The primary interface should be a simple function with this as an opt-in advanced API. |
@schrockn hm so the alternative testing path with a single function would look like: from dagster import execute_automation_tick, AutomationTickResult
def my_test():
instance=DagsterInstance.ephemeral()
result = execute_automation_tick(defs=defs, current_time=..., instance=instance)
assert result.num_requested == 1
result = execute_automation_tick(defs=defs, current_time=..., cursor=result.cursor, instance=instance)
assert result.num_requested == 0 This isn't the end of the world but is a bit more verbose because you have to explicitly shuttle the instance and cursor between ticks. The main thing I was trying to accomplish with the class was to avoid that, but there's definitely no harm in starting lightweight. |
8aba3a2
to
18549a4
Compare
@schrockn updated the PR to move the class thing out of the public API and add an evaluate_automation_conditions method. |
Yeah I think the function version is simpler and easier to understand. If we want to handle with automation_testing(context=context, instance=instance):
result = execute_automation_tick(defs=defs, current_time=...) or with automation_state(context=context, instance=instance, current_time=...) as state:
result = state.execute_automation_tick(defs=defs) and it just is a |
def evaluate_automation_conditions( | ||
defs: Definitions, | ||
instance: DagsterInstance, | ||
asset_selection: AssetSelection = AssetSelection.all(), | ||
evaluation_time: Optional[datetime.datetime] = None, | ||
cursor: Optional[AssetDaemonCursor] = None, | ||
logger: Optional[logging.Logger] = None, | ||
) -> EvaluateAutomationConditionsResult: |
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.
I think we should figure out a way to allow for passing a list of AssetsDefinitions
18549a4
to
59f0cae
Compare
59f0cae
to
234edf7
Compare
@schrockn gotcha -- removed the class-based thing, made |
respect_materialization_data_versions=False, | ||
auto_materialize_run_tags={}, | ||
) | ||
results, requested_asset_partitions = evaluator.evaluate() |
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.
Definitely should be a goal to have this return a range representation soon. cc: @smackesey
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.
cool thanks
…#22292) ## Summary & Motivation Adds a user-facing method for evaluating asset conditions ## How I Tested These Changes
Summary & Motivation
This is an initial forray into exposing a testing API for AutomationConditions. It's quite minimal at the moment, but contains the necessary functions for a user to test how either new materializations or the passage of time might impact the decisions made. It's inspired by the testing framework we use internally, but with a bit less magic.
One constraint here was that any return value from this must only use public APIs, meaning no
AssetKeyPartitionKey
orAssetSubset
, hence the somewhat weird shape of the AutomationConditionTesterResult object, and the fact that we just log the evaluation results rather than return them outright.This contains a single test at the moment, roughly indicating how a user might interface with this, but just wanted to put this out to assess the vibes on this type of pattern.
How I Tested These Changes