From 7e38088cce3e480ba65d2301d570dce9068af98d Mon Sep 17 00:00:00 2001 From: Serapheim Dimitropoulos Date: Fri, 24 Apr 2020 09:48:57 -0700 Subject: [PATCH 1/2] fix new yapf warnings (#213) get rid of unused imports and variables found by flake8 cleanup copyright comments refactor range() calls --- sdb/commands/internal/table.py | 20 +++++++++----------- sdb/commands/linux/per_cpu.py | 2 +- sdb/commands/linux/slabs.py | 4 ++-- sdb/commands/spl/spl_kmem_caches.py | 4 ++-- sdb/commands/zfs/internal/__init__.py | 1 - sdb/commands/zfs/metaslab.py | 2 +- sdb/commands/zfs/vdev.py | 2 +- sdb/pipeline.py | 2 +- setup.py | 2 +- 9 files changed, 18 insertions(+), 21 deletions(-) diff --git a/sdb/commands/internal/table.py b/sdb/commands/internal/table.py index b0f6d96a..cdddc49c 100644 --- a/sdb/commands/internal/table.py +++ b/sdb/commands/internal/table.py @@ -35,11 +35,11 @@ class Table: # # pylint: disable=bad-continuation def __init__( - self, - fields: List[str], - rjustfields: Optional[Set[str]] = None, - formatters: Optional[Dict[str, Callable[[Any], str]]] = None - ) -> None: + self, + fields: List[str], + rjustfields: Optional[Set[str]] = None, + formatters: Optional[Dict[str, Callable[[Any], + str]]] = None) -> None: self.fields = fields if rjustfields is None: @@ -93,13 +93,11 @@ def print_(self, continue line_fields = [] - for fid in range(len(self.fields)): - if self.fields[fid] in self.rjustfields: + for fid, field in enumerate(self.fields): + if field in self.rjustfields: line_fields.append( - f"{row_values[fid]:>{self.maxfieldlen[self.fields[fid]]}}" - ) + f"{row_values[fid]:>{self.maxfieldlen[field]}}") else: line_fields.append( - f"{row_values[fid]:<{self.maxfieldlen[self.fields[fid]]}}" - ) + f"{row_values[fid]:<{self.maxfieldlen[field]}}") print(delimeter.join(line_fields)) diff --git a/sdb/commands/linux/per_cpu.py b/sdb/commands/linux/per_cpu.py index 58008228..25081489 100644 --- a/sdb/commands/linux/per_cpu.py +++ b/sdb/commands/linux/per_cpu.py @@ -96,6 +96,6 @@ class LxPerCpuCounterSum(sdb.SingleInputCommand): def _call_one(self, obj: drgn.Object) -> Iterable[drgn.Object]: try: sum_ = drgn_percpu.percpu_counter_sum(obj) - except AttributeError as err: + except AttributeError: raise sdb.CommandError(self.name, "input is not a percpu_counter") yield drgn.Object(sdb.get_prog(), type="s64", value=sum_) diff --git a/sdb/commands/linux/slabs.py b/sdb/commands/linux/slabs.py index 56864112..22c08a53 100644 --- a/sdb/commands/linux/slabs.py +++ b/sdb/commands/linux/slabs.py @@ -110,8 +110,8 @@ def no_input(self) -> Iterable[drgn.Object]: yield from sorted( self.__no_input_iterator(), key=Slabs.FIELDS[self.args.s], - reverse=( - self.args.s not in Slabs.DEFAULT_INCREASING_ORDER_FIELDS)) + reverse=(self.args.s + not in Slabs.DEFAULT_INCREASING_ORDER_FIELDS)) else: yield from self.__no_input_iterator() diff --git a/sdb/commands/spl/spl_kmem_caches.py b/sdb/commands/spl/spl_kmem_caches.py index 55723922..5242b99e 100644 --- a/sdb/commands/spl/spl_kmem_caches.py +++ b/sdb/commands/spl/spl_kmem_caches.py @@ -100,8 +100,8 @@ def no_input(self) -> Iterable[drgn.Object]: yield from sorted( kmem.for_each_spl_kmem_cache(), key=SplKmemCaches.FIELDS[self.args.s], - reverse=(self.args.s not in - SplKmemCaches.DEFAULT_INCREASING_ORDER_FIELDS)) + reverse=(self.args.s + not in SplKmemCaches.DEFAULT_INCREASING_ORDER_FIELDS)) else: yield from kmem.for_each_spl_kmem_cache() diff --git a/sdb/commands/zfs/internal/__init__.py b/sdb/commands/zfs/internal/__init__.py index 57e885b4..7909c29c 100644 --- a/sdb/commands/zfs/internal/__init__.py +++ b/sdb/commands/zfs/internal/__init__.py @@ -17,7 +17,6 @@ # pylint: disable=missing-docstring import os -from typing import List import drgn import sdb diff --git a/sdb/commands/zfs/metaslab.py b/sdb/commands/zfs/metaslab.py index c1e5b063..c4f54216 100644 --- a/sdb/commands/zfs/metaslab.py +++ b/sdb/commands/zfs/metaslab.py @@ -192,6 +192,6 @@ def from_vdev(self, vdev: drgn.Object) -> Iterable[drgn.Object]: i, int(vdev.vdev_ms_count), int(vdev.vdev_id))) yield vdev.vdev_ms[i] else: - for i in range(0, int(vdev.vdev_ms_count)): + for i in range(int(vdev.vdev_ms_count)): msp = vdev.vdev_ms[i] yield msp diff --git a/sdb/commands/zfs/vdev.py b/sdb/commands/zfs/vdev.py index 860d5ca3..6787e369 100644 --- a/sdb/commands/zfs/vdev.py +++ b/sdb/commands/zfs/vdev.py @@ -130,6 +130,6 @@ def from_vdev(self, vdev: drgn.Object) -> Iterable[drgn.Object]: self.name, "when providing a vdev, " "specific child vdevs can not be requested") yield vdev - for cid in range(0, int(vdev.vdev_children)): + for cid in range(int(vdev.vdev_children)): cvd = vdev.vdev_child[cid] yield from self.from_vdev(cvd) diff --git a/sdb/pipeline.py b/sdb/pipeline.py index a7dcda75..bb833f67 100644 --- a/sdb/pipeline.py +++ b/sdb/pipeline.py @@ -1,4 +1,4 @@ -#o +# # Copyright 2019 Delphix # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/setup.py b/setup.py index 46eeff50..adf4600e 100755 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -from setuptools import setup, find_packages +from setuptools import setup setup( name='sdb', From c63fc0159b031c92bc6dbe13c4c33b65ab9d0d02 Mon Sep 17 00:00:00 2001 From: Prakash Surya Date: Fri, 24 Apr 2020 10:43:40 -0700 Subject: [PATCH 2/2] Sync "6.0/stage" with "master" via GitHub Actions (#211) --- .github/scripts/install-hub.sh | 3 ++ .github/scripts/sync-with-master.sh | 39 ++++++++++++++++++++++++++ .github/workflows/sync-with-master.yml | 21 ++++++++++++++ 3 files changed, 63 insertions(+) create mode 100755 .github/scripts/install-hub.sh create mode 100755 .github/scripts/sync-with-master.sh create mode 100644 .github/workflows/sync-with-master.yml diff --git a/.github/scripts/install-hub.sh b/.github/scripts/install-hub.sh new file mode 100755 index 00000000..5caf70f4 --- /dev/null +++ b/.github/scripts/install-hub.sh @@ -0,0 +1,3 @@ +#!/bin/bash -eux + +curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s v2.14.2 diff --git a/.github/scripts/sync-with-master.sh b/.github/scripts/sync-with-master.sh new file mode 100755 index 00000000..d8e48786 --- /dev/null +++ b/.github/scripts/sync-with-master.sh @@ -0,0 +1,39 @@ +#!/bin/bash -eux + +# +# This variable must be passed into this script. +# +[[ -n "${BRANCH}" ]] || exit 1 + +# +# We need these config parameters set in order to do the git-merge. +# +git config user.name "${GITHUB_ACTOR}" +git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" + +# +# We need the full git repository history in order to do the git-merge. +# +git fetch --unshallow + +# +# In order to open a pull request, we need to push to a remote branch. +# To avoid conflicting with existing remote branches, we use branches +# within the "sync-with-master" namespace. +# +git checkout -b "sync-with-master/${BRANCH}" "origin/${BRANCH}" +git merge -Xtheirs origin/master +git push -f origin "sync-with-master/${BRANCH}" + +# +# Opening a pull request may fail if there already exists a pull request +# for the branch; e.g. if a previous pull request was previously made, +# but not yet merged by the time we run this "sync" script again. Thus, +# rather than causing the automation to report a failure in this case, +# we swallow the error and report success. +# +# Additionally, as along as the git branch was properly updated (via the +# "git push" above), the existing PR will have been updated as well, so +# the "hub" command is unnecessary (hence ignoring the error). +# +git log -1 --format=%B | hub pull-request -F - -b "${BRANCH}" || true diff --git a/.github/workflows/sync-with-master.yml b/.github/workflows/sync-with-master.yml new file mode 100644 index 00000000..5d98d1d1 --- /dev/null +++ b/.github/workflows/sync-with-master.yml @@ -0,0 +1,21 @@ +on: + push: + branches: + - master + schedule: + - cron: '0 0 * * *' + +jobs: + sync: + strategy: + matrix: + branch: + - 6.0/stage + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + - run: ./.github/scripts/install-hub.sh + - run: ./.github/scripts/sync-with-master.sh + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BRANCH: ${{ matrix.branch }}