Changeset View
Changeset View
Standalone View
Standalone View
swh/graph/cli.py
Show First 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | def graph_cli_group(ctx, config_file): | ||||
ctx.obj["config"] = conf | ctx.obj["config"] = conf | ||||
@graph_cli_group.command("api-client") | @graph_cli_group.command("api-client") | ||||
@click.option("--host", default="localhost", help="Graph server host") | @click.option("--host", default="localhost", help="Graph server host") | ||||
@click.option("--port", default="5009", help="Graph server port") | @click.option("--port", default="5009", help="Graph server port") | ||||
@click.pass_context | @click.pass_context | ||||
def api_client(ctx, host, port): | def api_client(ctx, host, port): | ||||
"""client for the graph REST service""" | """client for the graph RPC service""" | ||||
from swh.graph import client | from swh.graph import client | ||||
url = "http://{}:{}".format(host, port) | url = "http://{}:{}".format(host, port) | ||||
app = client.RemoteGraphClient(url) | app = client.RemoteGraphClient(url) | ||||
# TODO: run web app | # TODO: run web app | ||||
print(app.stats()) | print(app.stats()) | ||||
▲ Show 20 Lines • Show All 217 Lines • ▼ Show 20 Lines | @click.option( | ||||
show_default=True, | show_default=True, | ||||
help="port to bind the server on", | help="port to bind the server on", | ||||
) | ) | ||||
@click.option( | @click.option( | ||||
"--graph", "-g", required=True, metavar="GRAPH", help="compressed graph basename" | "--graph", "-g", required=True, metavar="GRAPH", help="compressed graph basename" | ||||
) | ) | ||||
@click.pass_context | @click.pass_context | ||||
def serve(ctx, host, port, graph): | def serve(ctx, host, port, graph): | ||||
"""run the graph REST service""" | """run the graph RPC service""" | ||||
import aiohttp | import aiohttp | ||||
from swh.graph.backend import Backend | from swh.graph.backend import Backend | ||||
from swh.graph.server.app import make_app | from swh.graph.server.app import make_app | ||||
backend = Backend(graph_path=graph, config=ctx.obj["config"]) | backend = Backend(graph_path=graph, config=ctx.obj["config"]) | ||||
app = make_app(backend=backend) | app = make_app(backend=backend) | ||||
▲ Show 20 Lines • Show All 99 Lines • Show Last 20 Lines |