コード例 #1
0
def basic_analysis(params):
    import mdml_client as mdml
    # Connect to the MDML to query for data
    exp = mdml.experiment(params['experiment_id'], params['user'],
                          params['pass'], params['host'])
    # Grabbing the latest temperature value
    query = [{"device": "DATA1", "variables": ["temperature"], "last": 1}]
    res = exp.query(query, verify_cert=False)  # Running the query
    tempF = res['DATA1'][0]['temperature']
    tempC = (tempF - 32) * (5 / 9)
    return {'time': mdml.unix_time(True), 'tempC': tempC}
コード例 #2
0
ファイル: labview_client.py プロジェクト: jelias1/MDML_Client
def lv_MDML_connect(userdata):
    global EXPERIMENT_SESSION
    for i in range(len(userdata)):
        dat = userdata[i]
        if not isinstance(dat, str):
            userdata[i] = dat.decode('utf-8')
    experiment_id = userdata[0].upper()
    username = userdata[1]
    password = userdata[2]
    host = userdata[3]
    EXPERIMENT_SESSION = mdml.experiment(experiment_id, username, password,
                                         host)
コード例 #3
0
def sum_vars(params):
    import mdmlclient
    import mdml_client as mdml
    query = [{
        "device": "DEVICE_A",
        "variables": [],
        "last" : 1
    }]
    exp = mdml.experiment('TEST','test','testtest','merfpoc.egs.anl.gov')
    dat = exp.query(query)
    print(dat)
    row = dat['DEVICE_A'][0]
    var_sum = float(row['variable1']) + float(row['variable2']) + float(row['variable3']) + float(row['variable4']) + float(row['variable5'])
    return str(var_sum)
コード例 #4
0
        6, 50, 100, 250, 500, 750, 1000, 2000, 2500, 3000, 4000, 5000, 10000,
        11000, 12000, 13000, 14000, 15000, 20000, 30000, 40000, 50000, 60000,
        70000, 80000, 90000, 100000
    ]
    DELAYS = [
        0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
        1, 1, 1, 1.5, 1.5, 1.5, 1.5
    ]
    assert len(POINTS) == len(DELAYS)
    if THROUGHPUT:
        RUN = 'TEXT_THROUGHPUT'
    else:
        RUN = 'TEXT_PROCESSING'

# Create MDML experiment
My_MDML_Exp = mdml.experiment(Exp_ID, username, password, host)

for j, num_points in enumerate(POINTS):
    # Creating configuration files
    if IMAGES:
        device = f'IMAGE_{num_points[0]}_{num_points[1]}'
        config = {
            "experiment": {
                "experiment_id": "TEST",
                "experiment_notes": "Example image streaming with the MDML",
                "experiment_devices": [device]
            },
            "devices": [{
                "device_id": device,
                "device_name": "Example images",
                "device_output": "Random images",
コード例 #5
0
if args.register:
    from funcx.sdk.client import FuncXClient
    fxc = FuncXClient()
    funcx_func_uuid = fxc.register_function(
        basic_analysis, description="Temperature conversion")
    print(f'funcX UUID: {funcx_func_uuid}')
else:  # Use the most recent function funcx ID (manually put here after running --register once)
    funcx_func_uuid = "1712a2fc-cc40-4b2c-ae44-405d58f78c5d"  # Sept 16th 2020

# Now that the function is ready for use, we need to start an experiment to use it with
import sys
import time
sys.path.insert(1, '../')  # using local mdml_client
import mdml_client as mdml

exp = mdml.experiment("TEST", args.username, args.password, args.host)
exp.add_config(auto=True)
exp.send_config()
time.sleep(1)

# Send some data to analyze
data = {
    'time': mdml.unix_time(True),
    'temperature': 212,
    'humidity': 58,
    'note': 'Temperature and humidity values'
}
exp.publish_data(device_id="DATA1", data=data, add_device=True)

# Now, run the analysis
# Define function parameters
コード例 #6
0
ファイル: dev.py プロジェクト: jelias1/MDML_Client
import sys # using local mdml_client
sys.path.insert(1, '../')

import mdml_client as mdml
import time
exp = mdml.experiment("TEST", "test", "testtest", "merfpoc.egs.anl.gov")
exp.add_config('dev_config.json')
exp.send_config()
time.sleep(1)

curr_time = mdml.unix_time(True) # True for integer return instead of string
print(curr_time)

# Data type of dict required for the first .publish_data call when using auto configurations. 
data = [
    [300, 400, 500, 600],
    [1200, 1500, 2100, 1750]
]
exp.publish_vector_data(device_id = "SMPS_VECTOR", data = data, timestamp = curr_time+2)

try:
    while True:
        time.sleep(10)
except KeyboardInterrupt:
    print("Quitting")
finally:
    exp.reset()
    time.sleep(1)
    exp.disconnect()
コード例 #7
0
# Parameters to run the example
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--id", help="MDML experiment ID", required=True)
parser.add_argument("--host", help="MDML instance host", required=True)
parser.add_argument("--username", help="MDML username", required=True)
parser.add_argument("--password", help="MDML password", required=True)
args = parser.parse_args()

import time
import mdml_client as mdml

exp = mdml.experiment(args.id, args.username, args.password, args.host)

time.sleep(3)
try:

    def callback_func(client, userdata, message):  # Only message is used here
        print(
            f'TOPIC: {message.topic}\nPAYLOAD: {message.payload.decode("utf-8")}'
        )

    exp.listener(callback=callback_func)
except KeyboardInterrupt:
    print("Quitting...")
finally:
    exp.disconnect()
コード例 #8
0
import sys
sys.path.insert(1, '../')

import time
import mdml_client as mdml

exp = mdml.experiment("FSP", "Flame", "123FlameOn!!", "merfpoc.egs.anl.gov")
time.sleep(3)
try:
    def callback_func(client, userdata, message): # Only message is used here
        print(f'TOPIC: {message.topic}\nPAYLOAD: {message.payload.decode("utf-8")}')
    exp.listener(analysis_names = ["BAYES_OPTIM"], callback = callback_func)
except KeyboardInterrupt:
    print("Quitting...")
finally:
    exp.disconnect()