Skip to content

Commit

Permalink
config -> config_schema in calls
Browse files Browse the repository at this point in the history
Test Plan: bk

Reviewers: schrockn

Reviewed By: schrockn

Differential Revision: https://dagster.phacility.com/D3476
  • Loading branch information
sryza committed Jun 12, 2020
1 parent deb6d75 commit 4a39d23
Show file tree
Hide file tree
Showing 45 changed files with 135 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def emit_successful_expectation_no_metadata(_context):
@pipeline
def more_complicated_config():
@solid(
config={
config_schema={
'field_one': Field(String),
'field_two': Field(String, is_required=False),
'field_three': Field(String, is_required=False, default_value='some_value'),
Expand All @@ -272,7 +272,7 @@ def more_complicated_nested_config():
name='a_solid_with_multilayered_config',
input_defs=[],
output_defs=[],
config={
config_schema={
'field_any': Any,
'field_one': String,
'field_two': Field(String, is_required=False),
Expand Down Expand Up @@ -342,7 +342,7 @@ def hello_world_with_tags():
return solid_that_gets_tags()


@solid(name='solid_with_list', input_defs=[], output_defs=[], config=[int])
@solid(name='solid_with_list', input_defs=[], output_defs=[], config_schema=[int])
def solid_def(_):
return None

Expand Down Expand Up @@ -406,7 +406,7 @@ def return_any():
@pipeline
def pipeline_with_enum_config():
@solid(
config=Enum(
config_schema=Enum(
'TestEnum',
[
EnumValue(config_value='ENUM_VALUE_ONE', description='An enum value.'),
Expand Down Expand Up @@ -677,7 +677,7 @@ def retry_resource_pipeline():


@solid(
config={'fail': bool},
config_schema={'fail': bool},
input_defs=[InputDefinition('inp', str)],
output_defs=[
OutputDefinition(str, 'start_fail', is_required=False),
Expand Down Expand Up @@ -736,7 +736,7 @@ def return_one():
return 1

@solid(
config={'wait_to_terminate': bool},
config_schema={'wait_to_terminate': bool},
input_defs=[InputDefinition('one', Int)],
output_defs=[OutputDefinition(Int)],
)
Expand All @@ -747,7 +747,7 @@ def get_input_one(context, one):
return one

@solid(
config={'wait_to_terminate': bool},
config_schema={'wait_to_terminate': bool},
input_defs=[InputDefinition('one', Int)],
output_defs=[OutputDefinition(Int)],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def celery_mode_defs():
]


@solid(input_defs=[InputDefinition('word', String)], config={'factor': Int})
@solid(input_defs=[InputDefinition('word', String)], config_schema={'factor': Int})
def multiply_the_word(context, word):
return word * context.solid_config['factor']

Expand Down
4 changes: 2 additions & 2 deletions python_modules/dagster/dagster/config/config_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class Enum(ConfigType):
.. code-block:: python
@solid(
config=Field(
config_schema=Field(
Enum(
'CowboyType',
[
Expand Down Expand Up @@ -261,7 +261,7 @@ class Color(enum.Enum):
BLUE = enum.auto()
@solid(
config={"color": Field(Enum.from_python_enum(Color))}
config_schema={"color": Field(Enum.from_python_enum(Color))}
)
def select_color(context):
# ...
Expand Down
2 changes: 1 addition & 1 deletion python_modules/dagster/dagster/config/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class Field(object):
.. code-block::python
@solid(
config={
config_schema={
'word': Field(str, description='I am a word.'),
'repeats': Field(Int, default_value=1, is_required=False),
}
Expand Down
2 changes: 1 addition & 1 deletion python_modules/dagster/dagster/config/field_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class Selector(_ConfigHasFields):
.. code-block:: python
@solid(
config=Field(
config_schema=Field(
Selector(
{
'haw': {'whom': Field(String, default_value='honua', is_required=False)},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def hello_world(context, foo):
return foo
@solid(
config={'str_value' : Field(str)}
config_schema={'str_value' : Field(str)}
)
def hello_world(context, foo):
# context.solid_config is a dictionary with 'str_value' key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_basic_solids_config(snapshot):
name='required_field_solid',
input_defs=[],
output_defs=[],
config={'required_int': Int},
config_schema={'required_int': Int},
compute_fn=lambda *_args: fail_me(),
)
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ def return_int(context):
return context.solid_config

@composite_solid(
config={'number': int}, config_fn=lambda cfg: {'return_int': {'config': cfg['number'] + 1}},
config_schema={'number': int},
config_fn=lambda cfg: {'return_int': {'config': cfg['number'] + 1}},
)
def layer_three_wrap():
return_int()
Expand All @@ -140,7 +141,7 @@ def _layer_two_double_wrap_cfg_fn(cfg):
return {'layer_three_wrap': {'config': {'number': cfg['number'] + 1}}}

@composite_solid(
config={'number': int, 'inject_error': bool}, config_fn=_layer_two_double_wrap_cfg_fn
config_schema={'number': int, 'inject_error': bool}, config_fn=_layer_two_double_wrap_cfg_fn
)
def layer_two_double_wrap():
layer_three_wrap()
Expand Down Expand Up @@ -228,7 +229,7 @@ def add_one(_, num):
return num + 1

@composite_solid(
config={}, config_fn=lambda _cfg: {'add_one': {'inputs': {'num': {'value': 2}}}}
config_schema={}, config_fn=lambda _cfg: {'add_one': {'inputs': {'num': {'value': 2}}}}
)
def wrap_add_one():
add_one()
Expand All @@ -250,7 +251,9 @@ def test_double_nested_input_via_config_mapping():
def number(num):
return num

@composite_solid(config_fn=lambda _: {'number': {'inputs': {'num': {'value': 4}}}}, config={})
@composite_solid(
config_fn=lambda _: {'number': {'inputs': {'num': {'value': 4}}}}, config_schema={}
)
def wrap_solid(): # pylint: disable=unused-variable
return number()

Expand Down Expand Up @@ -278,7 +281,7 @@ def wrap_pipeline_double_nested_input():

def test_provide_one_of_two_inputs_via_config():
@solid(
config={'config_field_a': Field(String), 'config_field_b': Field(String)},
config_schema={'config_field_a': Field(String), 'config_field_b': Field(String)},
input_defs=[InputDefinition('input_a', String), InputDefinition('input_b', String)],
)
def basic(context, input_a, input_b):
Expand All @@ -303,7 +306,7 @@ def basic(context, input_a, input_b):
'inputs': {'input_b': {'value': 'set_input_b'}},
}
},
config={'config_field_a': Field(String), 'config_field_b': Field(String)},
config_schema={'config_field_a': Field(String), 'config_field_b': Field(String)},
)
def wrap_all_config_one_input(input_a):
return basic(input_a)
Expand Down Expand Up @@ -340,15 +343,15 @@ def required_scalar_config_solid(context):


@composite_solid(
config={'override_str': Field(String)},
config_schema={'override_str': Field(String)},
config_fn=lambda cfg: {'layer2': {'config': cfg['override_str']}},
)
def wrap():
return scalar_config_solid.alias('layer2')()


@composite_solid(
config={'nesting_override': Field(String)},
config_schema={'nesting_override': Field(String)},
config_fn=lambda cfg: {'layer1': {'config': {'override_str': cfg['nesting_override']}}},
)
def nesting_wrap():
Expand Down Expand Up @@ -383,14 +386,14 @@ def get_fully_unwrapped_config():

def test_direct_composite_descent_with_error():
@composite_solid(
config={'override_str': Field(int)},
config_schema={'override_str': Field(int)},
config_fn=lambda cfg: {'layer2': {'config': cfg['override_str']}},
)
def wrap_coerce_to_wrong_type():
return scalar_config_solid.alias('layer2')()

@composite_solid(
config={'nesting_override': Field(int)},
config_schema={'nesting_override': Field(int)},
config_fn=lambda cfg: {'layer1': {'config': {'override_str': cfg['nesting_override']}}},
)
def nesting_wrap_wrong_type_at_leaf():
Expand Down Expand Up @@ -456,7 +459,7 @@ def return_enum(context):
return context.solid_config['enum']

@composite_solid(
config={'num': int},
config_schema={'num': int},
config_fn=lambda cfg: {
'return_enum': {'config': {'enum': 'VALUE_ONE' if cfg['num'] == 1 else 'OTHER'}}
},
Expand Down Expand Up @@ -489,7 +492,7 @@ def return_int(context):
return context.solid_config['num']

@composite_solid(
config={'enum': DagsterEnumType},
config_schema={'enum': DagsterEnumType},
config_fn=lambda cfg: {
'return_int': {'config': {'num': 1 if cfg['enum'] == TestPythonEnum.VALUE_ONE else 2}}
},
Expand Down
Loading

0 comments on commit 4a39d23

Please sign in to comment.