diff --git a/requirements-swh.txt b/requirements-swh.txt index 675ffa5..fd25306 100644 --- a/requirements-swh.txt +++ b/requirements-swh.txt @@ -1,4 +1,4 @@ # Add here internal Software Heritage dependencies, one per line. -swh.core[http] +swh.core[http] >= 0.3 swh.journal swh.model diff --git a/setup.py b/setup.py index 1ccd22d..b1cfd4d 100755 --- a/setup.py +++ b/setup.py @@ -1,70 +1,70 @@ #!/usr/bin/env python3 # Copyright (C) 2015-2018 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information from io import open from os import path from setuptools import find_packages, setup here = path.abspath(path.dirname(__file__)) # Get the long description from the README file with open(path.join(here, "README.md"), encoding="utf-8") as f: long_description = f.read() def parse_requirements(name=None): if name: reqf = "requirements-%s.txt" % name else: reqf = "requirements.txt" requirements = [] if not path.exists(reqf): return requirements with open(reqf) as f: for line in f.readlines(): line = line.strip() if not line or line.startswith("#"): continue requirements.append(line) return requirements setup( name="swh.dataset", description="Software Heritage dataset tools", long_description=long_description, long_description_content_type="text/markdown", author="Software Heritage developers", author_email="swh-devel@inria.fr", url="https://forge.softwareheritage.org/source/swh-dataset/", packages=find_packages(), # packages's modules install_requires=parse_requirements() + parse_requirements("swh"), tests_require=parse_requirements("test"), entry_points=""" [swh.cli.subcommands] - dataset=swh.dataset.cli:cli + dataset=swh.dataset.cli """, setup_requires=["vcversioner"], extras_require={"testing": parse_requirements("test")}, vcversioner={}, include_package_data=True, classifiers=[ "Programming Language :: Python :: 3", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Operating System :: OS Independent", "Development Status :: 3 - Alpha", ], project_urls={ "Bug Reports": "https://forge.softwareheritage.org/maniphest", "Funding": "https://www.softwareheritage.org/donate", "Source": "https://forge.softwareheritage.org/source/swh-dataset", "Documentation": "https://docs.softwareheritage.org/devel/swh-dataset/", }, ) diff --git a/swh/dataset/cli.py b/swh/dataset/cli.py index ac7981d..6f8e29f 100644 --- a/swh/dataset/cli.py +++ b/swh/dataset/cli.py @@ -1,63 +1,63 @@ # Copyright (C) 2020 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information # WARNING: do not import unnecessary things here to keep cli startup time under # control import click -from swh.core.cli import CONTEXT_SETTINGS +from swh.core.cli import CONTEXT_SETTINGS, swh as swh_cli_group -@click.group(name="dataset", context_settings=CONTEXT_SETTINGS) +@swh_cli_group.group(name="dataset", context_settings=CONTEXT_SETTINGS) @click.option( "--config-file", "-C", default=None, type=click.Path(exists=True, dir_okay=False), help="Configuration file.", ) @click.pass_context -def cli(ctx, config_file): +def dataset_cli_group(ctx, config_file): """Software Heritage Dataset Tools""" from swh.core import config ctx.ensure_object(dict) conf = config.read(config_file) ctx.obj["config"] = conf -@cli.group("graph") +@dataset_cli_group.group("graph") @click.pass_context def graph(ctx): """Manage graph edges export""" pass @graph.command("export") @click.argument("export-path", type=click.Path()) @click.option("--export-id", "-e", help="Unique ID of the export run.") @click.option("--processes", "-p", default=1, help="Number of parallel processes") @click.pass_context def export_graph(ctx, export_path, export_id, processes): """Export the Software Heritage graph as an edge dataset.""" import uuid config = ctx.obj["config"] if not export_id: export_id = str(uuid.uuid4()) from swh.dataset.graph import export_edges export_edges(config, export_path, export_id, processes) @graph.command("sort") @click.argument("export-path", type=click.Path()) @click.pass_context def sort_graph(ctx, export_path): config = ctx.obj["config"] from swh.dataset.graph import sort_graph_nodes sort_graph_nodes(export_path, config)