def run_pipeline(flow: Flow, data_dir: str, output_dir: str, **kwargs) -> Optional[State]: """Run a pipeline. Parameters ---------- flow : Flow The generated flow. data_dir : str The directory containing the data. output_dir : str The output location for the data. **kwargs Parameter values. Returns ------- State The output of ``flow.run``. """ allparams = {param.name for param in flow.parameters()} params = {"data_dir": data_dir, "output_dir": output_dir, **kwargs} params = {key: value for key, value in params.items() if key in allparams} with prefect.context(data_dir=data_dir, output_dir=output_dir): output = flow.run(parameters=params) return output
def get_parameters(obj: prefect.Flow, context: dict) -> List: if isinstance(obj, prefect.Flow): params = obj.parameters() else: params = utils.get_value(obj, "parameters") if params is missing: return params return sorted(params, key=lambda p: p.slug)