Skip to main content

Marple SDK for Python

Project description

Marple SDK

An SDK to interact with Marple DB & Insight

Installation and importing

Install the Marple SDK using your package manager:

  • poetry add marpledata
  • uv add marpledata
  • pip install marpledata

The SDK currently exposes:

from marple import DB      # Marple DB
from marple import Insight # Marple Insight

Marple DB

To get started:

  • Create a stream in the Marple DB UI
  • Create an API token (in user settings)

If you are using a VPC or self-hosted version, pass a custom api_url to DB(...) (it should end in /api/v1).

Example: import a file and poll ingest status

This is the typical flow for importing a new file into Marple DB:

import time
from marple import DB

# Create a stream + API token in the Marple DB web application
STREAM = "Car data"
API_TOKEN = "<your api token>"
API_URL = "https://db.marpledata.com/api/v1"  # optional if using the default SaaS

db = DB(API_TOKEN, API_URL)

db.check_connection()

dataset_id = db.push_file(STREAM, "tests/examples_race.csv", metadata={"driver": "Mbaerto"})

while True:
    status = db.get_status(STREAM, dataset_id)
    if status.get("import_status") in {"FINISHED", "FAILED"}:
        break
    time.sleep(1)

Common operations

  • List streams: db.get_streams()
  • List datasets in a stream: db.get_datasets(stream_key)
  • Upload a file to a file-stream: db.push_file(stream_key, file_path, metadata={...})
  • Poll ingest status: db.get_status(stream_key, dataset_id)
  • Download original uploaded file: db.download_original(stream_key, dataset_id, destination_folder=".")
  • Download parquet for a signal: db.download_signal(stream_key, dataset_id, signal_id, destination_folder=".")

For live/realtime streams (creating and appending data):

  • Create an empty dataset: db.add_dataset(stream_key, dataset_name, metadata=None)
  • Upsert signal definitions: db.upsert_signals(stream_key, dataset_id, signals=[...])
  • Append timeseries data: db.dataset_append(stream_key, dataset_id, data=df, shape="long"|"wide"|None)

Calling endpoints directly

For advanced use cases, you can call API endpoints directly:

db.get("/health")
db.post("/query", json={"query": "select 1"})

Marple Insight

Common operations

  • List datasets in the workspace: insight.get_datasets()
  • Get a Marple DB dataset (by dataset id): insight.get_dataset_mdb(dataset_id)
  • List signals in a dataset: insight.get_signals(dataset_filter) / insight.get_signals_mdb(dataset_id)

Example: export a dataset (H5/MAT)

from marple import DB, Insight

INSIGHT_TOKEN = "<your api token>"
INSIGHT_URL = "https://insight.marpledata.com/api/v1"  # optional if using the default SaaS
DB_TOKEN = "<your api token>"
DB_URL = "https://db.marpledata.com/api/v1"  # optional if using the default SaaS
STREAM = "Car data"

insight = Insight(INSIGHT_TOKEN, INSIGHT_URL)
db = DB(DB_TOKEN, DB_URL)

dataset_id = db.get_datasets(STREAM)[0]["id"]
insight_dataset = insight.get_dataset_mdb(dataset_id)

file_path = insight.export_data_mdb(
    dataset_id,
    format="h5",
    signals=["car.speed"],
    destination=".",
)
print("Wrote", file_path)

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

marpledata-2.3.0.tar.gz (496.0 kB view details)

Uploaded Source

Built Distribution

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

marpledata-2.3.0-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file marpledata-2.3.0.tar.gz.

File metadata

  • Download URL: marpledata-2.3.0.tar.gz
  • Upload date:
  • Size: 496.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.7

File hashes

Hashes for marpledata-2.3.0.tar.gz
Algorithm Hash digest
SHA256 f9ea61ecd4761ad11a23cfe315f58b25e69cea3553701d2a352eb8e17fd90d1a
MD5 78141fa5fe5c7e7e6597694cbd8d8adb
BLAKE2b-256 06cd94e7d9e85a7d230df20b03c42620ef7c6684c559390034c6d8b4cac43101

See more details on using hashes here.

File details

Details for the file marpledata-2.3.0-py3-none-any.whl.

File metadata

  • Download URL: marpledata-2.3.0-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.7

File hashes

Hashes for marpledata-2.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a6f93e0eeab5f1aaef997c753f78e65e315cd26f65322499e96cd6c38a068160
MD5 cee5f3a21730ef4d4d699853587aa3aa
BLAKE2b-256 bfc0a15801f0d7afbc0968f661a061ad65abb75e0f990473df3e676104e4b5f0

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