Ticket #8979 (closed: fixed)

Opened 7 years ago

Last modified 5 years ago

Expose ValidateInputs for python algorithms

Reported by: Peter Peterson Owned by: Peter Peterson
Priority: major Milestone: Release 3.2
Component: Python Keywords:
Cc: martyn.gigg@… Blocked By:
Blocking: Tester: Martyn Gigg

Description

It has been pointed out by scientists that this extra level of checking and error reporting would be useful. It is also a prerequisite for #8495 to get done.

Change History

comment:1 Changed 7 years ago by Peter Peterson

  • Blocking 8495 removed

comment:2 Changed 7 years ago by Peter Peterson

  • Status changed from new to inprogress

Re #8979. Adding validateInputs to AlgorithmWrapper.

Changeset: c5109ce3c85fb7f16d259aca687be3e2df2ea2fb

comment:3 Changed 7 years ago by Peter Peterson

  • Status changed from inprogress to verify
  • Resolution set to fixed
  • Tester set to Martyn Gigg

This is on feature/8979_validate_inputs.

To Test: Pick a python algorithm and try these three variants:

  • Run it and see that everything is ok
  • Add a "validateInputs" method that returns an empty dictionary. Again, everything should be fine.
  • Fill in some cursory amount of error checking in "validateInputs" and see that the gui marks the appropriate parameters.

comment:4 Changed 7 years ago by Martyn Gigg

  • Status changed from verify to verifying

comment:5 Changed 7 years ago by Martyn Gigg

  • Status changed from verifying to reopened
  • Resolution fixed deleted

Tested with empty dict, single pair & multiple pairs and all expected properties were marked with the error markers.

I also tried with putting a non-string type as a value and it silently ignores it. I wonder if we should show a warning/error in the results log to indicate to the dev that something is wrong? Maybe something like this as a minor modification for the current loop at line 97?

      for (size_t i = 0; i < numItems; ++i)
      {
        boost::python::object value = resultDict[keys[i]];
        try
        {
          std::string key = boost::python::extract<std::string>(keys[i]);
          std::string value = boost::python::extract<std::string>(resultDict[keys[i]]);
          resultMap[key] = value;
        }
        catch(boost::python::error_already_set&)
        {
          this->getLogger().error("validateInputs() - Incorrect type for key/value pair detected in dict. "
                                  "All keys & values must be strings");
        }
      }

comment:6 Changed 7 years ago by Peter Peterson

  • Status changed from reopened to inprogress

Re #8979. Protecting against non-string types in the dict.

Changeset: f6a4357ddb7cbc724e3d2c8c5d0064b10545178f

comment:7 Changed 7 years ago by Peter Peterson

  • Status changed from inprogress to verify
  • Resolution set to fixed

comment:8 Changed 7 years ago by Martyn Gigg

  • Status changed from verify to verifying

comment:9 Changed 7 years ago by Martyn Gigg

  • Status changed from verifying to closed

Merge remote-tracking branch 'origin/feature/8979_validate_inputs'

Full changeset: c819ea8fdaf0885dface461b377503f96849c1c2

comment:10 Changed 5 years ago by Stuart Campbell

This ticket has been transferred to github issue 9822

Note: See TracTickets for help on using tickets.