Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
9e1dc09
push
Ben-geo Jun 14, 2025
848d8cd
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 14, 2025
f515f94
property to data
Ben-geo Jun 14, 2025
ba3c637
Merge branch 'feature/concrete-datacollector' of https://github.com/B…
Ben-geo Jun 14, 2025
375ac17
indentation
Ben-geo Jun 14, 2025
5fe4f9b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 14, 2025
ca9aa1a
model reporter if
Ben-geo Jun 15, 2025
31833dc
Merge branch 'feature/concrete-datacollector' of https://github.com/B…
Ben-geo Jun 15, 2025
dc2e3a7
Merge branch 'main' of https://github.com/Ben-geo/mesa-frames into fe…
Ben-geo Jun 15, 2025
a6fa584
abstract
Ben-geo Jun 15, 2025
6720aea
flush fixes
Ben-geo Jun 15, 2025
38ce8cf
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 15, 2025
731a3c1
input types
Ben-geo Jun 20, 2025
2141aa5
Merge branch 'feature/concrete-datacollector' of https://github.com/B…
Ben-geo Jun 20, 2025
11aa332
separate agent and model collectors
Ben-geo Jun 20, 2025
f1a7021
introduce more dynamic functionalities
Ben-geo Jun 20, 2025
6649ca9
fixing up the pg functions
Ben-geo Jun 20, 2025
c85057a
s3 changes
Ben-geo Jun 20, 2025
8865488
changing abstract class
Ben-geo Jun 20, 2025
c3e2e09
init doc
Ben-geo Jun 20, 2025
2b9b23f
more doc strings
Ben-geo Jun 20, 2025
eacc366
final docstrings
Ben-geo Jun 20, 2025
07f936c
sync
Ben-geo Jun 20, 2025
776746d
sync
Ben-geo Jun 20, 2025
bc6250b
pre commit fixes
Ben-geo Jun 20, 2025
52cf0b2
precommit
Ben-geo Jun 20, 2025
293e873
pre commit fixes
Ben-geo Jun 21, 2025
b569fdc
pre commit fixes
Ben-geo Jun 21, 2025
0ae5bbf
error fix
Ben-geo Jun 21, 2025
1f2e68d
test model
Ben-geo Jun 21, 2025
d5b7c67
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 21, 2025
92a5a25
precommit
Ben-geo Jun 21, 2025
d297499
Merge branch 'feature/concrete-datacollector' of https://github.com/B…
Ben-geo Jun 21, 2025
7d1784c
test_init
Ben-geo Jun 28, 2025
080a62e
agent level data
Ben-geo Jun 28, 2025
3427dcf
private methods
Ben-geo Jun 28, 2025
3070d6e
test conditional collect
Ben-geo Jun 28, 2025
504de7f
local tests
Ben-geo Jun 28, 2025
a3ab710
base
Ben-geo Jun 28, 2025
f3213f4
pg
Ben-geo Jun 28, 2025
ec531ab
collected data empty
Ben-geo Jun 29, 2025
b4ce492
fulltests
Ben-geo Jun 29, 2025
a439490
add dependencies
Ben-geo Jun 29, 2025
6f9fa9e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 29, 2025
dfe86a5
pycop dependency issue
Ben-geo Jun 29, 2025
370f4ac
Merge branch 'feature/concrete-datacollector' of https://github.com/B…
Ben-geo Jun 29, 2025
ac3c6b0
toml quotes
Ben-geo Jun 29, 2025
88295a5
agentsdf
Ben-geo Jul 2, 2025
eb6ebb7
multi agent
Ben-geo Jul 2, 2025
70212d0
fixes
Ben-geo Jul 2, 2025
9476b80
agent into agent reporter
Ben-geo Jul 2, 2025
564cae0
isin
Ben-geo Jul 6, 2025
6a80610
test agent reporter string issue
Ben-geo Jul 7, 2025
76c6743
multi selection
Ben-geo Jul 7, 2025
ef2e096
better name
Ben-geo Jul 7, 2025
974cc9b
collect_step
Ben-geo Jul 7, 2025
4294d7f
add tests in conditional colect
Ben-geo Jul 8, 2025
ec58505
test pg
Ben-geo Jul 9, 2025
9f453e6
pg test
Ben-geo Jul 9, 2025
5f0cb9a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 9, 2025
982938e
Merge branch 'main' of https://github.com/Ben-geo/mesa-frames into fe…
Ben-geo Jul 9, 2025
eb0560a
test yml
Ben-geo Jul 9, 2025
4b0ab70
Merge branch 'feature/concrete-datacollector' of https://github.com/B…
Ben-geo Jul 9, 2025
c9f5236
build yml
Ben-geo Jul 9, 2025
c2d5a03
build changes
Ben-geo Jul 9, 2025
b4c1eb9
build changes windows and mac
Ben-geo Jul 9, 2025
e8ab7ce
macos changes
Ben-geo Jul 9, 2025
e24ae7f
nopassword
Ben-geo Jul 9, 2025
46fbb12
Merge branch 'main' of https://github.com/Ben-geo/mesa-frames into fe…
Ben-geo Jul 13, 2025
ade94bf
better error handling
Ben-geo Jul 13, 2025
7a806e3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 13, 2025
9121842
add schema name
Ben-geo Jul 13, 2025
2bd95d3
Merge branch 'feature/concrete-datacollector' of https://github.com/B…
Ben-geo Jul 13, 2025
af72399
add schema name as public
Ben-geo Jul 13, 2025
c964c55
commit pg test
Ben-geo Jul 13, 2025
bb1406e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 13, 2025
c52b2d3
persist comment
Ben-geo Jul 13, 2025
d67c21c
age exampleset column
Ben-geo Jul 13, 2025
3dee95f
Merge branch 'feature/concrete-datacollector' of https://github.com/B…
Ben-geo Jul 13, 2025
f1a5da5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 13, 2025
9899843
removed agent_reporter pg
Ben-geo Jul 13, 2025
186c4b0
Merge branch 'feature/concrete-datacollector' of https://github.com/B…
Ben-geo Jul 13, 2025
0fe3b10
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 13, 2025
04bbe30
closed currsor
Ben-geo Jul 13, 2025
bd31cf1
Merge branch 'feature/concrete-datacollector' of https://github.com/B…
Ben-geo Jul 13, 2025
ddab735
final test
Ben-geo Jul 13, 2025
2cb45aa
precommit
Ben-geo Jul 13, 2025
4681241
precommit
Ben-geo Jul 13, 2025
f78a119
doc for datacollector
Ben-geo Jul 13, 2025
21e0f21
precommit fix
Ben-geo Jul 13, 2025
e7f7b29
windows build
Ben-geo Jul 13, 2025
0c72438
revert to the prev commit
Ben-geo Jul 13, 2025
220025b
added agent reporter for postgress
Ben-geo Jul 13, 2025
a2bc8e8
final pg test
Ben-geo Jul 13, 2025
5b8f30e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 14, 2025
09dd603
precommit and build changes
Ben-geo Jul 15, 2025
fec29d1
Merge branch 'feature/concrete-datacollector' of https://github.com/B…
Ben-geo Jul 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 88 additions & 21 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,50 @@ on:
push:
branches:
- main
- 'release**'
- "release**"
paths-ignore:
- '**.md'
- "**.md"
pull_request:
paths-ignore:
- '**.md'
- "**.md"
workflow_dispatch:
schedule:
- cron: '0 6 * * 1'
- cron: "0 6 * * 1"

