Пример #1
0
def available():

    # put alumni here or remove them from members.yaml and doodle poll
    left = ['Camila', 'Paul A', 'Jaehong']

    # read in the list of members and their presenting histories
    with open('members.yaml', 'r') as fd:
        members = yaml.load(fd)

    # scrape the available poll for next2_thursday
    doodle_poll = scrape_doodle("http://doodle.com/poll/umri2w7pxqnged37")
    next2_thursday = simslunch_time().strftime("%-m/%-d/%y")
    doodle_poll.replace('q', False)
    doodle_poll = doodle_poll.astype(np.bool)

    # update the 'available' property
    unavailable = list(doodle_poll.columns[doodle_poll.loc[next2_thursday,
                                                           'unavailable']])
    for name in members.keys():
        if name in unavailable or name in left:
            members[name]['available'] = 0
        else:
            members[name]['available'] = 1

    # write out the updated members list
    with open('members.yaml', 'w') as fd:
        yaml.safe_dump(members, fd)
Пример #2
0
def available():

    left = []

    # read in the list of members
    with open('members.yaml', 'r') as fd:
        members = yaml.load(fd)

    # reads doodle poll response for the particular week
    doodle_poll = scrape_doodle("http://doodle.com/poll/pd7rn7esk4q5vuft")
    next_monday = groupmeeting_time().strftime("%m/%d/%y")
    doodle_poll = doodle_poll.replace('q', False)
    doodle_poll = doodle_poll.astype(np.bool)

    unavailable = list(doodle_poll.columns[doodle_poll.loc[next_monday,
                                                           'unavailable']])
    # each member is marked available or not for that particular meeting based on their doodle poll response
    for name in members.keys():
        if name in unavailable or name in left:
            members[name]['available'] = 0
        else:
            members[name]['available'] = 1

    # write out the updated members list
    with open('members.yaml', 'w') as fd:
        yaml.safe_dump(members, fd)
Пример #3
0
def available():

    left = ['Camila', 'Paul A']

    # read in the list of members and their presenting histories
    with open('members.yaml', 'r') as fd:
        members = yaml.load(fd)
    
    doodle_poll = scrape_doodle("http://doodle.com/poll/umri2w7pxqnged37")
    next2_thursday = simslunch_time().strftime("%-m/%-d/%y")

    unavailable = list(doodle_poll.columns[doodle_poll.loc[next2_thursday, 'unavailable']])
    for name in members.keys():   
        if name in unavailable or name in left:
            members[name]['available'] = 0
        else:
            members[name]['available'] = 1

    # write out the updated members list
    with open('members.yaml', 'w') as fd:
        yaml.safe_dump(members, fd)
Пример #4
0
def available():

    left = []

    # read in the list of members and their presenting histories
    with open('members.yaml', 'r') as fd:
        members = yaml.load(fd)
    
    doodle_poll = scrape_doodle("http://doodle.com/poll/pd7rn7esk4q5vuft")
    next_monday = groupmeeting_time().strftime("%m/%d/%y")

    unavailable = list(doodle_poll.columns[doodle_poll.loc[next_monday, 'unavailable']])
    for name in members.keys():   
        if name in unavailable or name in left:
            members[name]['available'] = 0
        else:
            members[name]['available'] = 1

    # write out the updated members list
    with open('members.yaml', 'w') as fd:
        yaml.safe_dump(members, fd)
