示例#1
0
def test_config_from_files():
    run_config = config_from_files(config_files=[
        file_relative_path(__file__, "./definitions_tests/pass_env.yaml")
    ])

    assert run_config == {"solids": {"can_fail": {"config": {"error": False}}}}

    with pytest.raises(DagsterInvariantViolationError):
        config_from_files(
            config_files=[file_relative_path(__file__, "not_a_file.yaml")])

    with pytest.raises(DagsterInvariantViolationError):
        config_from_files(config_files=[
            file_relative_path(
                __file__, "./definitions_tests/test_repository_definition.py")
        ])
示例#2
0
def test_config_from_files():
    run_config = config_from_files(config_files=[
        file_relative_path(__file__, './definitions_tests/pass_env.yaml')
    ])

    assert run_config == {'solids': {'can_fail': {'config': {'error': False}}}}

    with pytest.raises(DagsterInvariantViolationError):
        config_from_files(
            config_files=[file_relative_path(__file__, 'not_a_file.yaml')])

    with pytest.raises(DagsterInvariantViolationError):
        config_from_files(config_files=[
            file_relative_path(
                __file__, './definitions_tests/test_repository_definition.py')
        ])
示例#3
0
文件: preset.py 项目: prezi/dagster
    def from_files(name,
                   config_files=None,
                   solid_selection=None,
                   mode=None,
                   tags=None):
        """Static constructor for presets from YAML files.

        Args:
            name (str): The name of this preset. Must be unique in the presets defined on a given
                pipeline.
            config_files (Optional[List[str]]): List of paths or glob patterns for yaml files
                to load and parse as the run config for this preset.
            solid_selection (Optional[List[str]]): A list of solid subselection (including single
                solid names) to execute with the preset. e.g. ``['*some_solid+', 'other_solid']``
            mode (Optional[str]): The mode to apply when executing this preset. (default:
                'default')
            tags (Optional[Dict[str, Any]]): The tags to apply when executing this preset.

        Returns:
            PresetDefinition: A PresetDefinition constructed from the provided YAML files.

        Raises:
            DagsterInvariantViolationError: When one of the YAML files is invalid and has a parse
                error.
        """
        check.str_param(name, "name")
        config_files = check.opt_list_param(config_files, "config_files")
        solid_selection = check.opt_nullable_list_param(solid_selection,
                                                        "solid_selection",
                                                        of_type=str)
        mode = check.opt_str_param(mode, "mode", DEFAULT_MODE_NAME)

        merged = config_from_files(config_files)

        return PresetDefinition(name, merged, solid_selection, mode, tags)