Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Paste
P1502
GRPC python client example
Active
Public
Actions
Authored by
seirl
on Oct 20 2022, 5:13 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Subscribers
None
from
google.protobuf.field_mask_pb2
import
FieldMask
from
swh.graph.grpc.swhgraph_pb2
import
(
NodeFilter
,
StatsRequest
,
TraversalRequest
,
)
from
swh.graph.grpc.swhgraph_pb2_grpc
import
TraversalServiceStub
channel
=
grpc
.
aio
.
insecure_channel
(
'localhost:50091'
)
with
channel
:
client
=
TraversalServiceStub
(
channel
)
# Stats request
print
(
client
.
Stats
(
StatsRequest
()))
# Traversal request
request
=
TraversalRequest
(
src
=
[
"swh:1:cnt:cafedeadbeef"
],
edges
=
"rev:rev,rev:rel"
,
direction
=
"BACKWARD"
,
return_nodes
=
NodeFilter
(
"rel"
),
mask
=
FieldMask
(
paths
=
[
"swhid"
,
"rel.message"
,
"rel.author"
]),
)
for
node
in
client
.
Traverse
(
request
):
print
(
node
)
Event Timeline
seirl
created this paste.
Oct 20 2022, 5:13 PM
2022-10-20 17:13:08 (UTC+2)
seirl
edited the content of this paste.
(Show Details)
Log In to Comment