From a1207c123eba37520624a172267ca4de95a48271 Mon Sep 17 00:00:00 2001 From: Yannick DAYER <yannick.dayer@idiap.ch> Date: Tue, 7 Mar 2023 11:14:49 +0100 Subject: [PATCH] [qa] autoupdate pre-commit --- .pre-commit-config.yaml | 8 ++++---- bob/devtools/bootstrap.py | 4 ---- bob/devtools/build.py | 3 --- bob/devtools/changelog.py | 4 ---- bob/devtools/ci.py | 2 -- bob/devtools/data/gitlab-ci/conda-configurator.py | 1 - bob/devtools/data/gitlab-ci/conda-next-build.py | 1 - bob/devtools/data/gitlab-ci/deregister.py | 1 - bob/devtools/dav.py | 1 - bob/devtools/deploy.py | 1 - bob/devtools/graph.py | 2 -- bob/devtools/mirror.py | 4 ---- bob/devtools/pipelines.py | 1 - bob/devtools/release.py | 2 -- bob/devtools/scripts/alternative_nightlies.py | 1 - bob/devtools/scripts/build.py | 1 - bob/devtools/scripts/changelog.py | 1 - bob/devtools/scripts/ci.py | 6 ------ bob/devtools/scripts/common_options.py | 1 - bob/devtools/scripts/dav.py | 2 -- bob/devtools/scripts/development.py | 3 --- bob/devtools/scripts/mirror.py | 1 - bob/devtools/scripts/rebuild.py | 3 --- bob/devtools/scripts/release.py | 1 - bob/devtools/scripts/runners.py | 9 --------- bob/devtools/scripts/settings.py | 3 --- bob/devtools/scripts/update_bob.py | 1 - bob/devtools/scripts/visibility.py | 1 - bob/devtools/test_ci.py | 2 -- deps/bob-devel/run_test.py | 1 - 30 files changed, 4 insertions(+), 68 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ccf73df7..cd2a22a1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,17 +2,17 @@ # See https://pre-commit.com/hooks.html for more hooks repos: - repo: https://github.com/timothycrosley/isort - rev: 5.10.1 + rev: 5.12.0 hooks: - id: isort args: [--settings-path, "pyproject.toml"] - repo: https://github.com/psf/black - rev: 22.10.0 + rev: 23.1.0 hooks: - id: black exclude: bob/devtools/templates/setup.py - repo: https://github.com/pycqa/flake8 - rev: 3.9.2 + rev: 6.0.0 hooks: - id: flake8 exclude: | @@ -21,7 +21,7 @@ repos: deps/bob-devel/run_test.py )$ - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v4.4.0 hooks: - id: check-ast exclude: bob/devtools/templates/setup.py diff --git a/bob/devtools/bootstrap.py b/bob/devtools/bootstrap.py index 73efac7a..88e26641 100644 --- a/bob/devtools/bootstrap.py +++ b/bob/devtools/bootstrap.py @@ -423,7 +423,6 @@ def setup_logger(logger, level): if __name__ == "__main__": - import argparse parser = argparse.ArgumentParser( @@ -547,7 +546,6 @@ if __name__ == "__main__": should_install_git = [] if args.command == "build": - # clean conda cache and packages before building run_cmdline([conda_bin, "clean", "--all"]) @@ -572,7 +570,6 @@ if __name__ == "__main__": ) elif args.command == "local": - # index the locally built packages run_cmdline( [conda_bin, "install", "--yes"] @@ -615,7 +612,6 @@ if __name__ == "__main__": ) elif args.command == "channel": - # installs from channel channels, _ = get_channels( public=True, diff --git a/bob/devtools/build.py b/bob/devtools/build.py index f664f849..9925da7d 100644 --- a/bob/devtools/build.py +++ b/bob/devtools/build.py @@ -265,7 +265,6 @@ def exists_on_channel(channel_url, basename): build_number, urls = next_build_number(channel_url, basename) def _get_build_number(name): - # remove .tar.bz2/.conda from name, then split from the end twice, on # '-' if name.endswith(".conda"): @@ -329,7 +328,6 @@ def uniq(seq, idfun=None): def parse_dependencies(recipe_dir, config): - metadata = get_rendered_metadata(recipe_dir, config) recipe = get_parsed_recipe(metadata) requirements = [] @@ -982,7 +980,6 @@ def build_deps(obj): """ recipes = load_order_file(os.path.join("deps", "order.txt")) for k, recipe in enumerate([os.path.join("deps", k) for k in recipes]): - if not os.path.exists(os.path.join(recipe, "meta.yaml")): # ignore - not a conda package continue diff --git a/bob/devtools/changelog.py b/bob/devtools/changelog.py index d5b20692..695e2b10 100644 --- a/bob/devtools/changelog.py +++ b/bob/devtools/changelog.py @@ -131,7 +131,6 @@ def get_last_tag_date(package): def _get_tag_changelog(tag): - try: return tag.release["description"] except Exception: @@ -152,7 +151,6 @@ def _write_one_tag(f, pkg_name, tag): f.write(" * %s (%s)\n" % (tag.name, git_date.strftime("%b %d, %Y %H:%M"))) for line in _get_tag_changelog(tag).replace("\r\n", "\n").split("\n"): - line = line.strip() if line.startswith("* ") or line.startswith("- "): line = line[2:] @@ -294,7 +292,6 @@ def write_tags_with_commits(f, gitpkg, since, mode): # commits start_date = since for tag in tags: - # write tag name and its text _write_one_tag(f, gitpkg.attributes["path_with_namespace"], tag) end_date = parse_date(tag.commit["committed_date"]) @@ -326,7 +323,6 @@ def write_tags_with_commits(f, gitpkg, since, mode): start_date = end_date if mode != "tags": - # write the tentative patch version bump for the future tag f.write(" * patch\n") diff --git a/bob/devtools/ci.py b/bob/devtools/ci.py index 26965fd1..07700f98 100644 --- a/bob/devtools/ci.py +++ b/bob/devtools/ci.py @@ -258,7 +258,6 @@ def cleanup(dry_run, username, password, includes): from .deploy import _setup_webdav_client for public in (True, False): - server_info = WEBDAV_PATHS[False][public] davclient = _setup_webdav_client( SERVER, server_info["root"], username, password @@ -283,7 +282,6 @@ def cleanup(dry_run, username, password, includes): path = server_info["conda"] for arch in archs: - arch_path = "/".join((path, arch)) if not (davclient.check(arch_path) and davclient.is_dir(arch_path)): diff --git a/bob/devtools/data/gitlab-ci/conda-configurator.py b/bob/devtools/data/gitlab-ci/conda-configurator.py index 489649fc..46255d39 100644 --- a/bob/devtools/data/gitlab-ci/conda-configurator.py +++ b/bob/devtools/data/gitlab-ci/conda-configurator.py @@ -86,7 +86,6 @@ def _get_channels(public, stable, server, intranet, group): if __name__ == "__main__": - if len(sys.argv) != 5: print(f"usage: {sys.argv[0]} group visibility tag condarc") sys.exit(1) diff --git a/bob/devtools/data/gitlab-ci/conda-next-build.py b/bob/devtools/data/gitlab-ci/conda-next-build.py index 9758255b..85b28e6c 100644 --- a/bob/devtools/data/gitlab-ci/conda-next-build.py +++ b/bob/devtools/data/gitlab-ci/conda-next-build.py @@ -94,7 +94,6 @@ def _next_build_number(channel_url, name, version, build_variant): if __name__ == "__main__": - if len(sys.argv) != 7: print(f"usage: {sys.argv[0]} group visibility tag name version variant") sys.exit(1) diff --git a/bob/devtools/data/gitlab-ci/deregister.py b/bob/devtools/data/gitlab-ci/deregister.py index 7f500b62..da6e6593 100644 --- a/bob/devtools/data/gitlab-ci/deregister.py +++ b/bob/devtools/data/gitlab-ci/deregister.py @@ -4,7 +4,6 @@ import gitlab import pkginfo if __name__ == "__main__": - if len(sys.argv) != 5: print( f"usage: {sys.argv[0]} server-url user-token project-id source-file" diff --git a/bob/devtools/dav.py b/bob/devtools/dav.py index bf874111..95d8f43a 100644 --- a/bob/devtools/dav.py +++ b/bob/devtools/dav.py @@ -142,7 +142,6 @@ def remove_old_beta_packages(client, path, dry_run, pyver=True, includes=None): pyver_finder = re.compile("py[1-9][0-9]h.*") for f in client.list(path): - if f.startswith("."): continue diff --git a/bob/devtools/deploy.py b/bob/devtools/deploy.py index 7325a993..c1850cbc 100644 --- a/bob/devtools/deploy.py +++ b/bob/devtools/deploy.py @@ -202,7 +202,6 @@ def deploy_documentation( if __name__ == "__main__": - import argparse parser = argparse.ArgumentParser( diff --git a/bob/devtools/graph.py b/bob/devtools/graph.py index b2514df8..8e4286c5 100644 --- a/bob/devtools/graph.py +++ b/bob/devtools/graph.py @@ -100,7 +100,6 @@ def compute_adjencence_matrix( % (use_package.attributes["path_with_namespace"], ref) ) with tempfile.TemporaryDirectory() as tmpdir: - logger.debug("Downloading archive for %s...", ref) archive = use_package.repository_archive(ref=ref) # in memory logger.debug("Archive has %d bytes", len(archive)) @@ -281,7 +280,6 @@ def generate_graph(adjacence_matrix, deptypes, whitelist): # generates nodes for all dependencies for package, values in adjacence_matrix.items(): - # ensures we only have the most complete dependence in the our list deps = {} to_consider = set() diff --git a/bob/devtools/mirror.py b/bob/devtools/mirror.py index 2756e2b7..ce97532b 100644 --- a/bob/devtools/mirror.py +++ b/bob/devtools/mirror.py @@ -214,10 +214,8 @@ def download_packages(packages, repodata, channel_url, dest_dir, arch, dry_run): # download files into temporary directory, that is removed by the end of # the procedure, or if something bad occurs with tempfile.TemporaryDirectory() as download_dir: - total = len(packages) for k, p in enumerate(packages): - k += 1 # adjust to produce correct order on printouts # checksum to verify @@ -237,7 +235,6 @@ def download_packages(packages, repodata, channel_url, dest_dir, arch, dry_run): package_retries = 10 while package_retries: - if not dry_run: logger.debug("[checking: %d/%d] %s", k, total, url) r = requests.get(url, stream=True, allow_redirects=True) @@ -400,7 +397,6 @@ def checksum_packages(repodata, dest_dir, arch, packages): issues = set() total = len(packages) for k, p in enumerate(packages): - path_to_package = os.path.join(dest_dir, arch, p) # checksum to verify diff --git a/bob/devtools/pipelines.py b/bob/devtools/pipelines.py index 230b5c46..417cc45f 100644 --- a/bob/devtools/pipelines.py +++ b/bob/devtools/pipelines.py @@ -19,7 +19,6 @@ def process_log(log): logs = dict() dates = [] for ll in log: - # Check which package are we if len(re.findall("Building bob/[a-z]*", ll)) > 0: logs[current_package] = dates diff --git a/bob/devtools/release.py b/bob/devtools/release.py index 866060fe..576ee1bb 100644 --- a/bob/devtools/release.py +++ b/bob/devtools/release.py @@ -173,7 +173,6 @@ def get_parsed_tag(gitpkg, tag): # if we bump the version, we need to find the latest released version for # this package if tag in ("major", "minor", "patch"): - # find the correct latest tag of this package (without 'v' in front), # None if there are no tags yet latest_tag_name = get_latest_tag_name(gitpkg) @@ -454,7 +453,6 @@ def wait_for_pipeline_to_finish(gitpkg, pipeline_id, dry_run=False): slept_so_far = 0 while pipeline.status == "running" or pipeline.status == "pending": - time.sleep(sleep_step) slept_so_far += sleep_step if slept_so_far > max_sleep: diff --git a/bob/devtools/scripts/alternative_nightlies.py b/bob/devtools/scripts/alternative_nightlies.py index e52e47ba..31d043ea 100644 --- a/bob/devtools/scripts/alternative_nightlies.py +++ b/bob/devtools/scripts/alternative_nightlies.py @@ -54,7 +54,6 @@ def alt_nightlies(order, variables): packages = read_packages(order) for n, (package, branch) in enumerate(packages): - # trigger a pipeline for package and branch project = gl.projects.get(package) logger.info( diff --git a/bob/devtools/scripts/build.py b/bob/devtools/scripts/build.py index 13f91d32..c0d0cf0c 100644 --- a/bob/devtools/scripts/build.py +++ b/bob/devtools/scripts/build.py @@ -243,7 +243,6 @@ def build( arch = conda_arch() for d in recipe_dir: - if not os.path.exists(d): raise RuntimeError("The directory %s does not exist" % d) diff --git a/bob/devtools/scripts/changelog.py b/bob/devtools/scripts/changelog.py index 13be66da..340572da 100644 --- a/bob/devtools/scripts/changelog.py +++ b/bob/devtools/scripts/changelog.py @@ -149,7 +149,6 @@ def changelog(target, changelog, group, mode, since): # iterates over the packages and dumps required information for package in packages: - if "/" not in package: package = "/".join((group, package)) diff --git a/bob/devtools/scripts/ci.py b/bob/devtools/scripts/ci.py index 5f646748..829bde43 100644 --- a/bob/devtools/scripts/ci.py +++ b/bob/devtools/scripts/ci.py @@ -102,7 +102,6 @@ def base_deploy(dry_run): deploy_packages = glob.glob(conda_paths) + glob.glob(tarbz2_paths) for k in deploy_packages: - if os.path.basename(k).startswith(name): logger.debug("Skipping deploying of %s - not a base package", k) continue @@ -247,7 +246,6 @@ def readme(package): """ for k in package: - logger.info("Checking python package %s", k) # twine check dist/*.zip @@ -328,7 +326,6 @@ def pypi(package, dry_run): from twine.commands.upload import upload for k in package: - logger.info("Deploying python package %s to PyPI", k) upload(settings, [k]) logger.info("%s: Deployed to PyPI - OK", k) @@ -677,7 +674,6 @@ def nightlies(ctx, order, dry_run): # loaded all recipes, now cycle through them implementing what is described # in the documentation of this function for n, (package, branch) in enumerate(packages): - echo_normal("\n" + (80 * "=")) echo_normal( "Building %s@%s (%d/%d)" % (package, branch, n + 1, len(packages)) @@ -841,7 +837,6 @@ def docs(ctx, requirement, dry_run): doc_path = os.path.join(os.environ["CI_PROJECT_DIR"], "doc") for n, (package, branch) in enumerate(packages): - group, name = package.split("/", 1) clone_to = os.path.join(doc_path, group, name) @@ -919,7 +914,6 @@ def docs(ctx, requirement, dry_run): # Making unique lists and removing all bob/beat references if not dry_run: - # extra requirements for sphinx group = os.environ["CI_PROJECT_NAMESPACE"] extra_intersphinx = set( diff --git a/bob/devtools/scripts/common_options.py b/bob/devtools/scripts/common_options.py index df211a09..397d2741 100644 --- a/bob/devtools/scripts/common_options.py +++ b/bob/devtools/scripts/common_options.py @@ -5,7 +5,6 @@ def ref_option(**kwargs): """An option for getting branch name.""" def custom_ref_option(func): - return click.option( "-r", "--ref", diff --git a/bob/devtools/scripts/dav.py b/bob/devtools/scripts/dav.py index a7f00505..2aed581c 100644 --- a/bob/devtools/scripts/dav.py +++ b/bob/devtools/scripts/dav.py @@ -277,7 +277,6 @@ def upload(private, execute, checksum, local, remote): return 1 for k in local: - if not os.path.isdir(k): path_with_hash = k if checksum: @@ -405,7 +404,6 @@ def clean_betas(private, execute, path): ] for arch in archs: - arch_path = "/".join((path, arch)) if not (cl.check(arch_path) and cl.is_dir(arch_path)): diff --git a/bob/devtools/scripts/development.py b/bob/devtools/scripts/development.py index 01012a97..b5f540a0 100644 --- a/bob/devtools/scripts/development.py +++ b/bob/devtools/scripts/development.py @@ -25,7 +25,6 @@ def install(env_name, folders): import subprocess for folder in folders: - # call pip cmd = [ "conda", @@ -65,7 +64,6 @@ def checkout(ctx, names, use_https, subfolder): os.makedirs(subfolder, exist_ok=True) for name in names: - # call git # skip if the directory already exists dest = name @@ -73,7 +71,6 @@ def checkout(ctx, names, use_https, subfolder): dest = os.path.join(subfolder, name) if not os.path.isdir(dest): - url = f"git@gitlab.idiap.ch:bob/{name}.git" if use_https: url = f"https://gitlab.idiap.ch/bob/{name}.git" diff --git a/bob/devtools/scripts/mirror.py b/bob/devtools/scripts/mirror.py index 90236bc8..7fcfed62 100644 --- a/bob/devtools/scripts/mirror.py +++ b/bob/devtools/scripts/mirror.py @@ -192,7 +192,6 @@ def mirror( start_date = start_date.date() # only interested on the day itself for arch in DEFAULT_SUBDIRS: - try: remote_repodata = get_json( channel_url, arch, "repodata_from_packages.json.bz2" diff --git a/bob/devtools/scripts/rebuild.py b/bob/devtools/scripts/rebuild.py index 17987f96..4a201452 100644 --- a/bob/devtools/scripts/rebuild.py +++ b/bob/devtools/scripts/rebuild.py @@ -235,7 +235,6 @@ def rebuild( arch = conda_arch() for d in recipe_dir: - if not os.path.exists(d): raise RuntimeError("The directory %s does not exist" % recipe_dir) @@ -268,7 +267,6 @@ def rebuild( if ( existing ): # other builds exist, get the latest and see if it still works - destpath = os.path.join( condarc_options["croot"], arch, os.path.basename(existing[0]) ) @@ -300,7 +298,6 @@ def rebuild( logger.info("Test for %s: SUCCESS (package is up-to-date)", src) if should_build: # something wrong happened, run a full build - logger.info( "Re-building %s-%s-py%s (build: %d) for %s", rendered_recipe["package"]["name"], diff --git a/bob/devtools/scripts/release.py b/bob/devtools/scripts/release.py index a6c53480..879bd1ff 100644 --- a/bob/devtools/scripts/release.py +++ b/bob/devtools/scripts/release.py @@ -176,7 +176,6 @@ def release(changelog, group, package, resume, dry_run): # go through the list of packages and release them starting from the # start_idx for i in range(start_idx, len(pkgs) - 1): - cur_package_name = changelogs[pkgs[i]][1:].strip() if "/" not in cur_package_name: diff --git a/bob/devtools/scripts/runners.py b/bob/devtools/scripts/runners.py index f39e9509..872727cf 100644 --- a/bob/devtools/scripts/runners.py +++ b/bob/devtools/scripts/runners.py @@ -12,7 +12,6 @@ logger = get_logger(__name__) def _get_runner_from_description(gl, descr): - # search for the runner to affect the_runner = [ k @@ -32,7 +31,6 @@ def _get_runner_from_description(gl, descr): def _get_project(gl, name): - retval = gl.projects.get(name) logger.debug( "Found gitlab project %s (id=%d)", @@ -43,7 +41,6 @@ def _get_project(gl, name): def _get_projects_from_group(gl, name): - group = gl.groups.get(name) logger.debug( "Found gitlab group %s (id=%d)", @@ -66,7 +63,6 @@ def _get_projects_from_group(gl, name): def _get_projects_from_runner(gl, runner): - the_runner = gl.runners.get(runner.id) logger.info( "Retrieving details for %d projects using runner %s (id=%d). " @@ -85,7 +81,6 @@ def _get_projects_from_runner(gl, runner): def _get_projects_from_file(gl, filename): - packages = [] with open(filename, "rt") as f: lines = [k.strip() for k in f.readlines()] @@ -150,7 +145,6 @@ def enable(name, targets, group, dry_run): packages = [] for target in targets: - if os.path.exists(target): # it is a file with project names packages += _get_projects_from_file(gl, target) @@ -161,9 +155,7 @@ def enable(name, targets, group, dry_run): packages += _get_projects_from_group(gl, target) for k in packages: - try: - logger.info( "Processing project %s (id=%d)", k.attributes["path_with_namespace"], @@ -274,7 +266,6 @@ def disable(name, targets, dry_run): for k in packages: try: - logger.info( "Processing project %s (id=%d)", k.attributes["path_with_namespace"], diff --git a/bob/devtools/scripts/settings.py b/bob/devtools/scripts/settings.py index e8517451..d3d0f510 100644 --- a/bob/devtools/scripts/settings.py +++ b/bob/devtools/scripts/settings.py @@ -110,7 +110,6 @@ def settings(projects, avatar, description, group, archive, dry_run): gl_projects = [] for target in projects: - if os.path.exists(target): # it is a file with project names gl_projects += _get_projects_from_file(gl, target) @@ -121,9 +120,7 @@ def settings(projects, avatar, description, group, archive, dry_run): gl_projects += _get_projects_from_group(gl, target) for k in gl_projects: - try: - logger.info( "Processing project %s (id=%d)", k.attributes["path_with_namespace"], diff --git a/bob/devtools/scripts/update_bob.py b/bob/devtools/scripts/update_bob.py index 7902a815..177376a0 100644 --- a/bob/devtools/scripts/update_bob.py +++ b/bob/devtools/scripts/update_bob.py @@ -45,7 +45,6 @@ def update_bob(stable): # find the list of public packages public_packages, private_packages = [], [] for n, (package, branch) in enumerate(packages): - if package == "bob/bob": continue diff --git a/bob/devtools/scripts/visibility.py b/bob/devtools/scripts/visibility.py index 54edfc44..1062b23e 100644 --- a/bob/devtools/scripts/visibility.py +++ b/bob/devtools/scripts/visibility.py @@ -68,7 +68,6 @@ def visibility(target, group): # iterates over the packages and dumps required information for package in packages: - if "/" not in package: package = "/".join((group, package)) diff --git a/bob/devtools/test_ci.py b/bob/devtools/test_ci.py index cc0ff5bb..ec8e2a7a 100644 --- a/bob/devtools/test_ci.py +++ b/bob/devtools/test_ci.py @@ -7,13 +7,11 @@ from .constants import BOBRC_PATH def test_is_private(): - base_url = "https://gitlab.idiap.ch" assert not is_private(base_url, "bob/bob.extension") assert is_private(base_url, "bob/private") def test_bobrc_json_validity(): - with open(BOBRC_PATH) as f: json.load(f) diff --git a/deps/bob-devel/run_test.py b/deps/bob-devel/run_test.py index 1f0098f7..c45f081a 100644 --- a/deps/bob-devel/run_test.py +++ b/deps/bob-devel/run_test.py @@ -25,7 +25,6 @@ def _check_package(name, pyname=None): def test_setuptools_integrity(): - _check_package("pytorch", "torch") _check_package("torchvision") -- GitLab