Skip to main content
from edgeml import edgeml
import time
import math

Globals

READ_KEY = "YOUR_READ_KEY"  # Replace with your actual read key
WRITE_KEY = "YOUR_WRITE_KEY"  # Replace with your actual write key
BACKEND_URL = "YOUR_BACKEND_URL"  # Replace with your actual backend URL

Upload randomly generated data to the server using the edge-ml python library

To upload data to edge-ml, we can use the DatasetCollector

For this, we need to provide the following information:

Parameter Description
url The URL to the edge-ml instance.
write_key The API key for writing into the system.
use_own_timestamps If true, users can pass timestamps to the collection function. Otherwise, timestamps are set by the DatasetCollector.
timeSeries An array containing the names of the time series to be used.
metaData A dictionary with metadata. Must contain only key-value pairs where both keys and values are strings.
datasetName = "Example Dataset"
useOwnTimeStamps = False
timeSeries = ["Acc", "Mag"]
metaData = {}

collector = edgeml.DatasetCollector(BACKEND_URL,
                                    WRITE_KEY,
                                    datasetName,
                                    useOwnTimeStamps,
                                    timeSeries,
                                    metaData)

Now we can add data to this dataset

For this we can call the addDataPoint-function. Don't forget to call onComplete after inserting all the data.

timestamp = round(time.time() * 1000)
for i in range(100):
    timestamp += 40
    x = i / 10000        # Adjust the divisor to control the frequency of the wave
    y_acc = math.sin(x)  # Generate the y-coordinate for "Acc"
    y_mag = math.cos(x)  # Generate the y-coordinate for "Mag"
    await collector.addDataPoint(timestamp, "Acc", y_acc) 
    await collector.addDataPoint(timestamp, "Mag", y_mag) 

# signal data collection is complete. This uploads the remaining data to the server
collector.onComplete()
True

Retrieve data from edge-ml

It is also possible to obtain the datasets in a project. To do so use the DatasetReceiver

project = edgeml.DatasetReceiver(BACKEND_URL, READ_KEY)

# See a single dataset
print(project.datasets[0])
# Or get some attribute from the dataset
print(project.datasets[0].metaData)

# Until now, we have only the metdata of the datasets.
# We can also download the actual time-series data.

# Only for one timeSeries:
project.datasets[0].timeSeries[0].loadData()
# Or for one dataset:
project.datasets[0].loadData()
# Or for all datasets:
project.loadData()
Dataset - Name: Example Dataset, ID: 682ee7d8a3130d2327595758, Metadata: {}
{}

Get the data in the dataset

The datasets are provided as pandas dataframes

# Access the data of a dataset
print("Dataset")
print(project.datasets[0].data.head())

print("\nTimeseries")
# Or just one time series
print(project.datasets[0].timeSeries[0].data.head())

# Or get all dataset in a project as list
project_data = project.data
print("\n#datasts: ", len(project_data))
Dataset
                     time     Acc  Mag
0 2025-05-22 09:01:12.595  0.0000  1.0
1 2025-05-22 09:01:12.635  0.0001  1.0
2 2025-05-22 09:01:12.675  0.0002  1.0
3 2025-05-22 09:01:12.715  0.0003  1.0
4 2025-05-22 09:01:12.755  0.0004  1.0

Timeseries
                     time     Acc
0 2025-05-22 09:01:12.595  0.0000
1 2025-05-22 09:01:12.635  0.0001
2 2025-05-22 09:01:12.675  0.0002
3 2025-05-22 09:01:12.715  0.0003
4 2025-05-22 09:01:12.755  0.0004

#datasts:  11

Get the labels in the dataset

project.datasets[0].labelings
[]

Labeling in the project

To labelings in a project define the labels

project.labelings
[{'_id': '682f07918245a094a595cdf5',
  'name': 'test',
  'labels': [{'name': 't1',
    'color': '#0081DD',
    '_id': '682f07918245a094a595cdf3'},
   {'name': 't2', 'color': '#C24A5F', '_id': '682f07918245a094a595cdf4'}],
  'projectId': '682ec257f42749f02e3a325f'}]

Download files

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

Source Distribution

edge_ml-0.0.0.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

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

edge_ml-0.0.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file edge_ml-0.0.0.tar.gz.

File metadata

  • Download URL: edge_ml-0.0.0.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for edge_ml-0.0.0.tar.gz
Algorithm Hash digest
SHA256 cb308b33896ceaca84af0b2c3dc73380232d9c71f5580cdd2ff3ff878f57f464
MD5 b9a1b2267aca90f06c9a18008661e7b6
BLAKE2b-256 c69c47154b6c19bc9e4f7d06353b17ced7c6dc0e6763d91780d819e1dc2660aa

See more details on using hashes here.

File details

Details for the file edge_ml-0.0.0-py3-none-any.whl.

File metadata

  • Download URL: edge_ml-0.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for edge_ml-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ff0fd5bf82ccdd597c827968b0f4a66e6dfcc99cad3bb6e9878665d37d75386c
MD5 1f53ea20aae26e4180c1fc7a1433da51
BLAKE2b-256 1dd6aa618d8612e2cd4578d1e4ec48ba3832daa241c1a898303dbc5fcd5c96fc

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 Sentry Error logging StatusPage Status page