Skip to content

Commit 3dae5ea

Browse files
Updates to Add New Mentors workflow (#664)
* updates * test fix
1 parent 7dbbc0e commit 3dae5ea

3 files changed

Lines changed: 25 additions & 26 deletions

File tree

tools/automation_mentors.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
TELEGRAM = 'telegram'
2626

2727
# Indexes for creating yaml sequences of data
28-
AREAS_START_INDEX = 14
29-
AREAS_END_INDEX = 18
30-
FOCUS_START_INDEX = 19
31-
FOCUS_END_INDEX = 23
32-
PROG_LANG_START_INDEX = 24
33-
PROG_LANG_END_INDEX = 28
28+
AREAS_START_INDEX = 13
29+
AREAS_END_INDEX = 17
30+
FOCUS_START_INDEX = 18
31+
FOCUS_END_INDEX = 22
32+
PROG_LANG_START_INDEX = 23
33+
PROG_LANG_END_INDEX = 27
3434

3535
type_ad_hoc = ("ad-hoc", "ad hoc")
3636
type_long_term = ("long-term", "long term")
@@ -263,18 +263,18 @@ def get_num_mentee_from_row(mentor_row):
263263
"""
264264
Gets the 'num_mentee' value for a new mentor from mentor_row, or use a default value if invalid.
265265
"""
266-
val = mentor_row.iloc[44]
266+
val = mentor_row.iloc[31]
267267

268268
return int(val) if pd.notna(val) else 0
269269

270270
def get_mentor_position(mentor_row):
271271
"""
272272
Returns formatted value for mentor role and company
273273
"""
274-
if not pd.isna(mentor_row.iloc[9]):
275-
return f"{mentor_row.iloc[8].strip()}, {mentor_row.iloc[9].strip()}"
274+
if not pd.isna(mentor_row.iloc[5]):
275+
return f"{mentor_row.iloc[4].strip()}, {mentor_row.iloc[5].strip()}"
276276
else:
277-
return mentor_row.iloc[8].strip()
277+
return mentor_row.iloc[4].strip()
278278

279279

280280
def xlsx_to_yaml_parser(mentor_row,
@@ -291,42 +291,42 @@ def xlsx_to_yaml_parser(mentor_row,
291291
focus = get_yaml_block_sequence(mentor_row, FOCUS_START_INDEX, FOCUS_END_INDEX)
292292
programming_languages = get_yaml_block_sequence(mentor_row, PROG_LANG_START_INDEX, PROG_LANG_END_INDEX)
293293

294-
mentor_image = f"{IMAGE_FILE_PATH}/{mentor_row.iloc[2].strip().lower().replace(' ', '_')}{IMAGE_SUFFIX}"
294+
mentor_image = f"{IMAGE_FILE_PATH}/{mentor_row.iloc[0].strip().lower().replace(' ', '_')}{IMAGE_SUFFIX}"
295295
# Format mentor role and company
296296
mentor_position = get_mentor_position(mentor_row)
297297

298-
mentor_type = get_mentorship_type(mentor_row.iloc[4])
298+
mentor_type = get_mentorship_type(mentor_row.iloc[6])
299299

300300
# If mentor is new i.e mentor_sort is 0 (from default input), get the correct num_mentees and sort values
301301
if mentor_sort == 0:
302302
num_mentee = get_num_mentee_from_row(mentor_row)
303303
mentor_sort = get_sort(mentor_type, current_period, num_mentee)
304304

305305
mentor = {
306-
'name': mentor_row.iloc[2].strip(),
306+
'name': mentor_row.iloc[0].strip(),
307307
'disabled': mentor_disabled,
308308
'matched': mentor_matched,
309309
'sort': mentor_sort,
310310
'num_mentee': num_mentee,
311311
'hours': extract_numbers_from_string(mentor_row.iloc[30]),
312312
'type': mentor_type,
313313
'index': mentor_index,
314-
'location': mentor_row.iloc[6],
314+
'location': mentor_row.iloc[3],
315315
'position': mentor_position,
316-
'bio': get_multiline_string(mentor_row.iloc[11]),
316+
'bio': get_multiline_string(mentor_row.iloc[10]),
317317
'image': get_multiline_string(mentor_image),
318-
'languages': mentor_row.iloc[7],
319-
'availability': add_availability(mentor_row.iloc[40]),
318+
'languages': mentor_row.iloc[8],
319+
'availability': add_availability(mentor_row.iloc[7]),
320320
'skills': {
321-
'experience': mentor_row.iloc[10],
322-
'years': extract_numbers_from_string(mentor_row.iloc[10]),
323-
'mentee': get_multiline_string(mentor_row.iloc[29]),
321+
'experience': mentor_row.iloc[9],
322+
'years': extract_numbers_from_string(mentor_row.iloc[9]),
323+
'mentee': get_multiline_string(mentor_row.iloc[28]),
324324
'areas': areas,
325325
'languages': ', '.join(programming_languages),
326326
'focus': focus,
327-
'extra': get_multiline_string(mentor_row.iloc[12])
327+
'extra': get_multiline_string(mentor_row.iloc[11])
328328
},
329-
'network': get_social_media_links(mentor_row.iloc[31], mentor_row.iloc[32]),
329+
'network': get_social_media_links(mentor_row.iloc[32], mentor_row.iloc[33]),
330330
}
331331
return mentor
332332

@@ -385,7 +385,7 @@ def get_all_mentors_in_yml_format(yml_file_path, xlsx_file_path, current_period,
385385
mentors = []
386386

387387
for row in range(0, len(df_mentors)):
388-
mentor_name = df_mentors.iloc[row].values[2].strip().lower()
388+
mentor_name = df_mentors.iloc[row].values[0].strip().lower()
389389

390390
df_yml_row = df_yml.loc[df_yml.Name == mentor_name]
391391

@@ -432,7 +432,7 @@ def get_new_mentors_in_yml_format(yml_file_path, xlsx_file_path, current_period,
432432
if df_mentors.iloc[row].isnull().all():
433433
break
434434

435-
mentor_name = df_mentors.iloc[row].values[2].strip().lower()
435+
mentor_name = df_mentors.iloc[row].values[0].strip().lower()
436436

437437
if df_yml.loc[df_yml.Name == mentor_name].empty:
438438
mentor = xlsx_to_yaml_parser(df_mentors.iloc[row], new_index, current_period)

tools/samples/mentors.xlsx

-14.7 KB
Binary file not shown.

tools/tests/automation_functional_test.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@ def test_write_mentors_skip_zero_rows(monkeypatch):
2020
run_automation()
2121

2222
result = read_yml_file(tmp_filename)
23-
assert len(result) == 3, f"Expected to write 3 mentors but added {len(result)}"
23+
assert len(result) == 2, f"Expected to write 2 mentors but added {len(result)}"
2424
assert MENTOR_2 == result[0]['name'], f"Expected content to be {MENTOR_2} but got '{result[0]['name']}'"
2525
assert MENTOR_3 == result[1]['name'], f"Expected content to be {MENTOR_3} but got '{result[1]['name']}'"
26-
assert MENTOR_4 == result[2]['name'], f"Expected content to be {MENTOR_4} but got '{result[2]['name']}'"
2726

2827
# Clean up the temporary file
2928
os.remove(tmp_filename)

0 commit comments

Comments
 (0)