Skip to content

Commit

Permalink
Back-compat fix for AllSelection field addition (#19677)
Browse files Browse the repository at this point in the history
This needs to have a null initializer to be deserialized

Test Plan:
Test that was failing before in master (but only on pydantic 2, which is
why my testing didn't catch it, sigh)
  • Loading branch information
gibsondan committed Feb 8, 2024
1 parent 2f54307 commit 921c41c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ def operand__str__(self) -> str:

@whitelist_for_serdes
class AllSelection(AssetSelection, frozen=True):
include_sources: Optional[bool]
include_sources: Optional[bool] = None

def resolve_inner(self, asset_graph: AssetGraph) -> AbstractSet[AssetKey]:
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from dagster._core.definitions.asset_graph import AssetGraph
from dagster._core.definitions.asset_selection import (
AllAssetCheckSelection,
AllSelection,
AndAssetSelection,
AssetCheckKeysSelection,
AssetChecksForAssetKeysSelection,
Expand All @@ -40,6 +41,7 @@
)
from dagster._core.definitions.assets import AssetsDefinition
from dagster._core.definitions.events import AssetKey
from dagster._serdes import deserialize_value
from dagster._serdes.serdes import _WHITELIST_MAP
from pydantic import ValidationError
from typing_extensions import TypeAlias
Expand Down Expand Up @@ -699,3 +701,9 @@ def test_to_string_binary_operators():
def test_empty_namedtuple_truthy():
# namedtuples with no fields are still truthy
assert bool(AllAssetCheckSelection.all())


def test_deserialize_old_all_asset_selection():
old_serialized_value = '{"__class__": "AllSelection"}'
new_unserialized_value = deserialize_value(old_serialized_value, AllSelection)
assert not new_unserialized_value.include_sources

0 comments on commit 921c41c

Please sign in to comment.