swh.graph.server.app module

A proxy HTTP server for swh-graph, talking to the Java code via py4j, and using FIFO as a transport to stream integers between the two languages.

async swh.graph.server.app.index(request)[source]
class swh.graph.server.app.GraphView(*args, **kwargs)[source]

Bases: aiohttp.web_urldispatcher.View

Base class for views working on the graph, with utility functions

node_of_swhid(swhid)[source]

Lookup a SWHID in a swhid2node map, failing in an HTTP-nice way if needed.

swhid_of_node(node)[source]

Lookup a node in a node2swhid map, failing in an HTTP-nice way if needed.

get_direction()[source]

Validate HTTP query parameter direction

get_edges()[source]

Validate HTTP query parameter edges, i.e., edge restrictions

get_traversal()[source]

Validate HTTP query parameter traversal, i.e., visit order

get_limit()[source]

Validate HTTP query parameter limit, i.e., number of results

class swh.graph.server.app.StreamingGraphView(*args, **kwargs)[source]

Bases: swh.graph.server.app.GraphView

Base class for views streaming their response line by line.

content_type = 'text/plain'
response_streamer(*args, **kwargs)[source]

Context manager to prepare then close a StreamResponse

async get()[source]
async prepare_response()[source]

This can be overridden with some setup to be run before the response actually starts streaming.

async stream_response()[source]

Override this to perform the response streaming. Implementations of this should await self.stream_line(line) to write each line.

async stream_line(line)[source]

Write a line in the response stream.

class swh.graph.server.app.StatsView(*args, **kwargs)[source]

Bases: swh.graph.server.app.GraphView

View showing some statistics on the graph

async get()[source]
class swh.graph.server.app.SimpleTraversalView(*args, **kwargs)[source]

Bases: swh.graph.server.app.StreamingGraphView

Base class for views of simple traversals

simple_traversal_type: Optional[str] = None
async prepare_response()[source]

This can be overridden with some setup to be run before the response actually starts streaming.

async stream_response()[source]

Override this to perform the response streaming. Implementations of this should await self.stream_line(line) to write each line.

class swh.graph.server.app.LeavesView(*args, **kwargs)[source]

Bases: swh.graph.server.app.SimpleTraversalView

simple_traversal_type: Optional[str] = 'leaves'
class swh.graph.server.app.NeighborsView(*args, **kwargs)[source]

Bases: swh.graph.server.app.SimpleTraversalView

simple_traversal_type: Optional[str] = 'neighbors'
class swh.graph.server.app.VisitNodesView(*args, **kwargs)[source]

Bases: swh.graph.server.app.SimpleTraversalView

simple_traversal_type: Optional[str] = 'visit_nodes'
class swh.graph.server.app.WalkView(*args, **kwargs)[source]

Bases: swh.graph.server.app.StreamingGraphView

async prepare_response()[source]

This can be overridden with some setup to be run before the response actually starts streaming.

async get_walk_iterator()[source]
async stream_response()[source]

Override this to perform the response streaming. Implementations of this should await self.stream_line(line) to write each line.

class swh.graph.server.app.RandomWalkView(*args, **kwargs)[source]

Bases: swh.graph.server.app.WalkView

get_walk_iterator()[source]
class swh.graph.server.app.VisitEdgesView(*args, **kwargs)[source]

Bases: swh.graph.server.app.SimpleTraversalView

async stream_response()[source]

Override this to perform the response streaming. Implementations of this should await self.stream_line(line) to write each line.

class swh.graph.server.app.VisitPathsView(*args, **kwargs)[source]

Bases: swh.graph.server.app.SimpleTraversalView

content_type = 'application/x-ndjson'
async stream_response()[source]

Override this to perform the response streaming. Implementations of this should await self.stream_line(line) to write each line.

class swh.graph.server.app.CountView(*args, **kwargs)[source]

Bases: swh.graph.server.app.GraphView

Base class for counting views.

count_type: Optional[str] = None
async get()[source]
class swh.graph.server.app.CountNeighborsView(*args, **kwargs)[source]

Bases: swh.graph.server.app.CountView

count_type: Optional[str] = 'neighbors'
class swh.graph.server.app.CountLeavesView(*args, **kwargs)[source]

Bases: swh.graph.server.app.CountView

count_type: Optional[str] = 'leaves'
class swh.graph.server.app.CountVisitNodesView(*args, **kwargs)[source]

Bases: swh.graph.server.app.CountView

count_type: Optional[str] = 'visit_nodes'
swh.graph.server.app.make_app(backend, **kwargs)[source]