Skip to content

Commit

Permalink
move dict_without_keys to dagster.utils
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidKatz-il committed Sep 7, 2020
1 parent d53f5b2 commit c5ea429
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
4 changes: 4 additions & 0 deletions python_modules/dagster/dagster/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,3 +517,7 @@ def compose(*args):
# reduce using functional composition over all the arguments, with the identity function as
# initializer
return functools.reduce(lambda f, g: lambda x: f(g(x)), args, lambda x: x)


def dict_without_keys(ddict, *keys):
return {key: value for key, value in ddict.items() if key not in set(keys)}
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,12 @@
dagster_type_materializer,
)
from dagster.config.field_utils import Selector
from dagster.utils import dict_without_keys
from dagster.utils.backcompat import canonicalize_backcompat_args, experimental

CONSTRAINT_BLACKLIST = {ColumnDTypeFnConstraint, ColumnDTypeInSetConstraint}


def dict_without_keys(ddict, *keys):
return {key: value for key, value in ddict.items() if key not in set(keys)}


@dagster_type_materializer(
Selector(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from dagster.config.field_utils import Selector
from dagster.core.storage.system_storage import fs_intermediate_storage, fs_system_storage
from dagster.core.storage.type_storage import TypeStoragePlugin
from dagster.utils import dict_without_keys

WriteModeOptions = Enum(
"WriteMode",
Expand Down Expand Up @@ -75,10 +76,6 @@
)


def dict_without_keys(ddict, *keys):
return {key: value for key, value in ddict.items() if key not in set(keys)}


@dagster_type_materializer(
Selector(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
file_relative_path,
solid,
)
from dagster.utils import dict_without_keys
from dagster.utils.test import get_temp_dir

spark = SparkSession.builder.getOrCreate()
Expand All @@ -28,10 +29,6 @@
]


def dict_without_keys(ddict, *keys):
return {key: value for key, value in ddict.items() if key not in set(keys)}


def create_pyspark_df():
data = [Row(_c0=str(i), _c1=str(i)) for i in range(100)]
return spark.createDataFrame(data)
Expand Down

0 comments on commit c5ea429

Please sign in to comment.