Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
167 commits
Select commit Hold shift + click to select a range
7248ae3
Added an example plotting notebook for utilization reports
Dozgulbas Aug 8, 2025
61e7d90
Added an example plotting notebook for utilization reports
Dozgulbas Aug 8, 2025
dd371fd
Added an example plotting notebook for utilization reports
Dozgulbas Aug 8, 2025
57bb7d1
Merge branch 'main' of https://github.com/AD-SDL/MADSci into util_graphs
Dozgulbas Aug 13, 2025
1e08c8a
Adding a place holder
Dozgulbas Aug 13, 2025
1fc67ba
Adding a place holder
Dozgulbas Aug 13, 2025
bda6d97
adding the first version
Dozgulbas Aug 15, 2025
b15ffde
adding the first version
Dozgulbas Aug 15, 2025
2421fc0
Added transfer manager types
Dozgulbas Aug 19, 2025
59af2a3
Added transfer manager types
Dozgulbas Aug 19, 2025
469707c
Added the transfer manager
Dozgulbas Aug 19, 2025
bcc7771
Added a step to handle transfer steps through transfer manager in run…
Dozgulbas Aug 19, 2025
19fb9b6
Transfer manager
Dozgulbas Aug 19, 2025
e3ef939
Transfer manager types
Dozgulbas Aug 19, 2025
c1681d4
Transfer manager client
Dozgulbas Aug 19, 2025
480ab81
Graph that handles the transfer manager logic
Dozgulbas Aug 19, 2025
e9bebd6
Server for transfer manager
Dozgulbas Aug 19, 2025
6bc7770
Example robot definitions config
Dozgulbas Aug 19, 2025
316466e
Tests
Dozgulbas Aug 19, 2025
1ad1623
transfer manager
Dozgulbas Aug 26, 2025
2798a7b
pulling updates from main
Dozgulbas Aug 26, 2025
e1718b2
handling transfer config file
Dozgulbas Aug 26, 2025
c8e43f2
Tests
Dozgulbas Aug 26, 2025
d774fb8
Handling location argument types
Dozgulbas Aug 26, 2025
4196131
handling transfer config file
Dozgulbas Aug 26, 2025
eaf7475
Bug: After transfer manager returns resolved steps, next step is neve…
Dozgulbas Aug 26, 2025
2e0b607
Added trasnfer manager
Dozgulbas Aug 26, 2025
cf892b7
Combined transfer manager configs under single file
Dozgulbas Aug 26, 2025
d982f65
Updated the server to use module nodetype
Dozgulbas Aug 29, 2025
60d9a5e
Updated the server to use module nodetype
Dozgulbas Aug 29, 2025
6cede7e
Added an example node definition for transfer_manager
Dozgulbas Aug 29, 2025
e1806f3
Updated server code to handle transfer actions
Dozgulbas Aug 29, 2025
eff7210
Revert the changes for transfer_manager
Dozgulbas Aug 29, 2025
c86f3b0
Updates to test transfer manager server
Dozgulbas Aug 29, 2025
5066cec
Added robot lookups for locations
Dozgulbas Sep 3, 2025
dcb0a08
Added a plate location
Dozgulbas Sep 3, 2025
a9ae8b7
Added transfer resource action
Dozgulbas Sep 3, 2025
24ec4a7
Updated to use loggers
Dozgulbas Sep 3, 2025
370298c
Handling location lookups
Dozgulbas Sep 3, 2025
b358893
Tests
Dozgulbas Sep 3, 2025
9a51b24
Removed
Dozgulbas Sep 3, 2025
dbf0c8c
No need for a transfer client
Dozgulbas Sep 3, 2025
90aa897
Updates
Dozgulbas Sep 3, 2025
47c1146
Updated resource handling
Dozgulbas Sep 3, 2025
9489383
Updated transfer resource function
Dozgulbas Sep 4, 2025
bd8b531
Logger updates
Dozgulbas Sep 4, 2025
9fa3593
Update for transfer manager definition arg
Dozgulbas Sep 4, 2025
ba7d655
Updated the action to log resource errors but not block the action fo…
Dozgulbas Sep 4, 2025
5480dcd
temp stash for commit
Dozgulbas Sep 4, 2025
ee820a8
Pre commit fixes
Dozgulbas Sep 4, 2025
4c8e50a
Pre commit fixes
Dozgulbas Sep 4, 2025
dedbdac
Updated examples for transfer_manager
Dozgulbas Sep 4, 2025
93e25a6
Updated examples for transfer_manager
Dozgulbas Sep 4, 2025
7e76ee6
Pre commit fixes
Dozgulbas Sep 4, 2025
4903dd9
Merge main into transfer_manager
Dozgulbas Sep 4, 2025
2cb6bfb
Added documentation
Dozgulbas Sep 4, 2025
e3e1448
Added pytests for the transfer_manager
Dozgulbas Sep 4, 2025
29fcbcd
Added a madsci version check at startup
Dozgulbas Sep 5, 2025
b39bf68
Added a version table
Dozgulbas Sep 5, 2025
1e24ded
Adding db version checker
Dozgulbas Sep 5, 2025
0a610bc
Adding a version migration tool
Dozgulbas Sep 5, 2025
159a0ec
Adding new methods to check db version
Dozgulbas Sep 8, 2025
25304a6
Adding a new method to retrieve db from backup
Dozgulbas Sep 8, 2025
97632a6
Raise error if version checker fails
Dozgulbas Sep 8, 2025
77c6f4a
Added a version checking tool
Dozgulbas Sep 9, 2025
2818ab3
Adding alembic setup
Dozgulbas Sep 9, 2025
3fb2ad9
Adding alembic setup
Dozgulbas Sep 9, 2025
97edd12
Added alembic install
Dozgulbas Sep 9, 2025
0f5068f
Server runs proper version check before start
Dozgulbas Sep 9, 2025
c470a45
Ignore alembic migration versions
Dozgulbas Sep 9, 2025
a667d27
Added alembic install
Dozgulbas Sep 9, 2025
853c13c
proper checks for downgrade as well
Dozgulbas Sep 9, 2025
0ca00d5
Now uses alembic for complex migration tasks
Dozgulbas Sep 10, 2025
6af5533
Tests
Dozgulbas Sep 10, 2025
377eb6b
Pre commit fix
Dozgulbas Sep 10, 2025
946eddb
Minor fix
Dozgulbas Sep 10, 2025
5ea8014
Added pytests for migration tools
Dozgulbas Sep 10, 2025
cbd4ae3
Added docs for migration tools
Dozgulbas Sep 10, 2025
ffecf47
Added a db VS madsci version checker
Dozgulbas Sep 11, 2025
b160971
Added version validation before server start
Dozgulbas Sep 11, 2025
8422340
Added version validation before server start
Dozgulbas Sep 11, 2025
f109a63
Added a mongodb migration tool
Dozgulbas Sep 11, 2025
5859739
Added a schema for events db
Dozgulbas Sep 11, 2025
08858b4
Adde a schema for datapoints db
Dozgulbas Sep 11, 2025
f5cc381
Minor fixes - Debug outputs
Dozgulbas Sep 12, 2025
ca60670
Added collection name field
Dozgulbas Sep 12, 2025
584624b
Better version mismatch logging
Dozgulbas Sep 12, 2025
162c44e
Better version mismatch logging
Dozgulbas Sep 12, 2025
16be136
Updated schema
Dozgulbas Sep 12, 2025
6e1185c
Updated schema
Dozgulbas Sep 12, 2025
cc49835
Pre-commit fixes
Dozgulbas Sep 12, 2025
f4c9278
Added pytests for migration tools
Dozgulbas Sep 12, 2025
139790e
Added documentation on migration tools
Dozgulbas Sep 15, 2025
5814484
Removed schema version checks
Dozgulbas Sep 15, 2025
93097d8
Removed schema version checks
Dozgulbas Sep 15, 2025
17182cd
removed versions
Dozgulbas Sep 15, 2025
33ce014
Updated tests
Dozgulbas Sep 15, 2025
be477f8
Added dependency installs for mongo and posgres tools
Dozgulbas Sep 17, 2025
17b7c54
Updated to handle container runs
Dozgulbas Sep 17, 2025
9fdf734
Handling migration inside containers
Dozgulbas Sep 17, 2025
ff4d086
Added user permission for code base
Dozgulbas Sep 17, 2025
432007f
Updates to fix user permissions
Dozgulbas Sep 17, 2025
51be948
Fixed bugs
Dozgulbas Sep 17, 2025
4a722a8
Added volume mount into docker migration command
Dozgulbas Sep 17, 2025
12d5887
Fixed bugs
Dozgulbas Sep 17, 2025
2ceb286
Added migration check
Dozgulbas Sep 17, 2025
e9ce843
Added migration check
Dozgulbas Sep 17, 2025
a8cb5e3
Added mongo schema
Dozgulbas Sep 17, 2025
bdca9b7
Tests
Dozgulbas Sep 17, 2025
29ef7f9
Updated Readme for migration tools
Dozgulbas Sep 17, 2025
be3e37b
Added pytests for migration tools
Dozgulbas Sep 17, 2025
951b493
Minor updates on utilization methods | Removed timout on the API call
Dozgulbas Sep 24, 2025
e55ec37
Merge branch 'main' into db_migrations
RyanTheRobothead Oct 24, 2025
82453c1
Tweak location manager settings fields
RyanTheRobothead Oct 24, 2025
51749bf
Remove some vestigial transfer manager definitions
RyanTheRobothead Oct 24, 2025
8069920
Remove more vestigial transfer manager definitions
RyanTheRobothead Oct 24, 2025
699090a
More cleanup and dependency fix
RyanTheRobothead Oct 24, 2025
e83df9a
Minor timeout changes/docs cleanup/switch to AnyUrl for parsing
RyanTheRobothead Oct 24, 2025
9f12453
Support semantic version checks
RyanTheRobothead Oct 24, 2025
1d3c849
Fix httpx package missing due to bad lock?
RyanTheRobothead Oct 24, 2025
de02b13
Merge branch 'main' into db_migrations
RyanTheRobothead Oct 24, 2025
8066fbd
Switch to __del__ deconstructors
RyanTheRobothead Oct 24, 2025
713e487
Refactor to use pydantic settings for config
RyanTheRobothead Oct 24, 2025
3f85349
WIP: Standardize mongodb url field; pydantify validation logic; explo…
RyanTheRobothead Oct 27, 2025
55ef8c7
Handle major and minor version updates only
Dozgulbas Nov 5, 2025
eed659d
Avoid running migration tool if version has not been tracked before
Dozgulbas Nov 5, 2025
8b730bb
Batter handle db version tracking
Dozgulbas Nov 7, 2025
dcc4cd3
Added argument parser
Dozgulbas Nov 7, 2025
39817a7
Handle version updates based on major and minor updates to MADSci
Dozgulbas Nov 7, 2025
292c841
Track schema versions for migration rather than MADSci version
Dozgulbas Nov 7, 2025
3123ac8
Track schema versions for migration rather than MADSci version
Dozgulbas Nov 7, 2025
6534dd8
Added argument parsers
Dozgulbas Nov 7, 2025
9e81365
Update on database and collection names
Dozgulbas Nov 7, 2025
7578cc8
Better handle db migrations
Dozgulbas Nov 7, 2025
26c8505
Better handle db migrations
Dozgulbas Nov 7, 2025
230cce9
Better handle db migrations
Dozgulbas Nov 7, 2025
d2436fb
Addresing review comments to handle migrations better
Dozgulbas Nov 8, 2025
3aed827
Fixed version
Dozgulbas Nov 13, 2025
b462920
Added pydantic validator for schema
Dozgulbas Nov 13, 2025
d7746ec
Better handle alembic migration
Dozgulbas Nov 13, 2025
5a0ed69
Enable system logs
Dozgulbas Nov 13, 2025
6728c29
Migration settings update
Dozgulbas Nov 13, 2025
a85000f
Use pydentic args
Dozgulbas Nov 13, 2025
b2f4d17
Updated arguments when commands are generated
Dozgulbas Nov 13, 2025
7e06dba
Updated arguments when commands are generated
Dozgulbas Nov 13, 2025
e89a44e
Added validate schema field to use with paydentic args
Dozgulbas Nov 13, 2025
3ca2d02
Fixed bug with validate_schema arg
Dozgulbas Nov 13, 2025
9b3ef6e
Merge branch 'main' into db_migrations
RyanTheRobothead Nov 17, 2025
af3a009
Fixing tests post-merge
RyanTheRobothead Nov 18, 2025
502535b
Add backup and restore validation and testing
RyanTheRobothead Nov 19, 2025
e40fcdf
Merge branch 'main' into db_migrations
RyanTheRobothead Nov 19, 2025
d2e88af
Merge branch 'main' into db_migrations
RyanTheRobothead Nov 20, 2025
1d10887
WIP: standalone backup tooling phase 1
RyanTheRobothead Nov 24, 2025
ba8b583
WIP: standalone backup tooling phase 2
RyanTheRobothead Nov 24, 2025
29fd16a
WIP: standalone backup tooling phase 3
RyanTheRobothead Nov 24, 2025
fac29ca
WIP: standalone backup tooling phase 4
RyanTheRobothead Nov 25, 2025
1c3881b
Unify CLI and add documentation
RyanTheRobothead Nov 25, 2025
3173e98
Migrate postgres tooling to common
RyanTheRobothead Nov 25, 2025
71f807b
Final: backup cli tooling separated from migration tool
RyanTheRobothead Nov 30, 2025
53832bf
Fix race condition/postgres backup path issue
RyanTheRobothead Dec 2, 2025
585be52
Remove references to not-implemented features
RyanTheRobothead Dec 2, 2025
6ae09e5
Remove unneccessary check
RyanTheRobothead Dec 2, 2025
8d9a98e
Update configuration
RyanTheRobothead Dec 2, 2025
f4403c7
Fix default values for db urls
RyanTheRobothead Dec 2, 2025
4c87e19
Fix some cli naming issues for clarity
RyanTheRobothead Dec 4, 2025
f89b680
Merge pull request #192 from AD-SDL/backup_tooling
RyanTheRobothead Dec 4, 2025
0fc3650
Merge branch 'main' into db_migrations
RyanTheRobothead Dec 4, 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
36 changes: 31 additions & 5 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,18 @@

