diff --git a/.github/workflows/adhoc_availability_prep.yml b/.github/workflows/adhoc_availability_prep.yml new file mode 100644 index 00000000..ae6660c1 --- /dev/null +++ b/.github/workflows/adhoc_availability_prep.yml @@ -0,0 +1,74 @@ +name: Update Mentor Availabilities for Monthly Ad-Hoc Prep + +on: + workflow_dispatch: + inputs: + month: + description: "Month number (e.g. 10 for October)" + required: true + file_id: + description: "Google Drive file ID of the Excel sheet with the availabilities" + required: true + +jobs: + update-mentors: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v5 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Cache pip + uses: actions/cache@v4 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('tools/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r tools/requirements.txt + + - name: Install and Configure rclone with Google Cloud service account + run: | + curl https://rclone.org/install.sh | sudo bash + echo '${{ secrets.GOOGLECLOUD_SERVICE_KEY_RETRIEVE_ADHOC_FILE_JSON }}' > service_account.json + rclone config create gdrive drive scope=drive service_account_file=service_account.json + + - name: Download spreadsheet from Google Drive + run: | + rclone backend copyid gdrive: ${{ github.event.inputs.file_id }} tools/adhoc.xlsx + + - name: Run script + run: | + cd tools + python automation_prepare_adhoc_availability.py adhoc.xlsx ${{ github.event.inputs.month }} + + - name: Cleanup files + if: always() + run: rm -f service_account.json tools/adhoc.xlsx + + - name: Create or Update Pull Request + uses: peter-evans/create-pull-request@v7 + with: + token: ${{ secrets.GHA_ACTIONS_ALLOW_TOKEN }} + commit-message: "updated mentor hours, availabilities, and sort for monthly adhoc prep" + branch: "automation/adhoc-monthly-prep" + team-reviewers: | + Women-Coding-Community/leaders + title: "[WCC Bot] Monthly Ad-hoc Prep - Month ${{ github.event.inputs.month }}" + body: | + This PR was created automatically by a GitHub Action that handles mentor data updates for the monthly ad-hoc preparation. + Only `_data/mentors.yml` should be updated. + + Please review the changes `_data/mentors.yml` and ensure that the changes are as expected before merging (Review the availability sheet used). + labels: | + automation + adhoc-prep diff --git a/.github/workflows/import_meetup_events.yml b/.github/workflows/import_meetup_events.yml index 17a96eef..7582037e 100644 --- a/.github/workflows/import_meetup_events.yml +++ b/.github/workflows/import_meetup_events.yml @@ -45,7 +45,7 @@ jobs: - name: Create or Update Pull Request uses: peter-evans/create-pull-request@v7 with: - token: ${{ secrets.MEETUP_IMPORT_ACTIONS_TOKEN }} + token: ${{ secrets.GHA_ACTIONS_ALLOW_TOKEN }} commit-message: "Automated import of Meetup events" branch: "automation/import-meetup-events" team-reviewers: "Women-Coding-Community/leaders" diff --git a/_data/mentors.yml b/_data/mentors.yml index 2d290643..c0552d7f 100644 --- a/_data/mentors.yml +++ b/_data/mentors.yml @@ -2824,7 +2824,7 @@ - Grow beyond senior level extra: Focus areas for aspiring data scientists; transitioning into data science, building a roadmap, preparing for technical interviews, optimizing resume/LinkedIn, creating and showcasing portfolio projects, and communicating insights effectively. network: - - linkedin: https://www.linkedin.com/in/ilayda-yilmaz/ + - linkedin: https://www.linkedin.com/in/ilayda-yilmaz/ - name: Damola Taiwo disabled: false @@ -2891,7 +2891,7 @@ - Grow from mid-level to senior-level - Grow from beginner to mid-level - Switch career to IT - extra: + extra: | Data engineering best practices; Data architecture design and implementation; Transitioning from on-premises to cloud solutions (with focus on Databricks); Growing from junior to mid-level; Growing from mid-level to senior-level; Career development and strategic planning in data roles; Technology architecture & strategy; Career growth & soft skills; Navigating the job market and building a professional brand; Effective communication in technical teams diff --git a/tools/README.md b/tools/README.md index 0b6603c5..c3d83541 100644 --- a/tools/README.md +++ b/tools/README.md @@ -5,7 +5,11 @@ There are two automation scripts: 2) `download_image.py`: downloads image from a specified URL and saves in `assets/images/mentors` -3) `automation_create_mentor_spreadsheets.py`: creates spreadhseets for each longterm mentor with filenames like `WCC - Long Term - MentorName.xlsx`. All the files are saved in a folder named `Long Term Mentors`. It uses the data from `Mentorship Programme long-term Registration Form for Mentees (Responses).xlsx` sheetname `Revised Mentees`as input. +3) `meetup_import.py`: imports new upcoming events from the WCC MeetUp page using the iCal feed: https://www.meetup.com/women-coding-community/events/ical/ + +4) `automation_create_mentor_spreadsheets.py`: creates spreadhseets for each longterm mentor with filenames like `WCC - Long Term - MentorName.xlsx`. All the files are saved in a folder named `Long Term Mentors`. It uses the data from `Mentorship Programme long-term Registration Form for Mentees (Responses).xlsx` sheetname `Revised Mentees`as input. + +5) `automation_prepare_adhoc_availability.py`: updates mentors data with specified availability hours in `samples/adhoc-prep.xlsx` in preparation for monthly ad-hoc mentorship. ### Dependencies @@ -75,4 +79,18 @@ sh run_meetup_import.sh 📁 Long Term Mentors │── WCC - Long Term - Nonna Shakhova.xlsx │── WCC - Long Term - Rajani Rao.xlsx - │── WCC - Long Term - Gabriel Oliveira.xlsx └── (more mentor files...) \ No newline at end of file + │── WCC - Long Term - Gabriel Oliveira.xlsx └── (more mentor files...) + +#### E) `automation_prepare_adhoc_availability.py` + +```shell +sh run_adhoc_prep_automation.sh +``` +**Note:** +- If running locally, ensure to update `adhoc-prep.xslx` with the new data to be updated for the mentors. +- If using GitHub Actions, the GHA workflow for this script uses a Google Cloud service account setup to retrieve the file from Google Drive. The service key has been configured for womencodingcommunity Google Drive account and the file to be used/updated has been shared with the service account email. +Hence, to run the GHA workflow, you only need to provide: + - the month value (e.g 9 for September) and, + - the file ID for the excel sheet to use + +For more information on the GC service account configurations, you can read the [README](blog_automation/README.md) in the blog automation folder. diff --git a/tools/automation_prepare_adhoc_availability.py b/tools/automation_prepare_adhoc_availability.py new file mode 100644 index 00000000..b565db3b --- /dev/null +++ b/tools/automation_prepare_adhoc_availability.py @@ -0,0 +1,144 @@ +""" + Create a script that will update availability and hours for mentors in preparation for adhoc registration for a specified month +""" +# !/usr/bin/env python + +import logging +import sys +import pandas as pd +from ruamel.yaml import YAML + +yaml = YAML() +yaml.width = 4096 + +TYPE_LONG_TERM = "long-term" +TYPE_AD_HOC = "ad-hoc" +TYPE_BOTH = "both" + +MONTHS_MAP = { + 4: 'April', + 5: 'May', + 6: 'June', + 7: 'July', + 8: 'August', + 9: 'September', + 10: 'October', + 11: 'November' +} + + +def get_available_mentor_sort(mentor, current_availability): + """ + Returns sort value for available mentors ONLY if: + - mentor is new (current availability still contains full list of months), sort to highest: 500 + - mentor has >3 available hours, sort to highest: 500 + - 3 or less hours, sort: 200 + + Note: sort logic for unavailable mentors is split on purpose (see update_mentor_availability function) + + Guide: https://docs.google.com/document/d/1GwlleBNScHCQ3K8rgvYIB3upIr1BylgWjGR2jxwYWtI/edit?tab=t.0 + """ + + if len(current_availability) > 1 or mentor.get('hours') > 3: + return 500 + + return 200 + + +def get_unavailable_mentor_sort(mentor): + """ + Returns sort value for unavailable mentor if: + - mentor is ad-hoc only or both but no available hours for the month, sort: 100 + - mentor is long-term only, sort: 10 + - mentor is deactivated, sort: 1 + """ + if mentor.get("disabled", True): + return 1 + + if mentor.get("type") == TYPE_LONG_TERM: + return 10 + + return 100 + + +def get_availability_update_dict(available_mentors): + """ + Returns a dictionary mapping mentor to their available hours (from spreadsheet file) + - If hours column in spreadsheet is empty/non-numeric, the value will be None (indicating existing hours should be kept) + """ + availability_update_dict = {} + + for _, row in available_mentors.iterrows(): + mentor_name = row['Mentor Name'].strip() + updated_hours = row['Availability (Hours)'] + + if pd.isna(updated_hours) or str(updated_hours).strip() == "": + availability_update_dict[mentor_name] = None + else: + availability_update_dict[mentor_name] = updated_hours + + return availability_update_dict + + +def update_mentor_availability(month, xlsx_file_path, yml_file_path): + """ + Updates mentor availability and hours in the mentors.yml file based on the provided xlsx file for a given month. + - Mentors not listed in the xlsx file are set to unavailable for the month. + - Mentors listed in the xlsx file have their availability set to the specified month and hours updated if provided. + - All mentors are re-sorted according to the guide: https://docs.google.com/document/d/1GwlleBNScHCQ3K8rgvYIB3upIr1BylgWjGR2jxwYWtI/edit?tab=t.0 + """ + + df_available_mentors = pd.read_excel(xlsx_file_path) + availability_updates = get_availability_update_dict(df_available_mentors) + + with open(yml_file_path, 'r') as input_yml: + mentors = yaml.load(input_yml) or [] + + for mentor in mentors: + yml_name = mentor['name'].strip() + + # if mentor is not included in availability file: update sort, set availability to none, and move to next mentor + if yml_name not in availability_updates: + mentor['sort'] = get_unavailable_mentor_sort(mentor) + mentor['availability'] = [] + continue + + # otherwise: mentor is available, update sort and reset availability to the current month only + current_availability = mentor.get('availability', []) + mentor['sort'] = get_available_mentor_sort(mentor, current_availability) + mentor['availability'] = [month] + + # Only update hours if updated hours is not None + updated_hours = availability_updates.get(yml_name) + if updated_hours is not None: + logging.info(f"Updating hours for {yml_name} to: {updated_hours}") + mentor['hours'] = updated_hours + + with open(yml_file_path, 'w') as f: + yaml.default_flow_style = True + yaml.dump(mentors, f) + + print(f"Mentor availabilities updated for month {MONTHS_MAP[month]}.") + + +def run_automation(): + logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') + + mentors_yml_file_path = "../_data/mentors.yml" + + if len(sys.argv) == 3: + xlsx_file_path = sys.argv[1] + month = int(sys.argv[2]) + + logging.info("Using values: xlsx: %s, month: %s", xlsx_file_path, month) + else: + xlsx_file_path = "samples/adhoc-prep.xlsx" + month = 11 + + logging.info("Default values: xlsx: %s, month: %s", xlsx_file_path, month) + + update_mentor_availability(month, xlsx_file_path, mentors_yml_file_path) + + +if __name__ == "__main__": + run_automation() diff --git a/tools/run_adhoc_prep_automation.sh b/tools/run_adhoc_prep_automation.sh new file mode 100644 index 00000000..b1f7003b --- /dev/null +++ b/tools/run_adhoc_prep_automation.sh @@ -0,0 +1,13 @@ +#Create the virtual environment On macOS/Linux +python3 -m venv myenv + +#Activate the virtual environment: +source myenv/bin/activate + +# Install packages +pip install -r requirements.txt + +# Enter the parameters: FILE_PATH_XLSX MONTH +# Example: samples/adhoc-prep.xlsx 9 +# month: the adhoc month in number e.g 4 -> April, 11 -> November +python3 automation_prepare_adhoc_availability.py samples/adhoc-prep.xlsx 10 diff --git a/tools/samples/adhoc-prep.xlsx b/tools/samples/adhoc-prep.xlsx new file mode 100644 index 00000000..15567fe9 Binary files /dev/null and b/tools/samples/adhoc-prep.xlsx differ