same thing as above.  I would also encapsulate the logic to get either a model or an ensemble (however it's implemented, either this way or with a None) in a separate function if possible (same thing for getting either a dataset or a source.