Skip to content

feat: download video learning events #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 16, 2025

Conversation

jo-elimu
Copy link
Member

@jo-elimu jo-elimu commented Apr 16, 2025

Issue Number

Purpose

Technical Details

Testing Instructions

Screenshots

Summary by CodeRabbit

  • New Features
    • Enabled automatic downloading and saving of the "video-learning-events.csv" dataset for each supported language.

@jo-elimu jo-elimu self-assigned this Apr 16, 2025
@jo-elimu jo-elimu requested a review from a team as a code owner April 16, 2025 04:23
@jo-elimu jo-elimu linked an issue Apr 16, 2025 that may be closed by this pull request
10 tasks
@jo-elimu jo-elimu merged commit 81f602a into main Apr 16, 2025
3 checks passed
@jo-elimu jo-elimu deleted the 1-download-video-learning-events branch April 16, 2025 04:23
Copy link

coderabbitai bot commented Apr 16, 2025

Walkthrough

This change reactivates a previously commented-out section in the download_datasets.py script. The uncommented code now downloads, prints, and saves the "video-learning-events.csv" dataset for each language in a specified list. For every language, the script constructs the dataset URL, reads it into a pandas DataFrame, prints the DataFrame, determines the local file path, prints the path, and saves the DataFrame as a CSV file. No changes were made to public APIs or exported entities. This update supports elimu.ai's mission to build innovative learning software that empowers out-of-school children to teach themselves basic reading📖, writing✍🏽, and math🔢 within 6 months.

Changes

File(s) Change Summary
download_datasets.py Uncommented the code block for downloading, printing, and saving "video-learning-events.csv" for each language.

Possibly related PRs

  • feat: download storybook learning events #2: Extended the dataset download functionality in download_datasets.py by initially adding code for downloading storybook learning events, upon which this PR builds by activating the video learning events download.
  • feat: download word learning events #3: Added code for downloading word learning events in the same script, similar to this PR’s activation of video learning events logic.
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🔭 Outside diff range comments (1)
download_datasets.py (1)

36-37: 💡 Verification agent

🧩 Analysis chain

Consider implementing the TODO for number learning events

There's a TODO comment for number learning events. Since you're now adding video learning events, it might be a good opportunity to implement number learning events as well if they're available. This would further support elimu.ai's mission to build innovative learning software that empowers out-of-school children to teach themselves basic reading📖, writing✍🏽 and math🔢 within 6 months.


🏁 Script executed:

#!/bin/bash
# Check if number learning events endpoints exist for any of the languages
echo "Checking for number-learning-events endpoints..."
for lang in eng hin tgl tha
do
  status=$(curl -s -o /dev/null -w "%{http_code}" "http://${lang}.elimu.ai/analytics/number-learning-event/list/number-learning-events.csv")
  echo "${lang}: HTTP status ${status}"
done

Length of output: 986


Action: Address Number Learning Event Implementation

The verification indicates that the endpoints for number learning events (for languages eng, hin, tgl, tha) are currently returning HTTP 404. Since you're now adding video learning events, please confirm whether number learning events are also intended to be supported. If so, this feature should be implemented—adding the corresponding endpoints—and any relevant processing should be integrated. Otherwise, if the feature isn’t planned for immediate release, consider updating or removing this TODO comment.

This adjustment will help further support elimu.ai's mission to build innovative learning software that empowers out-of-school children to teach themselves basic reading📖, writing✍🏽 and math🔢 within 6 months.

🧹 Nitpick comments (2)
download_datasets.py (2)

46-52: Nice work activating the video learning events download! 👍

This code successfully follows the established pattern in the script for downloading learning event data, supporting elimu.ai's mission to build innovative learning software that empowers out-of-school children to teach themselves basic reading📖, writing✍🏽 and math🔢 within 6 months.

However, I would recommend adding some error handling to gracefully manage potential network issues or invalid CSV data, as any failures in these HTTP requests would currently crash the script.

+    try:
         video_learning_events_csv_url = f'http://{language.lower()}.elimu.ai/analytics/video-learning-event/list/video-learning-events.csv'
         print(f'video_learning_events_csv_url: {video_learning_events_csv_url}')
         video_learning_events_dataframe = pandas.read_csv(video_learning_events_csv_url)
         print(f'video_learning_events_dataframe: \n{video_learning_events_dataframe}')
         video_learning_events_file_path = f'lang-{language}/video-learning-events.csv'
         print(f'video_learning_events_file_path: {video_learning_events_file_path}')
         video_learning_events_dataframe.to_csv(video_learning_events_file_path, index=False)
+    except Exception as e:
+        print(f"Error downloading video learning events for {language}: {e}")

1-53: Consider reducing code duplication with a helper function

The script has repeated similar code blocks for each type of learning event. This could be refactored into a helper function to improve maintainability and readability, which aligns with elimu.ai's mission to build innovative learning software that empowers out-of-school children to teach themselves basic reading📖, writing✍🏽 and math🔢 within 6 months.

 import os
 import pandas
