I hope this is the explicit example that you are missing.
In SimplePipelineExecutor — LSST Science Pipelines :
Most callers should use one of the
classmethodfactory functions (from_pipeline_filename,from_task_class,from_pipeline) instead of invoking the constructor directly; these guarantee that theButlerandQuantumGraphare created consistently.
Wherever you see pipetask run -b BUTLER_REPO -p PIPELINE_YAML -i INPUT_COLLECTIONS -o OUTPUT_COLLECTION -d DATA_QUERY -c LABEL:KEY=VALUE, you can instead do:
from lsst.ctrl.mpexec import SimplePipelineExecutor
from lsst.pipe.base import Pipeline
butler = SimplePipelineExecutor.prep_butler(BUTLER_REPO, inputs=[INPUT_COLLECTIONS], output=OUTPUT_COLLECTION)
pipeline = Pipeline.from_uri(PIPELINE_YAML)
pipeline.addConfigOverride(LABEL, KEY, VALUE)
spe = SimplePipelineExecutor.from_pipeline(pipeline, where=DATA_QUERY, butler=butler)
quanta = spe.run(True)
If you don’t need a config override, it’s simpler:
from lsst.ctrl.mpexec import SimplePipelineExecutor
from lsst.pipe.base import Pipeline
butler = SimplePipelineExecutor.prep_butler(BUTLER_REPO, inputs=[INPUT_COLLECTIONS], output=OUTPUT_COLLECTION)
spe = SimplePipelineExecutor.from_pipeline_filename(PIPELINE_YAML, where=DATA_QUERY, butler=butler)
quanta = spe.run(True)
Handling the --long-log option to pipetask is a bit trickier because it relies on an internal API that is not documented in pipelines.lsst.io (but has reasonable docstrings):
from lsst.daf.butler.cli.cliLog import CliLog
CliLog.initLog(longlog=True)