Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 3, 2025

Students were running experiments while paint colors (red/yellow) were out of stock. This adds MongoDB-based inventory tracking with evaporation compensation and Prefect maintenance flows for manual restocking.

Core System

  • inventory_utils.py: MongoDB CRUD for R/Y/B stock levels with time-based evaporation (5 µL/hr default)
  • restock_flow.py: Three Prefect flows - restock-maintenance, initialize-inventory, check-inventory-status
  • device_with_inventory.py: New mix-color-with-inventory flow that validates stock before mixing and subtracts after

Integration

  • Pre-mixing validation raises ValueError if insufficient stock (threshold + required volume)
  • Post-mixing automatic subtraction accounts for evaporation since last update
  • Original mix_color flow preserved for backward compatibility
  • Two new work queues: maintenance (priority 4), monitoring (priority 5)

Operations

# Initialize system (first time or reset)
initialize_inventory(red_volume=15000, yellow_volume=15000, blue_volume=15000)

# Color mixing automatically checks and subtracts
mix_color_with_inventory(R=120, Y=50, B=80, G=0, mix_well="B2")
# Raises: ValueError if stock < (required + 100µL threshold)

# Manual restock with audit trail
restock_inventory(red_volume=10000, yellow_volume=5000)
# Logs operator, timestamp, volumes to MongoDB

CLI

python orchestrator_restock.py check 5.0          # Alert if < 5ml
python orchestrator_restock.py restock 10 5 0 tech_id
python orchestrator_restock.py initialize 15 15 15

All MongoDB connections use try-finally for proper cleanup. Environment variables (MONGODB_PASSWORD, blinded_connection_string) handled gracefully for testing. Mock OT-2 implementation available via USE_REAL_OPENTRONS=false.

Original prompt

This section details on the original issue you should resolve

<issue_title>Add "restock" maintenance Prefect step for OT2 color matching demo</issue_title>
<issue_description>Likewise, probably time for me to handle stocking more strategically at some point, given that students were running experiments while (EDIT: yellow and red) were out of stock. I can also probably dig up the threads I have related to this. Maybe some issues in this repo, probably also on the self-driving-lab-demo discussions.</issue_description>

<agent_instructions>https://github.com/AccelerationConsortium/ac-dev-lab/blob/main/src/ac_training_lab/ot-2/_scripts/OT2mqtt.py

There would be an extra collection within mongodb I guess, for storing the state. We could assume a certain rate of evaporation and also make sure that with each experiment call, we're subtracting some amount. Likewise, we'd need the ability to trigger this manually.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@Neil-YL Feel free to ask if you cannot find things you need or anything you think I may know.😉

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Add restock maintenance Prefect step for OT2 demo Add inventory tracking and restock maintenance for OT-2 color mixing Nov 3, 2025
Copilot AI requested a review from sgbaird November 3, 2025 18:47
Copilot finished work on behalf of sgbaird November 3, 2025 18:47
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.

Add "restock" maintenance Prefect step for OT2 color matching demo

2 participants