I am trying to simplify the following traversal:
operation_dict['output_schema'] = g.V(operation_id).outE('uses').inV()\
.project('id','label','attribute_id', 'attribute_name', 'dataType')\
.by(T.id).by(T.label).by('attribute_id').by('attribute_name').by('dataType').toList()
Since i would like to reuse the projection traversal, i would like to extract it from the traversal, like the following snippet:
def extract_attribute(x):
return g.V(x).project('id','label','attribute_id', 'attribute_name', 'dataType')\
.by(T.id).by(T.label).by('attribute_id').by('attribute_name').by('dataType')
operation_dict['input_schema'] = g.V(operation_id).inE('follows').outV().outE('uses').inV()\
.map(lambda x: extract_attribute(x)).toList()
How can I do that in Gremlin for Python? I tried the Lambda functionality, but without success so far.