Wrapper for create an `BIND_APP` Operation with configuration. Compile and load an application after evaluated. Args: graph (:class:`GraphDAGNode`): A :class:`GraphDAGNode` instance app (:class:`AppAssets`): A :class:`AppAssets` instance. Returns: An :class:`Ope
(graph, app_assets)
| 46 | |
| 47 | |
| 48 | def bind_app(graph, app_assets): |
| 49 | """Wrapper for create an `BIND_APP` Operation with configuration. |
| 50 | Compile and load an application after evaluated. |
| 51 | |
| 52 | Args: |
| 53 | graph (:class:`GraphDAGNode`): A :class:`GraphDAGNode` instance |
| 54 | app (:class:`AppAssets`): A :class:`AppAssets` instance. |
| 55 | |
| 56 | Returns: |
| 57 | An :class:`Operation` with configuration that instruct |
| 58 | analytical engine how to build the app. |
| 59 | """ |
| 60 | inputs = [graph.op, app_assets.op] |
| 61 | config = {} |
| 62 | config[types_pb2.APP_ALGO] = utils.s_to_attr(app_assets.algo) |
| 63 | if hasattr(graph, "_vertex_map"): |
| 64 | config[types_pb2.VERTEX_MAP_TYPE] = utils.i_to_attr(graph._vertex_map) |
| 65 | if hasattr(graph, "_compact_edges"): |
| 66 | config[types_pb2.COMPACT_EDGES] = utils.b_to_attr(graph._compact_edges) |
| 67 | if hasattr(graph, "_use_perfect_hash"): |
| 68 | config[types_pb2.USE_PERFECT_HASH] = utils.b_to_attr(graph._use_perfect_hash) |
| 69 | if app_assets.cmake_extra_options is not None: |
| 70 | config[types_pb2.CMAKE_EXTRA_OPTIONS] = utils.s_to_attr( |
| 71 | app_assets.cmake_extra_options |
| 72 | ) |
| 73 | op = Operation( |
| 74 | graph.session_id, |
| 75 | types_pb2.BIND_APP, |
| 76 | inputs=inputs, |
| 77 | config=config, |
| 78 | output_types=types_pb2.BOUND_APP, |
| 79 | ) |
| 80 | return op |
| 81 | |
| 82 | |
| 83 | def run_app(app, *args, **kwargs): |