def test_double_type(): @solid(config_field=Field(NamedDict('Name', {'some_field': Field(String)}))) def solid_one(_context): raise Exception('should not execute') @solid(config_field=Field(NamedDict('Name', {'some_field': Field(String)}))) def solid_two(_context): raise Exception('should not execute') with pytest.raises(DagsterInvalidDefinitionError, match='Type names must be unique.'): PipelineDefinition(solids=[solid_one, solid_two])
def test_all_types_provided(): pipeline_def = PipelineDefinition( name='pipeline', solid_defs=[], mode_defs=[ ModeDefinition( name='SomeMode', resource_defs={ 'some_resource': ResourceDefinition( lambda: None, config_field=Field( NamedDict( 'SomeModeNamedDict', { 'with_default_int': Field( Int, is_optional=True, default_value=23434 ) }, ) ), ) }, ) ], ) environment_schema = create_environment_schema(pipeline_def) all_types = list(environment_schema.all_config_types()) type_names = set(t.name for t in all_types) assert 'SomeModeNamedDict' in type_names assert 'Pipeline.Mode.SomeMode.Environment' in type_names assert 'Pipeline.Mode.SomeMode.Resources.SomeResource' in type_names
def test_all_types_provided(): pipeline_def = PipelineDefinition( name='pipeline', solids=[], context_definitions={ 'some_context': PipelineContextDefinition( config_field=Field( NamedDict( 'SomeContextNamedDict', { 'with_default_int': Field(Int, is_optional=True, default_value=23434) }, )), context_fn=lambda *args: None, ) }, ) all_types = list(pipeline_def.all_config_types()) type_names = set(t.name for t in all_types) assert 'SomeContextNamedDict' in type_names assert 'Pipeline.ContextDefinitionConfig.SomeContext' in type_names assert 'Pipeline.ContextDefinitionConfig.SomeContext.Resources' in type_names
def test_double_type_name(): @solid(config_field=Field(NamedDict('SomeTypeName', {'some_field': Field(String)}))) def solid_one(_context): raise Exception('should not execute') @solid(config_field=Field(NamedDict('SomeTypeName', {'another_field': Field(String)}))) def solid_two(_context): raise Exception('should not execute') with pytest.raises(DagsterInvalidDefinitionError) as exc_info: create_environment_schema(PipelineDefinition(solid_defs=[solid_one, solid_two])) assert str(exc_info.value) == ( 'Type names must be unique. You have constructed two different instances of ' 'types with the same name "SomeTypeName".' )
def test_invalid_named_dict_field(): with pytest.raises(DagsterInvalidDefinitionError) as exc_info: NamedDict('some_named_dict', {'val': Int, 'another_val': Field(Int)}) assert str(exc_info.value) == ( 'You have passed a config type "Int" in the parameter "fields" and it is ' 'in the "val" entry of that dict. It is from a NamedDict named ' '"some_named_dict" with fields [\'another_val\', \'val\']. You ' 'have likely forgot to wrap this type in a Field.')