Skip to content
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

feat: Added logs to identify which platform is being processed! #338

Merged
merged 3 commits into from
Dec 9, 2024

Conversation

amindadgar
Copy link
Member

@amindadgar amindadgar commented Dec 8, 2024

Summary by CodeRabbit

  • New Features
    • Enhanced logging functionality for better visibility into the ETL process.
    • Added logging to track the progress of data transformation for both raw data and raw members.
  • Documentation
    • Updated docstring for clarity on the expected structure of the platform_info parameter.

Copy link
Contributor

coderabbitai bot commented Dec 8, 2024

Walkthrough

The changes in the dags/discourse_analyzer_etl.py file primarily focus on enhancing logging functionality within the ETL process. Two new logging statements have been introduced to the discourse_etl_raw_data and discourse_etl_raw_members tasks to improve visibility during data processing. Additionally, the docstring for the discourse_etl_raw_data function has been updated to specify that the platform_id parameter should be a string. The overall structure and logic of the ETL process remain unchanged.

Changes

File Change Summary
dags/discourse_analyzer_etl.py - Added logging statements in discourse_etl_raw_data and discourse_etl_raw_members tasks.
- Updated docstring in discourse_etl_raw_data to clarify platform_id type as str instead of datetime.
- No changes to control flow or error handling.
dags/analyzer_helper/discourse/transform_raw_data.py - Added logging for progress in TransformRawInfo class during data transformation using enumerate.
- No changes to method signatures or overall logic.
dags/analyzer_helper/discourse/transform_raw_members.py - Added logging for progress in TransformRawMembers class during member transformation using enumerate.
- No changes to method signatures or overall logic.

Possibly related PRs

🐇 In the meadow, I hop with glee,
Logging brightens the data spree!
Each platform's tale, now clear and bright,
As we process through day and night.
With docstrings fixed, we bound ahead,
In the world of ETL, we’re well-fed! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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 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
Contributor

@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: 2

🧹 Outside diff range and nitpick comments (2)
dags/discourse_analyzer_etl.py (2)

Line range hint 71-86: Fix incorrect type annotation in docstring

The docstring incorrectly shows platform_id as datetime type, but it's actually used as a str throughout the code.

             ```
             {
-                'platform_id' : datetime,
+                'platform_id' : str,
                 'id' : str,
                 'period' : datetime,
                 'recompute': bool,

Line range hint 109-152: Consider enhancing logging strategy

While adding platform identification logs is helpful, consider implementing a more comprehensive logging strategy:

  1. Add structured logging with consistent fields across all log messages
  2. Include timing information for performance monitoring
  3. Add log correlation IDs to track entire platform processing flow

Example structured logging pattern:

logging.info(
    "Processing platform data",
    extra={
        "platform_id": platform_id,
        "operation": "etl_raw_data",
        "correlation_id": f"{platform_id}_{period.isoformat()}",
    }
)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 7bb0f83 and df0b3f3.

📒 Files selected for processing (1)
  • dags/discourse_analyzer_etl.py (2 hunks)

dags/discourse_analyzer_etl.py Show resolved Hide resolved
dags/discourse_analyzer_etl.py Show resolved Hide resolved
Copy link
Contributor

@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 and nitpick comments (2)
dags/analyzer_helper/discourse/transform_raw_members.py (1)

27-27: Consider adding initial log message for total count.

While the progress logging is helpful, consider adding an initial log message before the loop to show the total number of members to be processed. This provides immediate visibility of the workload.

 def transform(self, raw_members: list) -> list:
     transformed_members = []
+    logging.info(f"Starting to process {len(raw_members)} raw members")
     for idx, member in enumerate(raw_members):
dags/analyzer_helper/discourse/transform_raw_data.py (1)

120-121: Consider logging enhancements for better visibility.

  1. Add an initial log message showing total entries to be processed
  2. Consider logging subtasks (reactions, replies) for more detailed progress tracking
 def transform(self, raw_data: list) -> list:
     transformed_data = []
+    total_entries = len(raw_data)
+    logging.info(f"Starting to process {total_entries} raw data entries")
     for idx, entry in enumerate(raw_data):
         # Create main post entry
         transformed_data.append(self.create_data_entry(entry))
+        logging.debug(f"Processed main post for entry {idx + 1}")

         # Create entries for reactions
         for reaction in entry["reactions"]:
             transformed_data.append(
                 self.create_data_entry(
                     entry,
                     interaction_type="reaction",
                     interaction_user=int(reaction),
                 )
             )
+        if entry["reactions"]:
+            logging.debug(f"Processed {len(entry['reactions'])} reactions for entry {idx + 1}")

         # Create entry for reply
         if entry["replied_post_id"]:
             transformed_data.append(
                 self.create_data_entry(
                     entry,
                     interaction_type="reply",
                     interaction_user=int(entry["replied_post_user_id"]),
                 )
             )
+            logging.debug(f"Processed reply for entry {idx + 1}")

-        logging.info(f"Preparing raw data: {idx + 1}/{len(raw_data)}")
+        logging.info(f"Preparing raw data: {idx + 1}/{total_entries}")
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between df0b3f3 and 20a0222.

📒 Files selected for processing (2)
  • dags/analyzer_helper/discourse/transform_raw_data.py (3 hunks)
  • dags/analyzer_helper/discourse/transform_raw_members.py (1 hunks)
🔇 Additional comments (3)
dags/analyzer_helper/discourse/transform_raw_members.py (1)

22-26: LGTM! Good use of enumerate for progress tracking.

The change to use enumerate provides a clean way to track progress without affecting the existing functionality.

dags/analyzer_helper/discourse/transform_raw_data.py (2)

1-2: LGTM! Clean import addition.

The logging import is correctly placed at the top of the file.


95-95: LGTM! Good use of enumerate for progress tracking.

The change to use enumerate provides a clean way to track progress without affecting the existing functionality.

@amindadgar amindadgar merged commit 2a9aedb into main Dec 9, 2024
14 checks passed
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.

1 participant