8.2.8.26.26. __doc__
-
run_model.__doc__ = "\n It is an utility function to execute dynamically generated function/models\n and - if Dispatcher based - add their workflows to the parent solution.\n\n :return:\n A function that executes the dispatch of the given `dsp`.\n :rtype: callable\n\n **Example**:\n\n Follows a simple example on how to use the\n :func:`~schedula.utils.dsp.run_model`:\n\n .. dispatcher:: dsp\n :opt: graph_attr={'ratio': '1'}\n\n >>> from schedula import Dispatcher\n >>> dsp = Dispatcher(name='Dispatcher')\n >>> dsp.add_function(\n ... function_id='execute_dsp', function=run_model,\n ... inputs=['dsp_model', 'inputs'], outputs=['outputs']\n ... )\n 'execute_dsp'\n >>> dsp_model = Dispatcher(name='Model')\n >>> dsp_model.add_function('max', max, inputs=['a', 'b'], outputs=['c'])\n 'max'\n >>> sol = dsp({'dsp_model': dsp_model, 'inputs': {'b': 1, 'a': 2}})\n >>> sol['outputs']\n Solution({'a': 2, 'b': 1, 'c': 2})\n >>> sol.workflow.nodes['execute_dsp']['solution']\n Solution({'a': 2, 'b': 1, 'c': 2})\n\n Moreover, it can be used also with all\n :func:`~schedula.utils.dsp.SubDispatcher` like objects::\n\n >>> sub_dsp = SubDispatch(dsp_model, outputs=['c'], output_type='list')\n >>> sol = dsp({'dsp_model': sub_dsp, 'inputs': {'b': 1, 'a': 2}})\n >>> sol['outputs']\n [2]\n >>> sol.workflow.nodes['execute_dsp']['solution']\n Solution({'a': 2, 'b': 1, 'c': 2})\n "