Пример #5
0
def make_selection():

    now = datetime.datetime.now()
    tick_end = datetime.datetime(now.year, now.month, now.day-datetime.date.today().weekday(), 17,0,0,0)
    if now < tick_end:
        print(colored("THIS IS NOT THE TIME!!!",'red'))
        #return

    femail1 = open('email1.txt', 'w')
    femail4 = open('email4.txt', 'w')
    femail1.write('Hi there,\n\nLet me remind you that you are the chair and speaker(s) for next week. (http://qyx268.github.io/astromeeting_site/)\n\nHere are the details:\n')
    femail4.write('Hi there,\n\nYou are selected to be the chair and speaker(s) for the group meeting to be held 4 weeks later (http://qyx268.github.io/astromeeting_site/)\n\nHere are the details:\n')
    femail1.write('date: %s\n'%groupmeeting_time(week=1).strftime("%d. %B %Y"))
    femail4.write('date: %s\n'%groupmeeting_time(week=4).strftime("%d. %B %Y"))

    half_talk_list = ['master', 'phd_junior']
    exception_list = {'chairs':{'',} ,'speakers':{'Stuart Wyithe',}} 

    # read in the list of members and their presenting histories
    with open('members.yaml', 'r') as fd:
        members = yaml.load(fd)

    # convert to a pandas dataframe
    members = pd.DataFrame.from_dict(members).T
    members.index.name = 'name'

    # Temporarily increment the contribution counts to include future volunteers
    doodle_poll = scrape_doodle("http://doodle.com/poll/psdh3untd9dqedzi")
    next4_monday = groupmeeting_time().strftime("%m/%d/%y")
    volunteers = {}
    for t in ('chair', 'speaker'):
        volunteers[t] = list(doodle_poll.columns[doodle_poll.loc[next4_monday, t]])
    for name in doodle_poll.columns:
        for contribution in ('chairs', 'speakers'):
            members.loc[name][contribution] += np.count_nonzero(doodle_poll[name].loc[:, contribution[:-1]])

    # pickle the doodle poll for later use
    with open("doodle_poll.pkl", "wb") as fd:
        pickle.dump(doodle_poll, fd)

    # cut down the members to just those who are available this coming week and
    # split by type
    print(colored("Unavailable list: %s"%members[members.available==0].index,'red'))
    members = members[members.available==1] 

    if len(members)<2:
        print(colored("not enough people","red"))
        return

    presenters = dict(chair = "", speaker = "")
    volunteered = dict(chair = "", speaker = "")

    # select volunteers if there are any
    for k, l in iter(volunteers.items()):
        for v in l:
            presenters[k] = v
            volunteered[k] = True
            print(colored("Volunteer for "+k+" by "+v,'red'))
            femail4.write(v+" volunteered for "+k+'\n')

    # choose the chair presenters randomly from those who have presented the
    # minimum number of times.
    for contribution in ('chairs', 'speakers'):
        if not volunteered[contribution[:-1]]:
            mi = members[contribution].min()
            pool = list(members.query(contribution + ' == @mi').index)
            # some people are exception
            pool = set(pool) - exception_list[contribution]
            presenters[contribution[:-1]] = random.sample(pool, 1)[0]
    
    # try to avoid same person holding and speaking at the same time
    while presenters['chair'] == presenters['speaker']:
        if not volunteered['chair']:
            mi = members['chair'].min()
            pool = list(members.query('chair == @mi').index)
            presenters['chair'] = random.sample(pool, 1)[0]
        elif not volunteered['speaker']:
            mi = members['speaker'].min()
            pool = list(members.query('speaker == @mi').index)     
            presenters['speaker'] = random.sample(pool, 1)[0]
        else:
            # well unless this guy volunteered to do both
            print(colored(presenters['speaker']+'volunteered to do both','red'))
            break

    # masters or 1-st year phds are required to give 15 mins talk, so add an other one
    flag = 0
    if members['type'][presenters['speaker']] in half_talk_list:
        half_talk_members = members[members['type'].isin(half_talk_list)].drop(presenters['speaker'])
        mi = half_talk_members['speakers'].min()
        pool = list(half_talk_members.query('speakers == @mi').index)
        presenters['speaker']+=', '+random.sample(pool, 1)[0]
        flag = 1

    # upate the selected_presenters file
    with open('selected_presenters.yaml', 'r') as fd:
        selected_presenters = yaml.load(fd)
    
    next_monday = groupmeeting_time(week=1).strftime("%m/%d/%y")
    try:
        femail1.write('chair:\t%s (%s)\nspeaker:\t%s (%s)\n'%(selected_presenters[next_monday]['chair'],members['email'][selected_presenters[next_monday]['chair']],selected_presenters[next_monday]['speaker'],members['email'][selected_presenters[next_monday]['speaker']]))
    except KeyError:
        femail1.write('chair:\t%s (%s)\nspeaker:\t%s (%s)\n'%(selected_presenters[next_monday]['chair'],members['email'][selected_presenters[next_monday]['chair']],selected_presenters[next_monday]['speaker'],members['email'][selected_presenters[next_monday]['speaker'].split(', ')].values))


    selected_presenters.pop(groupmeeting_time(week=0).strftime("%m/%d/%y")) 
    selected_presenters[next4_monday]= presenters

    print(colored('%s'%presenters+'4 weeks later',"red"))
    print(colored('%s'%selected_presenters[next_monday]+'next week','red'))
    if flag:
        femail4.write('chair:\t%s (%s)\nspeaker:\t%s (%s)\n'%(presenters['chair'],members['email'][presenters['chair']],presenters['speaker'],members['email'][presenters['speaker'].split(', ')].values))
    else:
        femail4.write('chair:\t%s (%s)\nspeaker:\t%s (%s)\n'%(presenters['chair'],members['email'][presenters['chair']],presenters['speaker'],members['email'][presenters['speaker']]))
    with open("selected_presenters_tba.yaml", "w") as fd:
        yaml.safe_dump(selected_presenters, fd)

    femail1.write("\nPlease note that it will be the speaker's duty to prepare a talk (less than 30 minutes) on the astro-group meeting.\n")
    femail1.write("\nAnd it will be the chair's responsibility to\n\t1) supervise the speaker on preparing the talk, \n\t2) remind the astro group that you are the chair and collect agendas from them on Monday, \n\t3) send an announcement to the astro-people about 15 minutes before the group meeting, \n\t4) update the group meeting minutes on AstroWiki,\n\t5) prepare a cake (usually) on Wednesday afternoon. \n")
    femail1.write('\nIf you have swapped with other people, please forward this email :)\n')

    femail4.write("\nPlease note that it will be the speaker's duty to prepare a talk (less than 30 minutes) on the astro-group meeting.\n")
    femail4.write("\nAnd it will be the chair's responsibility to\n\t1) supervise the speaker on preparing the talk, \n\t2) remind the astro group that you are the chair and collect agendas from them on Monday, \n\t3) send an announcement to the astro-people about 15 minutes before the group meeting, \n\t4) update the group meeting minutes on AstroWiki,\n\t5) prepare a cake (usually) on Wednesday afternoon. \n")
    femail4.write('\nPlease confirm it by replying me or let me know as soon as possible if you cannot make it :)\n')
    femail4.write('If you only need to give a 15-minute talk but you are the only speaker selected, let me know and I will arrange one more speaker.\n')

    femail1.write('\nCheers,\nYuxiang')
    femail4.write('\nCheers,\nYuxiang')
    femail1.close()
    femail4.close()

    #double speaker:
    tmp = list(selected_presenters[next4_monday].values())
    email4 = members['email'][tmp[1].split(', ')+tmp[0].split(', ')]

    tmp = list(selected_presenters[next_monday].values())
    email1 = members['email'][tmp[1].split(', ')+tmp[0].split(', ')]
    print('mail -s "Speaker and chair on the astro-group meeting" "'+', '.join([people for people in email4])+'" <email4.txt')
    print('mail -s "Speaker and chair on the astro-group meeting" "'+', '.join([people for people in email1])+'" <email1.txt')
