Skip to main content

The Modular Autonomous Discovery for Science (MADSci) Data Manager.

Project description

MADSci Data Manager

Handles capturing, storing, and querying data, in either JSON value or file form, created during the course of an experiment (either collected by instruments, or synthesized during anaylsis).

Notable Features

  • Collects and stores data generated in the course of an experiment as "datapoints"
  • Current datapoint types supported: Values (as JSON-serializable data) and Files (stored as-is)
  • Datapoints include metadata such as ownership info and datetimestamps
  • Datapoints are queryable and searchable based on both value and metadata

Usage

Manager

To create and run a new MADSci Data Manager, do the following in your MADSci lab directory:

  • If you're not using docker compose, provision and configure a MongoDB instance.
  • If you're using docker compose, create or add the following to your Lab's compose.yaml, defining your docker compose services for the DataManager and a MongoDB database to store datapoints.
name: madsci_example_lab
services:
  mongodb:
    container_name: mongodb
    image: mongodb/mongodb-community-server:latest
    ports:
      - 27017:27017
  data_manager:
    container_name: data_manager
    image: madsci:latest
    build:
      context: ..
      dockerfile: Dockerfile
    environment:
      - USER_ID=1000
      - GROUP_ID=1000
    network_mode: host
    volumes:
      - /path/to/your/lab/direcotry:/home/madsci/lab/
      - .madsci:/home/madsci/.madsci/
    command: python -m madsci.data_manager.data_server
    depends_on:
      - mongodb
# Create a Data Manager Definition
madsci manager add -t data_manager
# Start the database and Data Manager Server
docker compose up
# OR
python -m madsci.data_manager.data_server

You should see a REST server started on the configured host and port. Navigate in your browser to the URL you configured (default: http://localhost:8004/) to see if it's working.

You can see up-to-date documentation on the endpoints provided by your event manager, and try them out, via the swagger page served at http://your-data-manager-url-here/docs.

Client

You can use MADSci's DataClient (madsci.client.data_client.DataClient) in your python code to save, get, or query datapoints.

Here are some examples of using the DataClient to interact with the Data Manager:

from madsci.client.data_client import DataClient
from madsci.common.types.datapoint_types import ValueDataPoint, FileDataPoint
from datetime import datetime

# Initialize the DataClient
client = DataClient(url="http://localhost:8004")

# Create a ValueDataPoint
value_datapoint = ValueDataPoint(
    label="Temperature Reading",
    value={"temperature": 23.5, "unit": "Celsius"},
    data_timestamp=datetime.now()
)

# Submit the ValueDataPoint
submitted_value_datapoint = client.submit_datapoint(value_datapoint)
print(f"Submitted ValueDataPoint: {submitted_value_datapoint}")

# Retrieve the ValueDataPoint by ID
retrieved_value_datapoint = client.get_datapoint(submitted_value_datapoint.datapoint_id)
print(f"Retrieved ValueDataPoint: {retrieved_value_datapoint}")

# Create a FileDataPoint
file_datapoint = FileDataPoint(
    label="Experiment Log",
    path="/path/to/experiment_log.txt",
    data_timestamp=datetime.now()
)

# Submit the FileDataPoint
submitted_file_datapoint = client.submit_datapoint(file_datapoint)
print(f"Submitted FileDataPoint: {submitted_file_datapoint}")

# Retrieve the FileDataPoint by ID
retrieved_file_datapoint = client.get_datapoint(submitted_file_datapoint.datapoint_id)
print(f"Retrieved FileDataPoint: {retrieved_file_datapoint}")

# Save the file from the FileDataPoint to a local path
client.save_datapoint_value(submitted_file_datapoint.datapoint_id, "/local/path/to/save/experiment_log.txt")
print("File saved successfully.")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

madsci_data_manager-0.0.4.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

madsci_data_manager-0.0.4-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file madsci_data_manager-0.0.4.tar.gz.

File metadata

  • Download URL: madsci_data_manager-0.0.4.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.22.3 CPython/3.9.21 Linux/6.8.0-1021-azure

File hashes

Hashes for madsci_data_manager-0.0.4.tar.gz
Algorithm Hash digest
SHA256 3a4795f691d03e3cff558d9e48a43d83994cd18e4f7dec51a26e9765c15a4e23
MD5 ab334a834ce25dcb8359d7449281a0ee
BLAKE2b-256 f47d95ce1b6be846cddb304b9f10dc119e8f98cb8cc7a462ca42cc6e892db16d

See more details on using hashes here.

File details

Details for the file madsci_data_manager-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: madsci_data_manager-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.22.3 CPython/3.9.21 Linux/6.8.0-1021-azure

File hashes

Hashes for madsci_data_manager-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d67645a44d8e3eb8ed9484ef986dc9e082296df1b86d99eb63c329e637f43a5e
MD5 c2fdfae1e9b32e73133e5471d064c8ab
BLAKE2b-256 43147e74a52c61bf7d0b9992ff504cfa7acfde5b1a291b62d62c5b40ca9ad69e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page