concurrency:
group: "${{ github.workflow }}-${{ github.head_ref || github.run_id }}"
cancel-in-progress: true

jobs:
test_on_matrix:
name: build (${{ matrix.os }}, py${{ matrix.python-version }})
runs-on: ${{ matrix.os }}-latest
test_on_ubuntu:
name: build (ubuntu, py${{ matrix.python-version }})
runs-on: ubuntu-latest
timeout-minutes: 6

strategy:
fail-fast: false
matrix:
os: [windows, ubuntu, macos]
python-version: ['3.13']
include:
- os: ubuntu
python-version: '3.11'
- os: ubuntu
python-version: '3.12'
python-version: ["3.11", "3.12", "3.13"]

env:
MESA_FRAMES_RUNTIME_TYPECHECKING: "true"
POSTGRES_URI: postgresql://user:password@localhost:5432/testdb
SKIP_PG_TESTS: "false"

services:
postgres:
image: postgres:15
ports:
- 5432:5432
env:
POSTGRES_USER: user
POSTGRES_PASSWORD: password
POSTGRES_DB: testdb
options: >-
--health-cmd="pg_isready"
--health-interval=10s
--health-timeout=5s
--health-retries=5

steps:
- uses: actions/checkout@v4
Expand All @@ -53,24 +64,80 @@ jobs:

