Merge "Update assignment script to output to projects.yaml file"
This commit is contained in:
commit
ce14fd18e7
@ -2,7 +2,7 @@
|
|||||||
rules:
|
rules:
|
||||||
line-length:
|
line-length:
|
||||||
# Allow some of our longer URLs
|
# Allow some of our longer URLs
|
||||||
max: 90
|
max: 95
|
||||||
allow-non-breakable-words: yes # Default
|
allow-non-breakable-words: yes # Default
|
||||||
allow-non-breakable-inline-mappings: no # Default
|
allow-non-breakable-inline-mappings: no # Default
|
||||||
truthy: disable
|
truthy: disable
|
||||||
|
@ -20,3 +20,13 @@ def load_project_file(filename='reference/projects.yaml'):
|
|||||||
f.read(),
|
f.read(),
|
||||||
Loader=yamlordereddictloader.Loader,
|
Loader=yamlordereddictloader.Loader,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def write_project_file(data, filename='reference/projects.yaml'):
|
||||||
|
with open(filename, 'w', encoding='utf-8') as f:
|
||||||
|
yaml.dump(
|
||||||
|
data,
|
||||||
|
f,
|
||||||
|
default_flow_style=False,
|
||||||
|
Dumper=yamlordereddictloader.Dumper,
|
||||||
|
)
|
||||||
|
@ -15,9 +15,7 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import collections
|
import collections
|
||||||
import random
|
import random
|
||||||
import textwrap
|
|
||||||
|
|
||||||
from openstack_governance import _wiki
|
|
||||||
from openstack_governance import members
|
from openstack_governance import members
|
||||||
from openstack_governance import projects
|
from openstack_governance import projects
|
||||||
|
|
||||||
@ -34,6 +32,16 @@ def main():
|
|||||||
default='reference/projects.yaml',
|
default='reference/projects.yaml',
|
||||||
help='location of projects.yaml, (%(default)s)',
|
help='location of projects.yaml, (%(default)s)',
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--replace-all',
|
||||||
|
action='store_true',
|
||||||
|
help='Replace all assigned liasons (%(default)s)',
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--remove-all',
|
||||||
|
action='store_true',
|
||||||
|
help='Remove all assigned liasons (%(default)s)',
|
||||||
|
)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
member_nics = [
|
member_nics = [
|
||||||
@ -42,60 +50,42 @@ def main():
|
|||||||
]
|
]
|
||||||
|
|
||||||
project_data = projects.load_project_file(args.projects_file)
|
project_data = projects.load_project_file(args.projects_file)
|
||||||
project_names = list(project_data.keys())
|
|
||||||
|
|
||||||
num_teams = len(project_names)
|
num_teams = len(project_data)
|
||||||
assignments_per = num_teams // (len(member_nics) // 2)
|
assignments_per = num_teams // (len(member_nics) // 2)
|
||||||
|
|
||||||
print('TEAMS', num_teams)
|
|
||||||
print('TC ', len(member_nics))
|
|
||||||
print('PER ', assignments_per)
|
|
||||||
|
|
||||||
# Determine how many assignments everyone has by reading the wiki
|
|
||||||
# page.
|
|
||||||
|
|
||||||
project_to_liaisons = _wiki.get_liaison_data()
|
|
||||||
|
|
||||||
member_counts = collections.Counter({
|
member_counts = collections.Counter({
|
||||||
nic: 0
|
nic: 0
|
||||||
for nic in member_nics
|
for nic in member_nics
|
||||||
})
|
})
|
||||||
for team, liaisons in project_to_liaisons.items():
|
for _, team in project_data.items():
|
||||||
for member in liaisons:
|
for member in team.get('liasons', []):
|
||||||
member_counts.update({member: 1})
|
member_counts.update({member: 1})
|
||||||
|
|
||||||
print('\nAlready assigned:')
|
|
||||||
for member, count in sorted(member_counts.items()):
|
|
||||||
print('{:12}: {}'.format(member, count))
|
|
||||||
|
|
||||||
choices = []
|
choices = []
|
||||||
for member, count in sorted(member_counts.items()):
|
for member, count in sorted(member_counts.items()):
|
||||||
choices.extend([member] * (assignments_per - count))
|
choices.extend([member] * (assignments_per - count))
|
||||||
|
|
||||||
# Make sure we have a list in order that isn't assigning the same
|
# Make sure we have a list in order that isn't assigning the same
|
||||||
# person to a team twice.
|
# person to a team twice.
|
||||||
print()
|
|
||||||
for team, liaisons in project_to_liaisons.items():
|
for name, team in project_data.items():
|
||||||
while len(liaisons) < 2:
|
liasons = team.get('liasons', [])
|
||||||
|
if args.remove_all:
|
||||||
|
team['liasons'] = []
|
||||||
|
continue
|
||||||
|
if args.replace_all:
|
||||||
|
liasons = []
|
||||||
|
while len(liasons) < 2:
|
||||||
random.shuffle(choices)
|
random.shuffle(choices)
|
||||||
next_choice = choices.pop()
|
next_choice = choices.pop()
|
||||||
while next_choice in liaisons:
|
while next_choice in liasons:
|
||||||
choices.insert(0, next_choice)
|
choices.insert(0, next_choice)
|
||||||
next_choice = choices.pop()
|
next_choice = choices.pop()
|
||||||
print('assigning {} to {}'.format(next_choice, team))
|
liasons.append(next_choice)
|
||||||
liaisons.append(next_choice)
|
team['liasons'] = liasons
|
||||||
|
|
||||||
print(textwrap.dedent('''
|
projects.write_project_file(project_data, args.projects_file)
|
||||||
=== Project Teams ===
|
|
||||||
|
|
||||||
{| class="wikitable"
|
|
||||||
|-
|
|
||||||
! Group !! TC members'''))
|
|
||||||
|
|
||||||
for team, liaisons in project_to_liaisons.items():
|
|
||||||
print('|-\n| {} || {}'.format(team, ', '.join(liaisons)))
|
|
||||||
|
|
||||||
print('|}\n')
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user