コード例 #1
0
ファイル: test_check.py プロジェクト: trevenrawr/dagster
def test_opt_sequence_param():

    assert check.opt_sequence_param([], "sequence_param") == []
    assert check.opt_sequence_param(tuple(), "sequence_param") == tuple()

    assert check.opt_sequence_param(["foo"], "sequence_param",
                                    of_type=str) == ["foo"]
    assert check.opt_sequence_param("foo", "sequence_param") == "foo"
    assert check.opt_sequence_param("foo", "sequence_param",
                                    of_type=str) == "foo"

    assert check.opt_sequence_param(None, "sequence_param") == []

    with pytest.raises(CheckError):
        check.opt_sequence_param(1, "sequence_param",
                                 of_type=int)  # type: ignore

    with pytest.raises(CheckError):
        check.opt_sequence_param(["foo"], "sequence_param", of_type=int)
コード例 #2
0
 def __new__(
     cls,
     asset_key: AssetKey,
     dependencies: Sequence[ExternalAssetDependency],
     depended_by: Sequence[ExternalAssetDependedBy],
     compute_kind: Optional[str] = None,
     op_name: Optional[str] = None,
     op_description: Optional[str] = None,
     job_names: Optional[Sequence[str]] = None,
     partitions_def_data: Optional[ExternalPartitionsDefinitionData] = None,
     output_name: Optional[str] = None,
     output_description: Optional[str] = None,
     metadata_entries: Optional[Sequence[MetadataEntry]] = None,
 ):
     return super(ExternalAssetNode, cls).__new__(
         cls,
         asset_key=check.inst_param(asset_key, "asset_key", AssetKey),
         dependencies=check.opt_sequence_param(
             dependencies, "dependencies", of_type=ExternalAssetDependency),
         depended_by=check.opt_sequence_param(
             depended_by, "depended_by", of_type=ExternalAssetDependedBy),
         compute_kind=check.opt_str_param(compute_kind, "compute_kind"),
         op_name=check.opt_str_param(op_name, "op_name"),
         op_description=check.opt_str_param(
             op_description or output_description, "op_description"),
         job_names=check.opt_sequence_param(job_names,
                                            "job_names",
                                            of_type=str),
         partitions_def_data=check.opt_inst_param(
             partitions_def_data, "partitions_def_data",
             ExternalPartitionsDefinitionData),
         output_name=check.opt_str_param(output_name, "output_name"),
         output_description=check.opt_str_param(output_description,
                                                "output_description"),
         metadata_entries=check.opt_sequence_param(metadata_entries,
                                                   "metadata_entries",
                                                   of_type=MetadataEntry),
     )
コード例 #3
0
 def __new__(
     cls,
     name: str,
     external_pipeline_datas: Sequence["ExternalPipelineData"],
     external_schedule_datas: Sequence["ExternalScheduleData"],
     external_partition_set_datas: Sequence["ExternalPartitionSetData"],
     external_sensor_datas: Optional[Sequence["ExternalSensorData"]] = None,
     external_asset_graph_data: Optional[
         Sequence["ExternalAssetNode"]] = None,
 ):
     return super(ExternalRepositoryData, cls).__new__(
         cls,
         name=check.str_param(name, "name"),
         external_pipeline_datas=check.sequence_param(
             external_pipeline_datas,
             "external_pipeline_datas",
             of_type=ExternalPipelineData),
         external_schedule_datas=check.sequence_param(
             external_schedule_datas,
             "external_schedule_datas",
             of_type=ExternalScheduleData),
         external_partition_set_datas=check.sequence_param(
             external_partition_set_datas,
             "external_partition_set_datas",
             of_type=ExternalPartitionSetData,
         ),
         external_sensor_datas=check.opt_sequence_param(
             external_sensor_datas,
             "external_sensor_datas",
             of_type=ExternalSensorData,
         ),
         external_asset_graph_data=check.opt_sequence_param(
             external_asset_graph_data,
             "external_asset_graph_dats",
             of_type=ExternalAssetNode,
         ),
     )
コード例 #4
0
    def __new__(
        cls,
        assets: Sequence[AssetsDefinition],
        source_assets: Optional[Sequence[SourceAsset]] = None,
        resource_defs: Optional[Mapping[str, ResourceDefinition]] = None,
        executor_def: Optional[ExecutorDefinition] = None,
    ):
        check.sequence_param(assets, "assets", of_type=AssetsDefinition)
        source_assets = check.opt_sequence_param(source_assets,
                                                 "source_assets",
                                                 of_type=SourceAsset)
        resource_defs = check.opt_mapping_param(resource_defs,
                                                "resource_defs",
                                                key_type=str,
                                                value_type=ResourceDefinition)
        executor_def = check.opt_inst_param(executor_def, "executor_def",
                                            ExecutorDefinition)

        source_assets_by_key = build_source_assets_by_key(source_assets)
        root_manager = build_root_manager(source_assets_by_key)

        if "root_manager" in resource_defs:
            raise DagsterInvalidDefinitionError(
                "Resource dictionary included resource with key 'root_manager', "
                "which is a reserved resource keyword in Dagster. Please change "
                "this key, and then change all places that require this key to "
                "a new value.")
        # In the case of collisions, merge_dicts takes values from the
        # dictionary latest in the list, so we place the user provided resource
        # defs after the defaults.
        resource_defs = merge_dicts(
            {
                "root_manager": root_manager,
                "io_manager": fs_asset_io_manager
            },
            resource_defs,
        )

        _validate_resource_reqs_for_asset_group(asset_list=assets,
                                                source_assets=source_assets,
                                                resource_defs=resource_defs)

        return super(AssetGroup, cls).__new__(
            cls,
            assets=assets,
            source_assets=source_assets,
            resource_defs=resource_defs,
            executor_def=executor_def,
        )
コード例 #5
0
ファイル: solid.py プロジェクト: trevenrawr/dagster
 def __new__(
     cls,
     name: str,
     dagster_type_key: str,
     description: Optional[str],
     is_required: bool,
     metadata_entries: Optional[Sequence[MetadataEntry]] = None,
     is_dynamic: bool = False,
 ):
     return super(OutputDefSnap, cls).__new__(
         cls,
         name=check.str_param(name, "name"),
         dagster_type_key=check.str_param(dagster_type_key,
                                          "dagster_type_key"),
         description=check.opt_str_param(description, "description"),
         is_required=check.bool_param(is_required, "is_required"),
         metadata_entries=check.opt_sequence_param(metadata_entries,
                                                   "metadata_entries",
                                                   of_type=MetadataEntry),
         is_dynamic=check.bool_param(is_dynamic, "is_dynamic"),
     )