Skip to content

is_missing methods for variables

Wout De Nolf requested to merge missing_variables into main

To check in the task run method whether an input or output is missing, you can do either of these things:

  1. self.inputs.myvar is self.MISSING_DATA: problem when MISSING_DATA gets copied somehow
  2. self.inputs.myvar == self.MISSING_DATA: problem when for example a numpy array

The best check is this

  1. isinstance(self.inputs.myvar, hashing.MissingData)

This MR adds helpers to the Task class to do this:

class MyTask(Task, input_names=["a"]):
    def run(self):
        # missing namespace
        if self.missing_inputs.a:
            ...
        else:
            ...

        # getter with default when missing
        value = self.get_input_value("a", default=10)
Edited by Wout De Nolf

Merge request reports