Пример #6
0
def make_selection():

    # check the clock, give people time to visit the doodle polls
    # the selection can be done after 5pm every Thursday
    # AND BEFORE SUNDAY!!!
    now = datetime.datetime.now()
    today = datetime.date.today()
    days_ahead = today.weekday() -3
    if days_ahead < 0:
        days_ahead += 7
    tick_end = datetime.datetime(now.year, now.month, now.day-days_ahead, 17,0,0,0)
    
    if now < tick_end:
        print(colored("THIS IS NOT THE TIME!!!",'red'))
        #return

    # read in the list of members and their presenting histories
    with open('members.yaml', 'r') as fd:
        members = yaml.load(fd)

    # convert to a pandas dataframe
    members = pd.DataFrame.from_dict(members).T
    members.index.name = 'name'
    emails = members.email
    
    # cut down the members to just those who are available this coming week 
    print(colored("Unavailable list: %s"%members[members.available==0].index.tolist(),'red'))
    members = members[members.available==1]                                           
                                                                                   
    # the meeting is better off when less than 4 participants
    if len(members)<4:                                                                
       print(colored("not enough people","red"))                                     
       return                                                                        

    # Temporarily increment the contribution counts to include future volunteers
    doodle_poll = scrape_doodle("http://doodle.com/poll/g3idnd5gfg8ck2ze")
    next2_thursday = simslunch_time(week=2).strftime("%-m/%-d/%y")
    doodle_poll[doodle_poll=='q']=False      
    doodle_poll = doodle_poll.astype(np.bool)
    for name in doodle_poll.columns:
        for contribution in ('papers', 'plots'):
            try:
                members.loc[name][contribution] += np.count_nonzero(doodle_poll[name].loc[:, contribution[:-1]])
            except KeyError:
                print(name+' is not here')

    # pickle the doodle poll for later use
    with open("doodle_poll.pkl", "wb") as fd:
        pickle.dump(doodle_poll, fd)

    presenters = dict(paper = "", plot = "") 

    # select volunteers if there are any
    volunteers = {}
    for t in ('paper', 'plot'):
        volunteers[t] = list(doodle_poll.columns[doodle_poll.loc[next2_thursday, t]])
    for k, l in iter(volunteers.items()):
        if len(l)>0:
            presenters[k] = l                                 
            print(colored("Volunteered for "+k+" by "+str(l)[1:-1],'red')) 
        else:
            presenters[k] = []

    # selected presenters list
    with open('selected_presenters.yaml', 'r') as fd: 
        selected_presenters = yaml.load(fd)
        
    this_thursday = simslunch_time(week=0).strftime("%m/%d/%y")
    next_thursday = simslunch_time(week=1).strftime("%m/%d/%y")
    next2_thursday = simslunch_time(week=2).strftime("%m/%d/%y")

    # choose the paper presenters randomly from those who have presented the
    # minimum number of times.
    for contribution in ('papers', 'plots'):
        offset = 0
        count_min = members[contribution].min()
        count_max = members[contribution].max()
        diff = count_max - count_min
        while (len(presenters[contribution[:-1]])<2) and (offset<=diff):
            mi = count_min+offset
            # you want to exclude volunteers and selected people next_thursday
            pool = list(set(members.query(contribution + ' == @mi').index) - set(presenters['paper']) - set(presenters['plot']) - set(selected_presenters[next_thursday][contribution[:-1]].split(', ')))
            # SELECTION!!!
            presenters[contribution[:-1]] += random.sample(pool, min(len(pool),2-len(presenters[contribution[:-1]])))
            offset +=1

    selected_presenters.pop(this_thursday)
    selected_presenters[next2_thursday] = dict(paper = "", plot = "")
    for contribution in ('papers', 'plots'): 
        selected_presenters[next2_thursday][contribution[:-1]] = ', '.join(presenters[contribution[:-1]])

    # save the updated selected_presenters file to selected_presenters_tba.yaml
    # it will be mv-ed to selected_presenters.yaml, which will be mv-ed to selected_presenters.yaml.bak in the same time
    with open("selected_presenters_tba.yaml", "w") as fd:  
        yaml.safe_dump(selected_presenters, fd)            

    # show me the result
    print(colored('Next week (%s):\npapers:\t%s\nplots:\t%s\n'%(next_thursday,selected_presenters[next_thursday]['paper'], selected_presenters[next_thursday]['plot']),'red'))
    print(colored('2 weeks later (%s):\npapers:\t%s\nplots:\t%s\n'%(next2_thursday,selected_presenters[next2_thursday]['paper'], selected_presenters[next2_thursday]['plot']),'red'))

    # write emails
    f = open('email.bash','w')
    for contribution in ('paper', 'plot'):
        for name in selected_presenters[next_thursday][contribution].split(', '):
            context = 'Hi %s,\n\nPlease allow me to remind you that you are the speaker (for %s) for the simulation lunch meeting next week (%s). (http://smutch.github.io/simslunch_site/index.html)\n\nCheers,\nYuxiang'%(name, contribution, simslunch_time(week=1).strftime("%d/%B/%y"))
            f.write("mail -s '(Next Week) speaker on the simulation lunch meeting' %s <<< '%s'\n"%(emails[name], context))
        for name in selected_presenters[next2_thursday][contribution].split(', '):
            if name in volunteers[contribution]:
                context = 'Hi %s,\n\nYou volunteered to be the speaker (for %s) for the simulation lunch meeting to be held 2 weeks later (%s). (http://smutch.github.io/simslunch_site/index.html)\nPlease let me know if you do not want to present a %s:)\n\nCheers,\nYuxiang'%(name, contribution, simslunch_time(week=2).strftime("%d/%B/%y"),contribution)
            else:
                context = 'Hi %s,\n\nYou are selected to be the speaker (for %s) for the simulation lunch meeting to be held 2 weeks later (%s). (http://smutch.github.io/simslunch_site/index.html)\nPlease let me know if you do not want to present a %s:)\n\nCheers,\nYuxiang'%(name, contribution, simslunch_time(week=2).strftime("%d/%B/%y"),contribution)
            f.write("mail -s '(2 Weeks Later) speaker on the simulation lunch meeting' %s <<< '%s'\n"%(emails[name], context))
    f.close()
