Description
(This PEP was originally attached to the [WIP] PR #1386)
Summary/Motivation:
In #1383 @qtothec asked if we could return a more helpful return value from TransformationFactory()
when the requested transformation was not found. Currently, the Factory returns None
for unknown transformations, and it is the responsibility of the user to check that before attempting to apply the transformation. As users typically do not bother with the check, they end up getting less informative errors like:
AttributeError: 'NoneType' object has no attribute 'apply_to'
In PR #1386, we explored adding an "UnknownTransformation" object to be returned by the Transformation Factory, to follow the pattern started by the Solver Factory. The consensus of subsequent discussions was that the "default" behavior of Factories was actually undesirable and that Factories should be more assertive when a user requests an unknown object.
Proposal
-
All Factories (Solver, Transformation, Writer) should raise exceptions when the named object is not known / registered.
-
We will remove the "implicit NL solver behavior" (whereby 'unknown' names that correspond to executables in the PATH are assumed to be ASL solvers) entirely.
- For backwards compatibility, we will add explicit alias registrations to known common ASL solvers (e.g., COIN-OR solvers).
- the previous "implicit" behavior will be supported (and documented) by prefacing the executable name with "
asl:
" (e.g., "asl:ipopt
" would be the ipopt solver through the generic ASL interface, and would be different from the "ipopt
" solver, which is an interface customized for ipopt. - To ease the transition, we will continue to support implicit solvers (and only solvers) that emits a deprecation warning.