forked from dagster-io/dagster
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update test_perf.py to include asset checks (dagster-io#25382)
## Summary & Motivation As title. Copied from dagster-io#25302 ## How I Tested These Changes Run test_perf.py
- Loading branch information
Showing
2 changed files
with
72 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 44 additions & 13 deletions
57
...ster/dagster_tests/definitions_tests/declarative_automation_tests/perf_tests/test_perf.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,71 @@ | ||
import datetime | ||
import time | ||
|
||
from dagster import ( | ||
AutomationCondition, | ||
DagsterInstance, | ||
DailyPartitionsDefinition, | ||
Definitions, | ||
HourlyPartitionsDefinition, | ||
evaluate_automation_conditions, | ||
) | ||
from dagster._core.instance import DagsterInstance | ||
from dagster._core.definitions.automation_tick_evaluation_context import build_run_requests | ||
from dagster._time import get_current_datetime | ||
from dagster_test.toys.auto_materializing.large_graph import AssetLayerConfig, build_assets | ||
|
||
|
||
def test_eager_perf() -> None: | ||
def run_declarative_automation_perf_simulation(instance: DagsterInstance) -> None: | ||
hourly_partitions_def = HourlyPartitionsDefinition("2020-01-01-00:00") | ||
daily_partitions_def = DailyPartitionsDefinition("2020-01-01") | ||
assets = build_assets( | ||
id="perf_test", | ||
layer_configs=[ | ||
AssetLayerConfig(100, 0, hourly_partitions_def), | ||
AssetLayerConfig(200, 2, hourly_partitions_def), | ||
AssetLayerConfig(200, 4, hourly_partitions_def), | ||
AssetLayerConfig(200, 4, daily_partitions_def), | ||
AssetLayerConfig(200, 2, daily_partitions_def), | ||
AssetLayerConfig(50, 0, hourly_partitions_def), | ||
AssetLayerConfig(100, 2, hourly_partitions_def, n_checks_per_asset=1), | ||
AssetLayerConfig(100, 4, hourly_partitions_def, n_checks_per_asset=2), | ||
AssetLayerConfig(100, 4, daily_partitions_def, n_checks_per_asset=2), | ||
AssetLayerConfig(100, 2, daily_partitions_def), | ||
AssetLayerConfig(50, 2, daily_partitions_def), | ||
], | ||
automation_condition=AutomationCondition.eager(), | ||
automation_condition=AutomationCondition.eager() | ||
& AutomationCondition.all_deps_blocking_checks_passed(), | ||
) | ||
defs = Definitions(assets=assets) | ||
asset_job = defs.get_implicit_global_asset_job_def() | ||
|
||
instance = DagsterInstance.ephemeral() | ||
cursor = None | ||
start = time.time() | ||
for _ in range(2): | ||
cursor = evaluate_automation_conditions( | ||
defs=assets, instance=instance, cursor=cursor | ||
).cursor | ||
evaluation_time = get_current_datetime() - datetime.timedelta(days=1) | ||
for _ in range(3): | ||
result = evaluate_automation_conditions( | ||
defs=assets, instance=instance, cursor=cursor, evaluation_time=evaluation_time | ||
) | ||
cursor = result.cursor | ||
end = time.time() | ||
duration = end - start | ||
# all iterations should take less than 20 seconds on this graph | ||
assert duration < 20.0 | ||
|
||
# simulate the new events that would come from the requested runs | ||
run_requests = build_run_requests( | ||
entity_subsets=[r.true_subset for r in result.results], | ||
asset_graph=defs.get_asset_graph(), | ||
run_tags={}, | ||
emit_backfills=False, | ||
) | ||
for run_request in run_requests: | ||
asset_job.get_subset( | ||
asset_selection=set(run_request.asset_selection) | ||
if run_request.asset_selection | ||
else None, | ||
asset_check_selection=set(run_request.asset_check_keys) | ||
if run_request.asset_check_keys | ||
else None, | ||
).execute_in_process(instance=instance, partition_key=run_request.partition_key) | ||
|
||
evaluation_time += datetime.timedelta(hours=1) | ||
start = time.time() | ||
|
||
|
||
def test_eager_perf() -> None: | ||
run_declarative_automation_perf_simulation(DagsterInstance.ephemeral()) |