Пример #7
0
def make_selection():

    now = datetime.datetime.now()
    today = datetime.date.today()
    days_ahead = today.weekday() -3
    if days_ahead < 0:
        days_ahead += 7
    tick_end = datetime.datetime(now.year, now.month, now.day-days_ahead, 17,0,0,0)
    
    if now < tick_end:
        print(colored("THIS IS NOT THE TIME!!!",'red'))
        #return

    # read in the list of members and their presenting histories
    with open('members.yaml', 'r') as fd:
        members = yaml.load(fd)

    # convert to a pandas dataframe
    members = pd.DataFrame.from_dict(members).T
    members.index.name = 'name'
    emails = members.email
    
    # cut down the members to just those who are available this coming week 
    print(colored("Unavailable list: %s"%members[members.available==0].index.item(),'red'))
    members = members[members.available==1]                                           
                                                                                   
    if len(members)<4:                                                                
       print(colored("not enough people","red"))                                     
       return                                                                        

    # Temporarily increment the contribution counts to include future volunteers
    doodle_poll = scrape_doodle("http://doodle.com/poll/g3idnd5gfg8ck2ze")
    this_thursday = simslunch_time(week=0).strftime("%-m/%-d/%y")
    next_thursday = simslunch_time(week=1).strftime("%-m/%-d/%y")
    next2_thursday = simslunch_time(week=2).strftime("%-m/%-d/%y")
    volunteers = {}
    for t in ('paper', 'plot'):
        volunteers[t] = list(doodle_poll.columns[doodle_poll.loc[next2_thursday, t]])
    for name in doodle_poll.columns:
        for contribution in ('papers', 'plots'):
            try:
                members.loc[name][contribution] += np.count_nonzero(doodle_poll[name].loc[:, contribution[:-1]])
            except KeyError:
                #print(name+' is not here')
                pass

    # pickle the doodle poll for later use
    with open("doodle_poll.pkl", "wb") as fd:
        pickle.dump(doodle_poll, fd)

    presenters = dict(paper = "", plot = "") 

    # select volunteers if there are any
    for k, l in iter(volunteers.items()):
        if len(l)>0:
            presenters[k] = l                                 
            print(colored("Volunteer for "+k+" by "+str(l)[1:-1],'red')) 
        else:
            presenters[k] = []

    # selected presenters list
    with open('selected_presenters.yaml', 'r') as fd: 
        selected_presenters = yaml.load(fd)

    # choose the paper presenters randomly from those who have presented the
    # minimum number of times.
    for contribution in ('papers', 'plots'):
        offset = 0
        count_min = members[contribution].min()
        count_max = members[contribution].max()
        diff = count_max - count_min
        while (len(presenters[contribution[:-1]])<2) and (offset<diff):
            mi = count_min+offset
            pool = list(set(members.query(contribution + ' == @mi').index) - set(presenters['paper']) - set(presenters['plot']) - set(selected_presenters[next_thursday][contribution[:-1]].split(', ')))
            presenters[contribution[:-1]] += random.sample(pool, min(len(pool),2-len(presenters[contribution[:-1]])))
            offset +=1

    selected_presenters.pop(this_thursday)
    selected_presenters[next2_thursday] = dict(paper = "", plot = "")
    for contribution in ('papers', 'plots'): 
        selected_presenters[next2_thursday][contribution[:-1]] = ', '.join(presenters[contribution[:-1]])
    print(presenters)

    with open("selected_presenters_tba.yaml", "w") as fd:  
        yaml.safe_dump(selected_presenters, fd)            

    print(colored('Next week (%s):\npapers:\t%s\nplots:\t%s\n'%(next_thursday,selected_presenters[next_thursday]['paper'], selected_presenters[next_thursday]['plot']),'red'))
    print(colored('2 week later (%s):\npapers:\t%s\nplots:\t%s\n'%(next2_thursday,selected_presenters[next2_thursday]['paper'], selected_presenters[next2_thursday]['plot']),'red'))

    f = open('email.bash','w')
    for contribution in ('paper', 'plot'):
        for name in selected_presenters[next_thursday][contribution].split(', '):
            context = 'Hi %s,\n\nPlease allow me to remind you that you are the speaker (for %s) for the simulation lunch meeting next week (%s). (http://smutch.github.io/simslunch_site/index.html)\n\nCheers,\nYuxiang'%(name, contribution, simslunch_time(week=1).strftime("%d/%B/%y"))
            f.write("mail -s '(Next Week) speaker on the simulation lunch meeting' %s <<< '%s'\n"%(emails[name], context))
        for name in selected_presenters[next2_thursday][contribution].split(', '):
            if name in volunteers[contribution]:
                context = 'Hi %s,\n\nYou volunteered to be the speaker (for %s) for the simulation lunch meeting to be held 2 weeks later (%s). (http://smutch.github.io/simslunch_site/index.html)\nPlease let me know if you do not want to present a %s:)\n\nCheers,\nYuxiang'%(name, contribution, simslunch_time(week=2).strftime("%d/%B/%y"),contribution)
            else:
                context = 'Hi %s,\n\nYou are selected to be the speaker (for %s) for the simulation lunch meeting to be held 2 weeks later (%s). (http://smutch.github.io/simslunch_site/index.html)\nPlease let me know if you do not want to present a %s:)\n\nCheers,\nYuxiang'%(name, contribution, simslunch_time(week=2).strftime("%d/%B/%y"),contribution)
            f.write("mail -s '(2 Weeks later) speaker on the simulation lunch meeting' %s <<< '%s'\n"%(emails[name], context))
    f.close()