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).

MADSci Data Manager Diagram

Notable Features

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

Installation

The MADSci Data Manager is available via the Python Package Index, and can be installed via:

pip install madsci.data_manager

This python package is also included as part of the madsci Docker image. You can see an example docker image in this example compose file.

Note that you will also need a MongoDB database (included in the example compose file)

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, define your data manager and mongodb services based on the example compose file.
# 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.3.0.tar.gz (5.6 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.3.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: madsci_data_manager-0.3.0.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.24.1 CPython/3.9.22 Linux/6.11.0-1013-azure

File hashes

Hashes for madsci_data_manager-0.3.0.tar.gz
Algorithm Hash digest
SHA256 5779c87892a4440c6c0c5cca252e5e4e53bf9f837ec6ad62fc7eca452a8ef765
MD5 e82268d25697435199bf093f6e50f624
BLAKE2b-256 1a3e4a86cef8f14e555c94f75d116fe95b11d5a06110ecd13037e59ac8d97914

See more details on using hashes here.

File details

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

File metadata

  • Download URL: madsci_data_manager-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.24.1 CPython/3.9.22 Linux/6.11.0-1013-azure

File hashes

Hashes for madsci_data_manager-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e28a85ed0a3f291ac6d6c8a8e20372ad537c71c0ff44469e60cc28e74d36ab15
MD5 22b2934f3b29637a79fea222ddfbddba
BLAKE2b-256 7bf5cefa3000929a5a69f300553ed7ca0c72796d9e3a7ed30516760f35b0ea81

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