# DATA_SERVER_URL="http://localhost:8004/"
# DATA_MANAGER_DEFINITION="data.manager.yaml"
# DATA_DB_URL="mongodb://localhost:27017"
# DATA_DATABASE_NAME="madsci_data"
# DATA_COLLECTION_NAME="datapoints"
# MONGO_DB_URL="mongodb://localhost:27017"
# DATA_FILE_STORAGE_PATH="~/.madsci/datapoints"

### EventManagerSettings

# EVENT_SERVER_URL="http://localhost:8001"
# EVENT_MANAGER_DEFINITION="event.manager.yaml"
# EVENT_DB_URL="mongodb://localhost:27017"
# EVENT_COLLECTION_NAME="madsci_events"
# MONGO_DB_URL="mongodb://localhost:27017"
# EVENT_DATABASE_NAME="madsci_events"
# EVENT_COLLECTION_NAME="events"
# EVENT_ALERT_LEVEL=40
# EVENT_EMAIL_ALERTS=null

Expand All @@ -65,14 +68,18 @@
# WORKCELL_NODE_UPDATE_INTERVAL=1.0
# WORKCELL_COLD_START_DELAY=0
# WORKCELL_SCHEDULER="madsci.workcell_manager.schedulers.default_scheduler"
# WORKCELL_MONGO_URL=null
# MONGO_DB_URL="mongodb://localhost:27017"
# WORKCELL_DATABASE_NAME="madsci_workcells"
# WORKCELL_COLLECTION_NAME="archived_workflows"
# WORKCELL_GET_ACTION_RESULT_RETRIES=3

