Skip to content

Commit

Permalink
Make AssetGraphSubset and AssetBackfillData serializable
Browse files Browse the repository at this point in the history
  • Loading branch information
clairelin135 committed Nov 13, 2023
1 parent 71ba29e commit 79652f9
Show file tree
Hide file tree
Showing 13 changed files with 335 additions and 182 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def get_asset_backfill_preview(

asset_partitions = []

for asset_key in asset_backfill_data.get_targeted_asset_keys_topological_order():
for asset_key in asset_backfill_data.get_targeted_asset_keys_topological_order(asset_graph):
if asset_graph.get_partitions_def(asset_key):
partitions_subset = asset_backfill_data.target_subset.partitions_subsets_by_asset_key[
asset_key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,9 @@ def test_launch_asset_backfill_all_partitions_asset_selection():
target_subset.get_partitions_subset(AssetKey("asset2")).get_partition_keys()
== all_partition_keys
)
assert not target_subset.get_partitions_subset(AssetKey("asset1")).get_partition_keys()
assert not target_subset.get_partitions_subset(
AssetKey("asset1"), asset_graph=repo.asset_graph
).get_partition_keys()


def test_launch_asset_backfill_partitions_by_asset():
Expand Down Expand Up @@ -536,9 +538,8 @@ def test_launch_asset_backfill_with_upstream_anchor_asset():
launch_backfill_result, instance, repo
)
target_subset = asset_backfill_data.target_subset
asset_graph = target_subset.asset_graph
asset_graph = repo.asset_graph
assert target_subset == AssetGraphSubset(
target_subset.asset_graph,
partitions_subsets_by_asset_key={
AssetKey("hourly"): asset_graph.get_partitions_def(
AssetKey("hourly")
Expand Down Expand Up @@ -605,9 +606,8 @@ def test_launch_asset_backfill_with_two_anchor_assets():
launch_backfill_result, instance, repo
)
target_subset = asset_backfill_data.target_subset
asset_graph = target_subset.asset_graph
asset_graph = repo.asset_graph
assert target_subset == AssetGraphSubset(
target_subset.asset_graph,
partitions_subsets_by_asset_key={
AssetKey("hourly1"): asset_graph.get_partitions_def(
AssetKey("hourly1")
Expand Down Expand Up @@ -663,9 +663,8 @@ def test_launch_asset_backfill_with_upstream_anchor_asset_and_non_partitioned_as
launch_backfill_result, instance, repo
)
target_subset = asset_backfill_data.target_subset
asset_graph = target_subset.asset_graph
asset_graph = repo.asset_graph
assert target_subset == AssetGraphSubset(
target_subset.asset_graph,
non_partitioned_asset_keys={AssetKey("non_partitioned")},
partitions_subsets_by_asset_key={
AssetKey("hourly"): (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ def _execute_asset_backfill_iteration_no_side_effects(
updated_backfill = backfill.with_asset_backfill_data(
cast(AssetBackfillIterationResult, result).backfill_data,
dynamic_partitions_store=graphql_context.instance,
asset_graph=asset_graph,
)
graphql_context.instance.update_backfill(updated_backfill)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -574,20 +574,19 @@ def bfs_filter_subsets(

queued_subsets_by_asset_key: Dict[AssetKey, Optional[PartitionsSubset]] = {
initial_asset_key: (
initial_subset.get_partitions_subset(initial_asset_key)
initial_subset.get_partitions_subset(initial_asset_key, self)
if self.get_partitions_def(initial_asset_key)
else None
),
}
result = AssetGraphSubset(self)
result = AssetGraphSubset()

while len(queue) > 0:
asset_key = queue.popleft()
partitions_subset = queued_subsets_by_asset_key.get(asset_key)

if condition_fn(asset_key, partitions_subset):
result |= AssetGraphSubset(
self,
non_partitioned_asset_keys={asset_key} if partitions_subset is None else set(),
partitions_subsets_by_asset_key=(
{asset_key: partitions_subset} if partitions_subset is not None else {}
Expand Down
Loading

0 comments on commit 79652f9

Please sign in to comment.