+
+def download_dataset(language, event_type, file_prefix=None):
+    """
+    Downloads a specific learning event dataset for a given language
+    
+    Args:
+        language: Language code (e.g., 'ENG')
+        event_type: Type of learning event (e.g., 'letter-sound-learning-event')
+        file_prefix: Optional prefix for the local filename (defaults to event_type)
+    """
+    if file_prefix is None:
+        file_prefix = event_type.split('-')[0]
+    
+    try:
+        csv_url = f'http://{language.lower()}.elimu.ai/analytics/{event_type}/list/{event_type}s.csv'
+        print(f'{event_type}_csv_url: {csv_url}')
+        dataframe = pandas.read_csv(csv_url)
+        print(f'{event_type}_dataframe: \n{dataframe}')
+        file_path = f'lang-{language}/{file_prefix}-learning-events.csv'
+        print(f'{event_type}_file_path: {file_path}')
+        dataframe.to_csv(file_path, index=False)
+        return True
+    except Exception as e:
+        print(f"Error downloading {event_type} for {language}: {e}")
+        return False

 # Supported languages: https://github.com/elimu-ai/model/blob/main/src/main/java/ai/elimu/model/v2/enums/Language.java
 languages = [
     'ENG',
     'HIN',
     'TGL',
     'THA'
 ]
 print(f'languages: {languages}')

 # Download datasets for each language
 for language in languages:
     print()
     print(f'language: {language}')

     os.makedirs(f'lang-{language}', exist_ok=True)

-    letter_sound_learning_events_csv_url = f'http://{language.lower()}.elimu.ai/analytics/letter-sound-learning-event/list/letter-sound-learning-events.csv'
-    print(f'letter_sound_learning_events_csv_url: {letter_sound_learning_events_csv_url}')
-    letter_sound_learning_events_dataframe = pandas.read_csv(letter_sound_learning_events_csv_url)
-    print(f'letter_sound_learning_events_dataframe: \n{letter_sound_learning_events_dataframe}')
-    letter_sound_learning_events_file_path = f'lang-{language}/letter_sound-learning-events.csv'
-    print(f'letter_sound_learning_events_file_path: {letter_sound_learning_events_file_path}')
-    letter_sound_learning_events_dataframe.to_csv(letter_sound_learning_events_file_path, index=False)
+    download_dataset(language, 'letter-sound-learning-event', 'letter_sound')
-    word_learning_events_csv_url = f'http://{language.lower()}.elimu.ai/analytics/word-learning-event/list/word-learning-events.csv'
-    print(f'word_learning_events_csv_url: {word_learning_events_csv_url}')
-    word_learning_events_dataframe = pandas.read_csv(word_learning_events_csv_url)
-    print(f'word_learning_events_dataframe: \n{word_learning_events_dataframe}')
-    word_learning_events_file_path = f'lang-{language}/word-learning-events.csv'
-    print(f'word_learning_events_file_path: {word_learning_events_file_path}')
-    word_learning_events_dataframe.to_csv(word_learning_events_file_path, index=False)
+    download_dataset(language, 'word-learning-event', 'word')

     # TODO: number learning events
     
-    storybook_learning_events_csv_url = f'http://{language.lower()}.elimu.ai/analytics/storybook-learning-event/list/storybook-learning-events.csv'
-    print(f'storybook_learning_events_csv_url: {storybook_learning_events_csv_url}')
-    storybook_learning_events_dataframe = pandas.read_csv(storybook_learning_events_csv_url)
-    print(f'storybook_learning_events_dataframe: \n{storybook_learning_events_dataframe}')
-    storybook_learning_events_file_path = f'lang-{language}/storybook-learning-events.csv'
-    print(f'storybook_learning_events_file_path: {storybook_learning_events_file_path}')
-    storybook_learning_events_dataframe.to_csv(storybook_learning_events_file_path, index=False)
+    download_dataset(language, 'storybook-learning-event', 'storybook')

-    video_learning_events_csv_url = f'http://{language.lower()}.elimu.ai/analytics/video-learning-event/list/video-learning-events.csv'
-    print(f'video_learning_events_csv_url: {video_learning_events_csv_url}')
-    video_learning_events_dataframe = pandas.read_csv(video_learning_events_csv_url)
-    print(f'video_learning_events_dataframe: \n{video_learning_events_dataframe}')
-    video_learning_events_file_path = f'lang-{language}/video-learning-events.csv'
-    print(f'video_learning_events_file_path: {video_learning_events_file_path}')
-    video_learning_events_dataframe.to_csv(video_learning_events_file_path, index=False)
+    download_dataset(language, 'video-learning-event', 'video')
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7384d2d and e16924e.

⛔ Files ignored due to path filters (4)
  • lang-ENG/video-learning-events.csv is excluded by !**/*.csv
  • lang-HIN/video-learning-events.csv is excluded by !**/*.csv
  • lang-TGL/video-learning-events.csv is excluded by !**/*.csv
  • lang-THA/video-learning-events.csv is excluded by !**/*.csv
📒 Files selected for processing (1)
  • download_datasets.py (1 hunks)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Download datasets
1 participant