Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/cli.py
Show First 20 Lines • Show All 153 Lines • ▼ Show 20 Lines | |||||
@storage.command() | @storage.command() | ||||
@click.option( | @click.option( | ||||
"--stop-after-objects", | "--stop-after-objects", | ||||
"-n", | "-n", | ||||
default=None, | default=None, | ||||
type=int, | type=int, | ||||
help="Stop after processing this many objects. Default is to " "run forever.", | help="Stop after processing this many objects. Default is to " "run forever.", | ||||
) | ) | ||||
@click.option( | |||||
"--type", | |||||
"-t", | |||||
"object_types", | |||||
default=[], | |||||
type=click.Choice( | |||||
vlorentz: `s/check/write/`? | |||||
Not Done Inline Actionsor even replay olasd: or even `replay` | |||||
# use a hardcoded list to prevent having to load the | |||||
# replay module at cli loading time | |||||
[ | |||||
"origin", | |||||
"origin_visit", | |||||
"origin_visit_status", | |||||
"snapshot", | |||||
"revision", | |||||
"release", | |||||
"directory", | |||||
"content", | |||||
"skipped_content", | |||||
"metadata_authority", | |||||
"metadata_fetcher", | |||||
"raw_extrinsic_metadata", | |||||
"extid", | |||||
] | |||||
), | |||||
help="Object types to replay", | |||||
multiple=True, | |||||
) | |||||
@click.pass_context | @click.pass_context | ||||
def replay(ctx, stop_after_objects): | def replay(ctx, stop_after_objects, object_types): | ||||
"""Fill a Storage by reading a Journal. | """Fill a Storage by reading a Journal. | ||||
There can be several 'replayers' filling a Storage as long as they use | There can be several 'replayers' filling a Storage as long as they use | ||||
the same `group-id`. | the same `group-id`. | ||||
""" | """ | ||||
import functools | import functools | ||||
from swh.journal.client import get_journal_client | from swh.journal.client import get_journal_client | ||||
from swh.storage import get_storage | from swh.storage import get_storage | ||||
from swh.storage.replay import process_replay_objects | from swh.storage.replay import process_replay_objects | ||||
ensure_check_config(ctx.obj["config"], ctx.obj["check_config"], "write") | ensure_check_config(ctx.obj["config"], ctx.obj["check_config"], "write") | ||||
conf = ctx.obj["config"] | conf = ctx.obj["config"] | ||||
storage = get_storage(**conf.pop("storage")) | storage = get_storage(**conf.pop("storage")) | ||||
client_cfg = conf.pop("journal_client") | client_cfg = conf.pop("journal_client") | ||||
if object_types: | |||||
client_cfg["object_types"] = object_types | |||||
if stop_after_objects: | if stop_after_objects: | ||||
client_cfg["stop_after_objects"] = stop_after_objects | client_cfg["stop_after_objects"] = stop_after_objects | ||||
try: | try: | ||||
client = get_journal_client(**client_cfg) | client = get_journal_client(**client_cfg) | ||||
except ValueError as exc: | except ValueError as exc: | ||||
ctx.fail(exc) | ctx.fail(exc) | ||||
worker_fn = functools.partial(process_replay_objects, storage=storage) | worker_fn = functools.partial(process_replay_objects, storage=storage) | ||||
Show All 39 Lines |
s/check/write/?