### ExperimentManagerSettings

# EXPERIMENT_SERVER_URL="http://localhost:8002/"
# EXPERIMENT_MANAGER_DEFINITION="experiment.manager.yaml"
# EXPERIMENT_DB_URL="mongodb://localhost:27017"
# MONGO_DB_URL="mongodb://localhost:27017"
# EXPERIMENT_DATABASE_NAME="madsci_experiments"
# EXPERIMENT_COLLECTION_NAME="experiments"

### ResourceManagerSettings

Expand All @@ -93,3 +100,22 @@
# LOCATION_REDIS_HOST="localhost"
# LOCATION_REDIS_PORT=6379
# LOCATION_REDIS_PASSWORD=null

### PostgreSQLBackupSettings

# POSTGRES_BACKUP_DIR=".madsci/backups"
# POSTGRES_MAX_BACKUPS=10
# POSTGRES_VALIDATE_INTEGRITY=true
# POSTGRES_COMPRESSION=true
# DB_URL="postgresql://madsci:madsci@localhost:5432/resources"
# POSTGRES_BACKUP_FORMAT="custom"

### MongoDBBackupSettings

# MONGODB_BACKUP_DIR=".madsci/backups"
# MONGODB_MAX_BACKUPS=10
# MONGODB_VALIDATE_INTEGRITY=true
# MONGODB_COMPRESSION=true
# MONGO_DB_URL="mongodb://localhost:27017"
MONGODB_DATABASE=
# MONGODB_COLLECTIONS=null
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ test_experiment/
# Output data
.wei/
.madsci/
backups/

