Skip to content

Feature/concrete-data-collector #161

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 97 commits into from
Jul 16, 2025

Conversation

Ben-geo
Copy link
Collaborator

@Ben-geo Ben-geo commented Jun 14, 2025

Summary by CodeRabbit

  • New Features

    • Introduced a flexible DataCollector for simulation models, supporting data collection at both model and agent levels.
    • Added support for multiple storage backends: in-memory, local CSV, Parquet, AWS S3, and PostgreSQL.
    • Expanded configuration options for storage types.
  • Bug Fixes

    • Not applicable.
  • Tests

    • Added comprehensive tests for DataCollector, including data collection, conditional triggers, and storage integration (local files and PostgreSQL).
  • Chores

    • Updated dependencies to include support for PostgreSQL and AWS S3 storage.
    • Enhanced GitHub Actions workflow for improved multi-platform and multi-version testing.

@Ben-geo Ben-geo added the feature New functionality added to the project. label Jun 14, 2025
@Ben-geo Ben-geo changed the title concrete-data-collector Feature/concrete-data-collector Jun 14, 2025
Copy link

codecov bot commented Jun 14, 2025

Codecov Report

Attention: Patch coverage is 83.09859% with 24 lines in your changes missing coverage. Please review.

Project coverage is 91.82%. Comparing base (f928522) to head (fec29d1).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
mesa_frames/concrete/datacollector.py 82.85% 24 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #161      +/-   ##
==========================================
+ Coverage   89.88%   91.82%   +1.93%     
==========================================
  Files          12       13       +1     
  Lines        1780     1920     +140     
==========================================
+ Hits         1600     1763     +163     
+ Misses        180      157      -23     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Ben-geo Ben-geo force-pushed the feature/concrete-datacollector branch 3 times, most recently from 32914bc to a2bc8e8 Compare July 14, 2025 17:18
@Ben-geo
Copy link
Collaborator Author

Ben-geo commented Jul 14, 2025

Hey @adamamer20 - I have finished the test for postgress agent_reporters as well!
however I am not able to bring down the time for windows CI - do you have any insights on this?
I will continue checking about it over the week

@adamamer20
Copy link
Member

adamamer20 commented Jul 15, 2025

Hey @Ben-geo,
I was mistaken during our last call when I suggested unifying everything under Docker. Turns out GitHub service containers only work on Linux runners, so we can’t rely on them for Windows builds.

Given that, I think the simplest and cleanest solution is to run the Postgres tests only on Linux and macOS, and skip them on Windows to avoid the long setup with Chocolatey.

We can implement this by:

  1. An env var in the workflow that flags Windows:
env:
  SKIP_PG_TESTS: ${{ runner.os == 'Windows' }}
  1. Skipping the test using pytest:
import pytest
import os

@pytest.mark.skipif(
    os.getenv("SKIP_PG_TESTS") == "true",
    reason="PostgreSQL tests are skipped on Windows runners"
)
def test_postgress(...):
    ...

This tradeoff is worth it, we get full DB coverage on Linux/macOS, and significantly faster CI runs on Windows without the extra complexity.

@Ben-geo
Copy link
Collaborator Author

Ben-geo commented Jul 15, 2025

Given that, I think the simplest and cleanest solution is to run the Postgres tests only on Linux and macOS, and skip them on Windows to avoid the long setup with Chocolatey.

Yup agreed this is what I had thought we should do too !!! Okie that's it I think with that everything is done!
all the requirements are taken care of I guess right??!!!!

@Ben-geo Ben-geo marked this pull request as ready for review July 15, 2025 19:07
@adamamer20 adamamer20 added this to the 0.1.0-stable milestone Jul 16, 2025
@adamamer20 adamamer20 linked an issue Jul 16, 2025 that may be closed by this pull request
@adamamer20 adamamer20 self-requested a review July 16, 2025 18:17
Copy link
Member

@adamamer20 adamamer20 left a comment

Choose a reason for hiding this comment

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

LGTM! Glad to merge this :)

@adamamer20 adamamer20 merged commit 4ef7217 into projectmesa:main Jul 16, 2025
10 of 11 checks passed
@adamamer20
Copy link
Member

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Jul 17, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

coderabbitai bot commented Jul 17, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The changes introduce a new DataCollector class for the mesa-frames framework, supporting flexible data collection from simulation models and agents with multiple storage backends (memory, CSV, Parquet, S3, PostgreSQL). Comprehensive unit tests for this class are added. The GitHub Actions workflow is restructured for better OS and database coverage, and dependencies for S3 and PostgreSQL support are specified.

Changes

File(s) Change Summary
.github/workflows/build.yml Split matrix job into Ubuntu (with PostgreSQL) and macOS/Windows jobs; improved PostgreSQL setup; clarified coverage upload step.
mesa_frames/abstract/datacollector.py Generalized _storage_uri to _storage, expanded allowed storage types, updated parameter names and docstrings.
mesa_frames/concrete/datacollector.py Added new DataCollector class supporting collection and storage (memory, CSV, Parquet, S3, PostgreSQL) for model/agent data.
pyproject.toml Added dependencies: psycopg2-binary==2.9.10 and boto3>=1.35.91.
tests/test_datacollector.py Added comprehensive unit tests for DataCollector, including local and PostgreSQL integration tests.

Sequence Diagram(s)

Loading
sequenceDiagram
    participant User
    participant ModelDF
    participant DataCollector
    participant StorageBackend

    User->>ModelDF: Run simulation step(s)
    ModelDF->>DataCollector: Call _collect() at step
    DataCollector->>ModelDF: Retrieve model/agent reporters
    DataCollector->>DataCollector: Store data in memory (LazyFrame)
    User->>DataCollector: Call _flush() (optional)
    DataCollector->>StorageBackend: Write data (memory/CSV/Parquet/S3/PostgreSQL)

Poem

In the garden of code, a collector appears,
Gathering data from models and agents, my dears.
With CSV, Parquet, S3, or a database post,
The bunny now hops where it’s needed the most.
Tests sprout like carrots—so crisp and so bright—
This harvest of features is a coder’s delight!
🥕✨


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f928522 and fec29d1.

📒 Files selected for processing (5)
  • .github/workflows/build.yml (2 hunks)
  • mesa_frames/abstract/datacollector.py (3 hunks)
  • mesa_frames/concrete/datacollector.py (1 hunks)
  • pyproject.toml (1 hunks)
  • tests/test_datacollector.py (1 hunks)
✨ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in 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.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New functionality added to the project.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactoring mesa.datacollector
2 participants