Skip to content

Commit

Permalink
Ticket #216: make Server class comparable (#224)
Browse files Browse the repository at this point in the history
Fix "TypeError: '<' not supported between instances of 'Server' and
'Server'" class of error:
  File ".../Shine/Lustre/Component.py", line 424, in groupbyallservers
    sortlist = sorted(srvcomps, key=itemgetter(0))
TypeError: '<' not supported between instances of 'Server' and 'Server'

Signed-off-by: Dominique Martinet <[email protected]>
  • Loading branch information
degremont authored Jul 26, 2024
1 parent f1d95dc commit 11f329d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/Shine/Lustre/Server.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ def __init__(self, hostname, nids, hdlr=None):
def __str__(self):
return "%s (%s)" % (self.hostname, ','.join(self.nids))

def __lt__(self, other):
# Cast hostname into str until NodeSet is sortable
return (str(self.hostname), self.nids) < (str(other.hostname), self.nids)

@classmethod
def hostname_long(cls):
"""
Expand Down

0 comments on commit 11f329d

Please sign in to comment.