#node modules
**/node_modules
Expand All @@ -314,4 +315,11 @@ coverage.xml
.coverage

.mcp.json

# Alembic migration versions (environment-specific)
src/madsci_resource_manager/madsci/resource_manager/alembic/versions/*.py


# Agentic coding
.claude/
agent_docs/
6 changes: 5 additions & 1 deletion .justfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ checks:
@pre-commit run --all-files || { echo "" && echo "Some checks failed! Running one more time to see if any automatic fixes worked:" && echo "" ; pre-commit run --all-files; }
# Run the pre-commit checks
check: checks
ruff-unsafe:
@ruff check . --fix --unsafe-fixes

# Build the project
build: dcb
Expand Down Expand Up @@ -187,6 +189,8 @@ node_integration_tests:
experiment_integration_tests:
docker compose run --rm --no-deps workcell_manager python -m nbconvert --to notebook --inplace --stdout --execute ./notebooks/experiment_notebook.ipynb

backup_integration_tests:
docker compose run --rm --no-deps workcell_manager python -m nbconvert --to notebook --inplace --stdout --execute ./notebooks/backup_and_migration.ipynb

# Run the integration tests
integration_tests: node_integration_tests experiment_integration_tests
integration_tests: node_integration_tests experiment_integration_tests backup_integration_tests
103 changes: 103 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,109 @@ The `AbstractManagerBase` class provides:
- When generating new IDs, use `new_ulid_str()` from `madsci.common.utils`
- Example usage: `resource_id = new_ulid_str()`

### Database Patterns

MADSci uses two database systems optimized for different use cases:

#### Database Types
- **PostgreSQL**: Used by Resource Manager for relational data with strict schemas
- **MongoDB**: Used by Event, Data, Experiment, and Workcell Managers for flexible document storage

#### Backup and Restore

All backup tools are centralized in `madsci_common` for maximum reusability:

```python
# PostgreSQL backups
from madsci.common.backup_tools import PostgreSQLBackupTool
from madsci.common.types.backup_types import PostgreSQLBackupSettings

settings = PostgreSQLBackupSettings(
db_url="postgresql://localhost/resources",
backup_dir=Path("./backups"),
max_backups=10,
validate_integrity=True
)
backup_tool = PostgreSQLBackupTool(settings)
backup_path = backup_tool.create_backup("pre_migration")

# MongoDB backups
from madsci.common.backup_tools import MongoDBBackupTool
from madsci.common.types.backup_types import MongoDBBackupSettings

settings = MongoDBBackupSettings(
mongo_db_url=AnyUrl("mongodb://localhost:27017"),
database="events",
backup_dir=Path("./backups"),
max_backups=10
)
backup_tool = MongoDBBackupTool(settings)
backup_path = backup_tool.create_backup("hourly")
```

**CLI Usage:**
```bash
# Unified CLI (auto-detects database type)
madsci-backup create --db-url postgresql://localhost/resources
madsci-backup create --db-url mongodb://localhost:27017/events

# Database-specific CLIs
madsci-postgres-backup create --db-url postgresql://localhost/resources
madsci-mongodb-backup create --mongo-url mongodb://localhost:27017 --database events
```

#### Database Connections

**PostgreSQL** (using SQLModel):
```python
from sqlmodel import Session, create_engine

engine = create_engine(
db_url,
pool_size=20, # Connection pool size
pool_pre_ping=True # Verify connections before use
)

with Session(engine) as session:
# Perform operations
session.commit()
```

**MongoDB** (using pymongo):
```python
from pymongo import MongoClient

with MongoClient(mongo_url) as client:
db = client[database_name]
collection = db[collection_name]
# Perform operations
```

#### Database Migrations

**PostgreSQL migrations** (Resource Manager):
- Uses Alembic for schema version management
- Automatic backups before migrations
- Auto-restore on migration failure
```bash
python -m madsci.resource_manager.migration_tool --db-url postgresql://localhost/resources
```

**MongoDB migrations** (per manager):
- Handle index creation and schema validation
- Manager-specific migration tools
- Automatic pre-migration backups

#### Best Practices

1. **Always use ULID for IDs**: `resource_id = new_ulid_str()`
2. **Backup before migrations**: Automatic with migration tools
3. **Use connection pooling**: Configure appropriate pool sizes
4. **Environment variables for config**: Never hardcode connection strings
5. **Validate backups**: Use `validate_backup_integrity()` for critical backups
6. **Test migrations first**: Always test in development before production


### Node Development
Laboratory instruments implement the Node interface:
1. Inherit from `AbstractNodeModule`
Expand Down
Loading
Loading