datalad / datalad-gooey

A graphical user interface for DataLad (datalad.org)
https://docs.datalad.org/projects/gooey
Other
4 stars 6 forks source link

EnsureDataset too strong, preventing calling dataset methods from DataLad menu #304

Closed mslw closed 1 year ago

mslw commented 1 year ago

This is an evil twin of #298 introduced in 7aedf35eec1f87a098a64f8e584cc9f0d1de2eaa - now we can't call dataset methods from DataLad menu:

Traceback (most recent call last):
  File "/home/mszczepanik/Documents/datalad-gooey/datalad_gooey/dataladcmd_ui.py", line 105, in configure
    self._parameters = populate_form_w_params(
  File "/home/mszczepanik/Documents/datalad-gooey/datalad_gooey/param_form_utils.py", line 148, in populate_form_w_params
    p[1].set_from_spec(cmdkwargs_defaults)
  File "/home/mszczepanik/Documents/datalad-gooey/datalad_gooey/param.py", line 191, in set_from_spec
    self.set(spec[self.__name])
  File "/home/mszczepanik/Documents/datalad-gooey/datalad_gooey/param.py", line 163, in set
    val = self.get_constraint()(value) if value != _NoValue else value
  File "/home/mszczepanik/Documents/datalad-gooey/datalad_gooey/constraints.py", line 318, in __call__
    raise ValueError("Can't create Dataset from %s." % type(value))
ValueError: Can't create Dataset from <class 'NoneType'>.

Looks like only a minor change is needed to allow None, but I'm not quite sure at which stage (Dataset can be None at first, but not when we start setting it).

mih commented 1 year ago

Indeed, thanks for reporting. It needs to be EnsureDataset() | EnsureNone()