[v2] pw_maintainers_cli: enhance ci tree selection

Message ID 20230929131714.12525-1-pbhagavatula@marvell.com (mailing list archive)
State New
Headers
Series [v2] pw_maintainers_cli: enhance ci tree selection |

Commit Message

Pavan Nikhilesh Bhagavatula Sept. 29, 2023, 1:17 p.m. UTC
  From: Pavan Nikhilesh <pbhagavatula@marvell.com>

When longest prefix match doesnt find a suitable tree, remove the
trees of files belonging to 'drivers/common' and check if there
is any unique tree for the patchset.

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
---
 v2 Chnages:
 - Find tree by removing 'drivers/common' instead of count based
 approach.

 tools/pw_maintainers_cli.py | 31 ++++++++++++++++++++++++++-----
 1 file changed, 26 insertions(+), 5 deletions(-)

--
2.25.1
  

Comments

Aaron Conole Oct. 12, 2023, 12:59 p.m. UTC | #1
<pbhagavatula@marvell.com> writes:

> From: Pavan Nikhilesh <pbhagavatula@marvell.com>
>
> When longest prefix match doesnt find a suitable tree, remove the
> trees of files belonging to 'drivers/common' and check if there
> is any unique tree for the patchset.
>
> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> ---
>  v2 Chnages:
>  - Find tree by removing 'drivers/common' instead of count based
>  approach.
>
>  tools/pw_maintainers_cli.py | 31 ++++++++++++++++++++++++++-----
>  1 file changed, 26 insertions(+), 5 deletions(-)
>
> diff --git a/tools/pw_maintainers_cli.py b/tools/pw_maintainers_cli.py
> index c7b5ba0..ef60df8 100755
> --- a/tools/pw_maintainers_cli.py
> +++ b/tools/pw_maintainers_cli.py
> @@ -203,13 +203,15 @@ class Maintainers(object):
>          """
>          Return a git tree that matches a list of files."""
>          tree_list = []
> +        file_tree_map = {}
>          for _file in files:
>              _tree = self._get_tree(_file)
>              # Having no tree means that we accept those changes going through a
>              # subtree (e.g. release notes).
>              if _tree:
>                  tree_list.append(_tree)
> -        tree = self.get_common_denominator(tree_list)
> +                file_tree_map[_file] = _tree
> +        tree = self.get_common_denominator(tree_list, file_tree_map)
>          if not tree:
>              tree = 'git://dpdk.org/dpdk'
>          return tree
> @@ -268,7 +270,7 @@ class Maintainers(object):
>          self.matched[matching_pattern] = tree
>          return tree
>
> -    def get_common_denominator(self, tree_list):
> +    def get_common_denominator(self, tree_list, file_tree_map):
>          """Finds a common tree by finding the longest common prefix.
>          Examples for expected output:
>            dpdk-next-virtio + dpdk = dpdk
> @@ -278,7 +280,6 @@ class Maintainers(object):
>          """
>          # Make sure the list is unique.
>          tree_list = list(set(tree_list))
> -
>          # Rename dpdk-next-virtio internally to match dpdk-next-net
>          _tree_list = [
>                  tree.replace('dpdk-next-virtio', 'dpdk-next-net-virtio')

Any reason why this whitespace is dropped here?  Otherwise, the patch
looks okay - but I don't think this line should be dropped.

If you agree, I can correct when I merge it.

> @@ -286,11 +287,31 @@ class Maintainers(object):
>          common_prefix = \
>              os.path.commonprefix(_tree_list).rstrip('-').replace(
>                      'dpdk-next-net-virtio', 'dpdk-next-virtio')
> -        # There is no 'dpdk-next' named tree.
> -        if common_prefix.endswith('dpdk-next') or common_prefix.endswith('/'):
> +        # There is no 'dpdk-next' named tree, remove files that belong
> +        # to 'drivers/common' and see if we find a tree.
> +        if common_prefix.endswith('dpdk-next'):
> +            common_prefix = self.get_filtered_tree(file_tree_map)
> +        elif common_prefix.endswith('/'):
>              common_prefix = 'git://dpdk.org/dpdk'
>          return common_prefix
>
> +    def get_common_files(self, files):
> +        match_list = []
> +        for f in files:
> +            if re.match(r"drivers\/common", f) is not None:
> +                match_list.append(f)
> +        return match_list
> +
> +    def get_filtered_tree(self, file_tree_map):
> +        # Get list of files that are in 'drivers/common'
> +        common_list = self.get_common_files(file_tree_map.keys())
> +        for c in common_list:
> +            file_tree_map.pop(c, None)
> +        tree_list = list(set(file_tree_map.values()))
> +        if len(tree_list) == 1:
> +            return tree_list[0]
> +        return None
> +
>
>  if __name__ == '__main__':
>      """Main procedure."""
> --
> 2.25.1
  
Pavan Nikhilesh Bhagavatula Oct. 13, 2023, 5:55 a.m. UTC | #2
> > From: Pavan Nikhilesh <pbhagavatula@marvell.com>
> >
> > When longest prefix match doesnt find a suitable tree, remove the
> > trees of files belonging to 'drivers/common' and check if there
> > is any unique tree for the patchset.
> >
> > Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> > ---
> >  v2 Chnages:
> >  - Find tree by removing 'drivers/common' instead of count based
> >  approach.
> >
> >  tools/pw_maintainers_cli.py | 31 ++++++++++++++++++++++++++-----
> >  1 file changed, 26 insertions(+), 5 deletions(-)
> >
> > diff --git a/tools/pw_maintainers_cli.py b/tools/pw_maintainers_cli.py
> > index c7b5ba0..ef60df8 100755
> > --- a/tools/pw_maintainers_cli.py
> > +++ b/tools/pw_maintainers_cli.py
> > @@ -203,13 +203,15 @@ class Maintainers(object):
> >          """
> >          Return a git tree that matches a list of files."""
> >          tree_list = []
> > +        file_tree_map = {}
> >          for _file in files:
> >              _tree = self._get_tree(_file)
> >              # Having no tree means that we accept those changes going through
> a
> >              # subtree (e.g. release notes).
> >              if _tree:
> >                  tree_list.append(_tree)
> > -        tree = self.get_common_denominator(tree_list)
> > +                file_tree_map[_file] = _tree
> > +        tree = self.get_common_denominator(tree_list, file_tree_map)
> >          if not tree:
> >              tree = 'git://dpdk.org/dpdk'
> >          return tree
> > @@ -268,7 +270,7 @@ class Maintainers(object):
> >          self.matched[matching_pattern] = tree
> >          return tree
> >
> > -    def get_common_denominator(self, tree_list):
> > +    def get_common_denominator(self, tree_list, file_tree_map):
> >          """Finds a common tree by finding the longest common prefix.
> >          Examples for expected output:
> >            dpdk-next-virtio + dpdk = dpdk
> > @@ -278,7 +280,6 @@ class Maintainers(object):
> >          """
> >          # Make sure the list is unique.
> >          tree_list = list(set(tree_list))
> > -
> >          # Rename dpdk-next-virtio internally to match dpdk-next-net
> >          _tree_list = [
> >                  tree.replace('dpdk-next-virtio', 'dpdk-next-net-virtio')
> 
> Any reason why this whitespace is dropped here?  Otherwise, the patch
> looks okay - but I don't think this line should be dropped.

The new line removal can be ignored.

> 
> If you agree, I can correct when I merge it.
> 

Yes, please.

Thanks, 
Pavan.

> > @@ -286,11 +287,31 @@ class Maintainers(object):
> >          common_prefix = \
> >              os.path.commonprefix(_tree_list).rstrip('-').replace(
> >                      'dpdk-next-net-virtio', 'dpdk-next-virtio')
> > -        # There is no 'dpdk-next' named tree.
> > -        if common_prefix.endswith('dpdk-next') or
> common_prefix.endswith('/'):
> > +        # There is no 'dpdk-next' named tree, remove files that belong
> > +        # to 'drivers/common' and see if we find a tree.
> > +        if common_prefix.endswith('dpdk-next'):
> > +            common_prefix = self.get_filtered_tree(file_tree_map)
> > +        elif common_prefix.endswith('/'):
> >              common_prefix = 'git://dpdk.org/dpdk'
> >          return common_prefix
> >
> > +    def get_common_files(self, files):
> > +        match_list = []
> > +        for f in files:
> > +            if re.match(r"drivers\/common", f) is not None:
> > +                match_list.append(f)
> > +        return match_list
> > +
> > +    def get_filtered_tree(self, file_tree_map):
> > +        # Get list of files that are in 'drivers/common'
> > +        common_list = self.get_common_files(file_tree_map.keys())
> > +        for c in common_list:
> > +            file_tree_map.pop(c, None)
> > +        tree_list = list(set(file_tree_map.values()))
> > +        if len(tree_list) == 1:
> > +            return tree_list[0]
> > +        return None
> > +
> >
> >  if __name__ == '__main__':
> >      """Main procedure."""
> > --
> > 2.25.1
  
Pavan Nikhilesh Bhagavatula Dec. 7, 2023, 1:33 p.m. UTC | #3
> -----Original Message-----
> From: Pavan Nikhilesh Bhagavatula <pbhagavatula@marvell.com>
> Sent: Friday, October 13, 2023 11:25 AM
> To: Aaron Conole <aconole@redhat.com>
> Cc: Jerin Jacob Kollanukkaran <jerinj@marvell.com>; alialnu@nvidia.com;
> thomas@monjalon.net; david.marchand@redhat.com; ci@dpdk.org
> Subject: RE: [EXT] Re: [PATCH v2] pw_maintainers_cli: enhance ci tree
> selection
> 
> > > From: Pavan Nikhilesh <pbhagavatula@marvell.com>
> > >
> > > When longest prefix match doesnt find a suitable tree, remove the
> > > trees of files belonging to 'drivers/common' and check if there
> > > is any unique tree for the patchset.
> > >
> > > Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> > > ---
> > >  v2 Chnages:
> > >  - Find tree by removing 'drivers/common' instead of count based
> > >  approach.
> > >
> > >  tools/pw_maintainers_cli.py | 31 ++++++++++++++++++++++++++-----
> > >  1 file changed, 26 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/tools/pw_maintainers_cli.py b/tools/pw_maintainers_cli.py
> > > index c7b5ba0..ef60df8 100755
> > > --- a/tools/pw_maintainers_cli.py
> > > +++ b/tools/pw_maintainers_cli.py
> > > @@ -203,13 +203,15 @@ class Maintainers(object):
> > >          """
> > >          Return a git tree that matches a list of files."""
> > >          tree_list = []
> > > +        file_tree_map = {}
> > >          for _file in files:
> > >              _tree = self._get_tree(_file)
> > >              # Having no tree means that we accept those changes going
> through
> > a
> > >              # subtree (e.g. release notes).
> > >              if _tree:
> > >                  tree_list.append(_tree)
> > > -        tree = self.get_common_denominator(tree_list)
> > > +                file_tree_map[_file] = _tree
> > > +        tree = self.get_common_denominator(tree_list, file_tree_map)
> > >          if not tree:
> > >              tree = 'git://dpdk.org/dpdk'
> > >          return tree
> > > @@ -268,7 +270,7 @@ class Maintainers(object):
> > >          self.matched[matching_pattern] = tree
> > >          return tree
> > >
> > > -    def get_common_denominator(self, tree_list):
> > > +    def get_common_denominator(self, tree_list, file_tree_map):
> > >          """Finds a common tree by finding the longest common prefix.
> > >          Examples for expected output:
> > >            dpdk-next-virtio + dpdk = dpdk
> > > @@ -278,7 +280,6 @@ class Maintainers(object):
> > >          """
> > >          # Make sure the list is unique.
> > >          tree_list = list(set(tree_list))
> > > -
> > >          # Rename dpdk-next-virtio internally to match dpdk-next-net
> > >          _tree_list = [
> > >                  tree.replace('dpdk-next-virtio', 'dpdk-next-net-virtio')
> >
> > Any reason why this whitespace is dropped here?  Otherwise, the patch
> > looks okay - but I don't think this line should be dropped.
> 
> The new line removal can be ignored.
> 
> >
> > If you agree, I can correct when I merge it.
> >
> 
> Yes, please.
> 

Ping

> Thanks,
> Pavan.
> 
> > > @@ -286,11 +287,31 @@ class Maintainers(object):
> > >          common_prefix = \
> > >              os.path.commonprefix(_tree_list).rstrip('-').replace(
> > >                      'dpdk-next-net-virtio', 'dpdk-next-virtio')
> > > -        # There is no 'dpdk-next' named tree.
> > > -        if common_prefix.endswith('dpdk-next') or
> > common_prefix.endswith('/'):
> > > +        # There is no 'dpdk-next' named tree, remove files that belong
> > > +        # to 'drivers/common' and see if we find a tree.
> > > +        if common_prefix.endswith('dpdk-next'):
> > > +            common_prefix = self.get_filtered_tree(file_tree_map)
> > > +        elif common_prefix.endswith('/'):
> > >              common_prefix = 'git://dpdk.org/dpdk'
> > >          return common_prefix
> > >
> > > +    def get_common_files(self, files):
> > > +        match_list = []
> > > +        for f in files:
> > > +            if re.match(r"drivers\/common", f) is not None:
> > > +                match_list.append(f)
> > > +        return match_list
> > > +
> > > +    def get_filtered_tree(self, file_tree_map):
> > > +        # Get list of files that are in 'drivers/common'
> > > +        common_list = self.get_common_files(file_tree_map.keys())
> > > +        for c in common_list:
> > > +            file_tree_map.pop(c, None)
> > > +        tree_list = list(set(file_tree_map.values()))
> > > +        if len(tree_list) == 1:
> > > +            return tree_list[0]
> > > +        return None
> > > +
> > >
> > >  if __name__ == '__main__':
> > >      """Main procedure."""
> > > --
> > > 2.25.1
  
Aaron Conole Dec. 7, 2023, 1:44 p.m. UTC | #4
Pavan Nikhilesh Bhagavatula <pbhagavatula@marvell.com> writes:

>> -----Original Message-----
>> From: Pavan Nikhilesh Bhagavatula <pbhagavatula@marvell.com>
>> Sent: Friday, October 13, 2023 11:25 AM
>> To: Aaron Conole <aconole@redhat.com>
>> Cc: Jerin Jacob Kollanukkaran <jerinj@marvell.com>; alialnu@nvidia.com;
>> thomas@monjalon.net; david.marchand@redhat.com; ci@dpdk.org
>> Subject: RE: [EXT] Re: [PATCH v2] pw_maintainers_cli: enhance ci tree
>> selection
>> 
>> > > From: Pavan Nikhilesh <pbhagavatula@marvell.com>
>> > >
>> > > When longest prefix match doesnt find a suitable tree, remove the
>> > > trees of files belonging to 'drivers/common' and check if there
>> > > is any unique tree for the patchset.
>> > >
>> > > Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
>> > > ---
>> > >  v2 Chnages:
>> > >  - Find tree by removing 'drivers/common' instead of count based
>> > >  approach.
>> > >
>> > >  tools/pw_maintainers_cli.py | 31 ++++++++++++++++++++++++++-----
>> > >  1 file changed, 26 insertions(+), 5 deletions(-)
>> > >
>> > > diff --git a/tools/pw_maintainers_cli.py b/tools/pw_maintainers_cli.py
>> > > index c7b5ba0..ef60df8 100755
>> > > --- a/tools/pw_maintainers_cli.py
>> > > +++ b/tools/pw_maintainers_cli.py
>> > > @@ -203,13 +203,15 @@ class Maintainers(object):
>> > >          """
>> > >          Return a git tree that matches a list of files."""
>> > >          tree_list = []
>> > > +        file_tree_map = {}
>> > >          for _file in files:
>> > >              _tree = self._get_tree(_file)
>> > >              # Having no tree means that we accept those changes going
>> through
>> > a
>> > >              # subtree (e.g. release notes).
>> > >              if _tree:
>> > >                  tree_list.append(_tree)
>> > > -        tree = self.get_common_denominator(tree_list)
>> > > +                file_tree_map[_file] = _tree
>> > > +        tree = self.get_common_denominator(tree_list, file_tree_map)
>> > >          if not tree:
>> > >              tree = 'git://dpdk.org/dpdk'
>> > >          return tree
>> > > @@ -268,7 +270,7 @@ class Maintainers(object):
>> > >          self.matched[matching_pattern] = tree
>> > >          return tree
>> > >
>> > > -    def get_common_denominator(self, tree_list):
>> > > +    def get_common_denominator(self, tree_list, file_tree_map):
>> > >          """Finds a common tree by finding the longest common prefix.
>> > >          Examples for expected output:
>> > >            dpdk-next-virtio + dpdk = dpdk
>> > > @@ -278,7 +280,6 @@ class Maintainers(object):
>> > >          """
>> > >          # Make sure the list is unique.
>> > >          tree_list = list(set(tree_list))
>> > > -
>> > >          # Rename dpdk-next-virtio internally to match dpdk-next-net
>> > >          _tree_list = [
>> > >                  tree.replace('dpdk-next-virtio', 'dpdk-next-net-virtio')
>> >
>> > Any reason why this whitespace is dropped here?  Otherwise, the patch
>> > looks okay - but I don't think this line should be dropped.
>> 
>> The new line removal can be ignored.
>> 
>> >
>> > If you agree, I can correct when I merge it.
>> >
>> 
>> Yes, please.
>> 
>
> Ping

Apologies - applied, Thanks!

>> Thanks,
>> Pavan.
>> 
>> > > @@ -286,11 +287,31 @@ class Maintainers(object):
>> > >          common_prefix = \
>> > >              os.path.commonprefix(_tree_list).rstrip('-').replace(
>> > >                      'dpdk-next-net-virtio', 'dpdk-next-virtio')
>> > > -        # There is no 'dpdk-next' named tree.
>> > > -        if common_prefix.endswith('dpdk-next') or
>> > common_prefix.endswith('/'):
>> > > +        # There is no 'dpdk-next' named tree, remove files that belong
>> > > +        # to 'drivers/common' and see if we find a tree.
>> > > +        if common_prefix.endswith('dpdk-next'):
>> > > +            common_prefix = self.get_filtered_tree(file_tree_map)
>> > > +        elif common_prefix.endswith('/'):
>> > >              common_prefix = 'git://dpdk.org/dpdk'
>> > >          return common_prefix
>> > >
>> > > +    def get_common_files(self, files):
>> > > +        match_list = []
>> > > +        for f in files:
>> > > +            if re.match(r"drivers\/common", f) is not None:
>> > > +                match_list.append(f)
>> > > +        return match_list
>> > > +
>> > > +    def get_filtered_tree(self, file_tree_map):
>> > > +        # Get list of files that are in 'drivers/common'
>> > > +        common_list = self.get_common_files(file_tree_map.keys())
>> > > +        for c in common_list:
>> > > +            file_tree_map.pop(c, None)
>> > > +        tree_list = list(set(file_tree_map.values()))
>> > > +        if len(tree_list) == 1:
>> > > +            return tree_list[0]
>> > > +        return None
>> > > +
>> > >
>> > >  if __name__ == '__main__':
>> > >      """Main procedure."""
>> > > --
>> > > 2.25.1
  

Patch

diff --git a/tools/pw_maintainers_cli.py b/tools/pw_maintainers_cli.py
index c7b5ba0..ef60df8 100755
--- a/tools/pw_maintainers_cli.py
+++ b/tools/pw_maintainers_cli.py
@@ -203,13 +203,15 @@  class Maintainers(object):
         """
         Return a git tree that matches a list of files."""
         tree_list = []
+        file_tree_map = {}
         for _file in files:
             _tree = self._get_tree(_file)
             # Having no tree means that we accept those changes going through a
             # subtree (e.g. release notes).
             if _tree:
                 tree_list.append(_tree)
-        tree = self.get_common_denominator(tree_list)
+                file_tree_map[_file] = _tree
+        tree = self.get_common_denominator(tree_list, file_tree_map)
         if not tree:
             tree = 'git://dpdk.org/dpdk'
         return tree
@@ -268,7 +270,7 @@  class Maintainers(object):
         self.matched[matching_pattern] = tree
         return tree

-    def get_common_denominator(self, tree_list):
+    def get_common_denominator(self, tree_list, file_tree_map):
         """Finds a common tree by finding the longest common prefix.
         Examples for expected output:
           dpdk-next-virtio + dpdk = dpdk
@@ -278,7 +280,6 @@  class Maintainers(object):
         """
         # Make sure the list is unique.
         tree_list = list(set(tree_list))
-
         # Rename dpdk-next-virtio internally to match dpdk-next-net
         _tree_list = [
                 tree.replace('dpdk-next-virtio', 'dpdk-next-net-virtio')
@@ -286,11 +287,31 @@  class Maintainers(object):
         common_prefix = \
             os.path.commonprefix(_tree_list).rstrip('-').replace(
                     'dpdk-next-net-virtio', 'dpdk-next-virtio')
-        # There is no 'dpdk-next' named tree.
-        if common_prefix.endswith('dpdk-next') or common_prefix.endswith('/'):
+        # There is no 'dpdk-next' named tree, remove files that belong
+        # to 'drivers/common' and see if we find a tree.
+        if common_prefix.endswith('dpdk-next'):
+            common_prefix = self.get_filtered_tree(file_tree_map)
+        elif common_prefix.endswith('/'):
             common_prefix = 'git://dpdk.org/dpdk'
         return common_prefix

+    def get_common_files(self, files):
+        match_list = []
+        for f in files:
+            if re.match(r"drivers\/common", f) is not None:
+                match_list.append(f)
+        return match_list
+
+    def get_filtered_tree(self, file_tree_map):
+        # Get list of files that are in 'drivers/common'
+        common_list = self.get_common_files(file_tree_map.keys())
+        for c in common_list:
+            file_tree_map.pop(c, None)
+        tree_list = list(set(file_tree_map.values()))
+        if len(tree_list) == 1:
+            return tree_list[0]
+        return None
+

 if __name__ == '__main__':
     """Main procedure."""