Here is a github issue and solution that I saw the other day. I think it’s a nice pattern.

def generate_model(values={'mu': true_param, 'm': None}): #prior mu = pymc.Uniform("mu", lower=-10, upper=10, value=values['mu'], observed=(values['mu'] is not None)) # likelihood function m = pymc.Normal("m", mu=mu, tau=tau, value=values['m'], observed=(values['m'] is not None)) return locals()