Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/ttsim/interface_dag_elements/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class FailIf(MainTargetABC):
input_df_mapper_has_incorrect_format: str = (
"fail_if__input_df_mapper_has_incorrect_format"
)
input_data_is_missing: str = "fail_if__input_data_is_missing"
non_convertible_objects_in_results_tree: str = (
"fail_if__non_convertible_objects_in_results_tree"
)
Expand Down
16 changes: 16 additions & 0 deletions src/ttsim/interface_dag_elements/fail_if.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,22 @@ def non_convertible_objects_in_results_tree(
raise ValueError(msg)


@fail_function(
include_if_any_element_present=[
"specialized_environment__tax_transfer_dag",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"specialized_environment__tax_transfer_dag",
"specialized_environment__tax_transfer_function",

My bad in the issue description. The DAG only requires the labels.

Copy link
Collaborator Author

@MImmesberger MImmesberger Jul 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this PR is just done with this change:

@fail_function(
    include_if_any_element_present=[
->      "raw_results__columns",
    ]
)
def root_nodes_are_missing(

I think it's just that the root_nodes_are_missing triggers to early. It shouldn't do
when just using specialized_environment__tax_transfer_dag as a target, and maybe it
also shouldn't when we target specialized_environment__tax_transfer_function.

Do we need input data for anything else than num_segments when creating the DAG or the
TT function? Both should be fine without, no? We could use the default for
num_segments then.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think that's it. Let's not worry too much.

The num_segments needs to be at least a large as the number of observations. But it is Jax-specific and we cannot check everything -- the probability that someone creates a function with some input data and then injects other data with Jax seems sufficiently small. Sort of similar to #966. If you feel like it, create an issue, but nothing to worry about now.

"raw_results__columns",
]
)
def input_data_is_missing(
input_data__flat: FlatData | None,
processed_data: QNameData | None,
) -> None:
"""Fail if input data is missing.

Triggers the `fail_if_root_nodes_are_missing` function if the input data is missing.
"""


@fail_function()
def input_df_has_bool_or_numeric_column_names(
input_data__df_and_mapper__df: pd.DataFrame,
Expand Down
13 changes: 13 additions & 0 deletions tests/ttsim/interface_dag_elements/test_failures.py
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,19 @@ def c(b):
)


def test_fail_if_input_data_is_missing_via_main(backend):
with pytest.raises(
ValueError,
match=r"\('input_data', 'flat'\)",
):
main(
main_target=MainTarget.specialized_environment.tax_transfer_dag,
date_str="2025-01-01",
orig_policy_objects={"root": METTSIM_ROOT},
backend=backend,
)


def test_fail_if_root_nodes_are_missing_asks_for_individual_level_columns(
minimal_input_data, backend
):
Expand Down
Loading