コード例 #1
0
    def from_dict(cls, d: Dict[str, Any]) -> "DbtResult":
        """Constructs an instance of :class:`DbtResult <dagster_dbt.DbtResult>` from a dictionary.

        Args:
            d (Dict[str, Any]): A dictionary with key-values to construct a :class:`DbtResult
                <dagster_dbt.DbtResult>`.

        Returns:
            DbtResult: An instance of :class:`DbtResult <dagster_dbt.DbtResult>`.
        """
        check.list_elem(d, "logs")
        logs = check.is_list(d["logs"], of_type=Dict)
        check.list_elem(d, "results")
        results = [
            NodeResult.from_dict(d)
            for d in check.is_list(d["results"], of_type=Dict)
        ]
        generated_at = check.str_elem(d, "generated_at")
        elapsed_time = check.float_elem(d, "elapsed_time")

        return cls(
            logs=logs,
            results=results,
            generated_at=generated_at,
            elapsed_time=elapsed_time,
        )
コード例 #2
0
    def from_dict(cls, d: Dict[str, Any]) -> "NodeResult":
        """Constructs an instance of :class:`NodeResult <dagster_dbt.NodeResult>` from a dictionary.

        Args:
            d (Dict[str, Any]): A dictionary with key-values to construct a :class:`NodeResult
                <dagster_dbt.NodeResult>`.

        Returns:
            NodeResult: An instance of :class:`NodeResult <dagster_dbt.NodeResult>`.
        """
        node = check.dict_elem(d, "node")
        error = check.opt_str_elem(d, "error")
        execution_time = check.float_elem(d, "execution_time")
        thread_id = check.opt_str_elem(d, "thread_id")
        check.list_elem(d, "timing")
        step_timings = [
            StepTiming(
                name=d["name"],
                started_at=parser.isoparse(d["started_at"]),
                completed_at=parser.isoparse(d["completed_at"]),
            )
            for d in check.is_list(d["timing"], of_type=Dict)
        ]
        table = check.opt_dict_elem(d, "table")

        return cls(
            step_timings=step_timings,
            node=node,
            error=error,
            execution_time=execution_time,
            thread_id=thread_id,
            table=table,
        )
コード例 #3
0
    def from_dict(cls, d: Dict[str, Any]) -> "NodeResult":
        """Constructs an instance of :class:`NodeResult <dagster_dbt.NodeResult>` from a dictionary.

        Args:
            d (Dict[str, Any]): A dictionary with key-values to construct a :class:`NodeResult
                <dagster_dbt.NodeResult>`.

        Returns:
            NodeResult: An instance of :class:`NodeResult <dagster_dbt.NodeResult>`.
        """
        check.dict_elem(d, "node")
        check.opt_str_elem(d, "error")
        check.float_elem(d, "execution_time")
        check.opt_str_elem(d, "thread_id")
        check.list_elem(d, "timing")
        check.is_list(d["timing"], of_type=Dict)
        check.opt_dict_elem(d, "table")

        return cls(step_timings=d.get("timing"), **d)
コード例 #4
0
ファイル: types.py プロジェクト: nuruladroady/dagster
    def from_dict(cls, d: Dict[str, Any]) -> "DbtRpcOutput":
        """Constructs an instance of :class:`DbtRpcOutput <dagster_dbt.DbtRpcOutput>` from a
        dictionary.

        Args:
            d (Dict[str, Any]): A dictionary with key-values to construct a :class:`DbtRpcOutput
                <dagster_dbt.DbtRpcOutput>`.

        Returns:
            DbtRpcOutput: An instance of :class:`DbtRpcOutput <dagster_dbt.DbtRpcOutput>`.
        """
        check.str_elem(d, "state")
        check.str_elem(d, "start")
        check.str_elem(d, "end")
        check.float_elem(d, "elapsed")

        d["result"] = DbtResult.from_dict(d)

        return cls(**d)
コード例 #5
0
ファイル: test_check.py プロジェクト: nuruladroady/dagster
def test_float_elem():
    ddict = {"a_bool": True, "a_float": 1.0, "a_int": 1, "a_none": None, "a_str": "a"}

    assert check.float_elem(ddict, "a_float") == 1.0

    with pytest.raises(ElementCheckError):
        check.float_elem(ddict, "a_bool")

    with pytest.raises(ElementCheckError):
        check.float_elem(ddict, "a_int")

    with pytest.raises(ElementCheckError):
        check.float_elem(ddict, "a_none")

    with pytest.raises(ElementCheckError):
        check.float_elem(ddict, "a_str")
コード例 #6
0
ファイル: types.py プロジェクト: zuik/dagster
    def from_dict(cls, d: Dict[str, Any]) -> "DbtRpcOutput":
        """Constructs an instance of :class:`DbtRpcOutput <dagster_dbt.DbtRpcOutput>` from a
        dictionary.

        Args:
            d (Dict[str, Any]): A dictionary with key-values to construct a :class:`DbtRpcOutput
                <dagster_dbt.DbtRpcOutput>`.

        Returns:
            DbtRpcOutput: An instance of :class:`DbtRpcOutput <dagster_dbt.DbtRpcOutput>`.
        """
        state = check.str_elem(d, "state")
        start = check.str_elem(d, "start")
        end = check.str_elem(d, "end")
        elapsed = check.float_elem(d, "elapsed")

        result = DbtResult.from_dict(d)

        return cls(result=result, state=state, start=start, end=end, elapsed=elapsed)
コード例 #7
0
    def from_dict(cls, d: Dict[str, Any]) -> "NodeResult":
        """Constructs an instance of :class:`NodeResult <dagster_dbt.NodeResult>` from a dictionary.

        Args:
            d (Dict[str, Any]): A dictionary with key-values to construct a :class:`NodeResult
                <dagster_dbt.NodeResult>`.

        Returns:
            NodeResult: An instance of :class:`NodeResult <dagster_dbt.NodeResult>`.
        """
        # When executing from the CLI in 0.19.x, we get unique_id as a top level attribute
        if "unique_id" in d:
            unique_id = check.str_elem(d, "unique_id")
            node = None
        # When executing via RPC server or via CLI in 0.18.x or lower, we get unique id within
        # "node" schema
        else:
            node = check.dict_elem(d, "node")
            unique_id = check.str_elem(node, "unique_id")
        error = check.opt_str_elem(d, "error")
        execution_time = check.float_elem(d, "execution_time")
        thread_id = check.opt_str_elem(d, "thread_id")
        check.list_elem(d, "timing")
        step_timings = [
            StepTiming(
                name=d["name"],
                started_at=parser.isoparse(d["started_at"]),
                completed_at=parser.isoparse(d["completed_at"]),
            ) for d in check.is_list(d["timing"], of_type=Dict)
        ]
        table = check.opt_dict_elem(d, "table")

        return cls(
            node=node,
            unique_id=unique_id,
            step_timings=step_timings,
            error=error,
            execution_time=execution_time,
            thread_id=thread_id,
            table=table,
        )