- name: Install mesa-frames + dev dependencies
run: |
# 1. Install the project itself
uv pip install --system .
# 2. Install everything under the "dev" dependency group
uv pip install --group dev --system

- name: Test with pytest
run: pytest --durations=10 --cov=mesa_frames tests/ --cov-report=xml

- if: matrix.os == 'ubuntu'
name: Codecov
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}

test_on_mac_windows:
name: build (${{ matrix.os }}, py3.13)
runs-on: ${{ matrix.os }}-latest
timeout-minutes: 10

strategy:
matrix:
include:
- os: windows
skip_pg: true
- os: macos
skip_pg: false

env:
MESA_FRAMES_RUNTIME_TYPECHECKING: "true"
POSTGRES_URI: postgresql://user:password@localhost:5432/testdb
SKIP_PG_TESTS: ${{ matrix.skip_pg }}

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"

- name: Install uv via GitHub Action
uses: astral-sh/setup-uv@v6
with:
cache: true

- name: Install mesa-frames + dev dependencies
run: |
uv pip install --system .
uv pip install --group dev --system

- name: Install and Start PostgreSQL (macOS)
if: matrix.os == 'macos'
run: |
brew install postgresql@15

export PATH="/opt/homebrew/opt/postgresql@15/bin:$PATH"
export PGDATA="/opt/homebrew/var/postgresql@15"

# Ensure a clean database directory
rm -rf $PGDATA
mkdir -p $PGDATA

initdb --username=user --auth=trust --encoding=UTF8 $PGDATA

pg_ctl -D $PGDATA -l logfile start

sleep 5

createdb testdb -U user
shell: bash

- name: Test with pytest
run: pytest --durations=10 --cov=mesa_frames tests/ --cov-report=xml

build:
name: build
runs-on: ubuntu-latest
needs: [test_on_matrix]
needs: [test_on_ubuntu, test_on_mac_windows]
steps:
- name: All matrix builds and tests passed
run: echo "All matrix jobs completed successfully."
- run: echo "All matrix jobs completed successfully."
10 changes: 6 additions & 4 deletions mesa_frames/abstract/datacollector.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class AbstractDataCollector(ABC):
_agent_reporters: dict[str, str | Callable] | None
_trigger: Callable[..., bool]
_reset_memory = bool
_storage_uri: Literal["memory:", "csv:", "postgresql:"]
_storage: Literal["memory", "csv", "parquet", "S3-csv", "S3-parquet", "postgresql"]
_frames: list[pl.DataFrame]

def __init__(
Expand All @@ -74,7 +74,9 @@ def __init__(
agent_reporters: dict[str, str | Callable] | None = None,
trigger: Callable[[Any], bool] | None = None,
reset_memory: bool = True,
storage: Literal["memory:", "csv:", "postgresql:"] = "memory:",
storage: Literal[
"memory", "csv", "parquet", "S3-csv", "S3-parquet", "postgresql"
] = "memory",
):
"""
Initialize a Datacollector.
Expand All @@ -91,15 +93,15 @@ def __init__(
A function(model) -> bool that determines whether to collect data.
reset_memory : bool
Whether to reset in-memory data after flushing. Default is True.
storage : Literal["memory:", "csv:", "postgresql:"]
storage : Literal["memory", "csv", "parquet", "S3-csv", "S3-parquet", "postgresql" ]
Storage backend URI (e.g. 'memory:', 'csv:', 'postgresql:').
"""
self._model = model
self._model_reporters = model_reporters or {}
self._agent_reporters = agent_reporters or {}
self._trigger = trigger or (lambda model: False)
self._reset_memory = reset_memory
self._storage_uri = storage or "memory:"
self._storage = storage or "memory"
self._frames = []

def collect(self) -> None:
Expand Down
Loading
Loading