Create a subgraph from gremlin output. Args: interactive_query (:class:`graphscope.interactive.query.InteractiveQueryDAGNode`): The GIE instance holds the graph that gremlin query on. gremlin_script (str): gremlin script to be executed. request_op
(
interactive_query, gremlin_script, request_options=None, oid_type="int64"
)
| 1046 | |
| 1047 | |
| 1048 | def gremlin_to_subgraph( |
| 1049 | interactive_query, gremlin_script, request_options=None, oid_type="int64" |
| 1050 | ): |
| 1051 | """Create a subgraph from gremlin output. |
| 1052 | |
| 1053 | Args: |
| 1054 | interactive_query (:class:`graphscope.interactive.query.InteractiveQueryDAGNode`): |
| 1055 | The GIE instance holds the graph that gremlin query on. |
| 1056 | gremlin_script (str): |
| 1057 | gremlin script to be executed. |
| 1058 | request_options (dict, optional): gremlin request options. format: |
| 1059 | { |
| 1060 | "engine": "gae" |
| 1061 | } |
| 1062 | oid_type (str, optional): |
| 1063 | Type of vertex original id. Defaults to "int64". |
| 1064 | |
| 1065 | Returns: |
| 1066 | An op to create the subgraph from gremlin script |
| 1067 | """ |
| 1068 | config = {} |
| 1069 | config[types_pb2.GIE_GREMLIN_QUERY_MESSAGE] = utils.s_to_attr(gremlin_script) |
| 1070 | config[types_pb2.OID_TYPE] = utils.s_to_attr(oid_type) |
| 1071 | config[types_pb2.VINEYARD_ID] = utils.i_to_attr(interactive_query.object_id) |
| 1072 | if request_options: |
| 1073 | config[types_pb2.GIE_GREMLIN_REQUEST_OPTIONS] = utils.s_to_attr( |
| 1074 | json.dumps(request_options) |
| 1075 | ) |
| 1076 | op = Operation( |
| 1077 | interactive_query.session_id, |
| 1078 | types_pb2.SUBGRAPH, |
| 1079 | config=config, |
| 1080 | output_types=types_pb2.GRAPH, |
| 1081 | ) |
| 1082 | return op |
| 1083 | |
| 1084 | |
| 1085 | def save_to_graphar(graph, path: str, **kwargs): |