Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Step by Step Midas Guide #2

Open
msimar opened this issue Nov 25, 2014 · 4 comments
Open

Step by Step Midas Guide #2

msimar opened this issue Nov 25, 2014 · 4 comments

Comments

@msimar
Copy link

msimar commented Nov 25, 2014

Hi Midas Team

As per my observation, the step by step guide to run midas and do some test is missing in the documentation. I follows the example:

Start stream : midas_stream_example.py
Start Node A : midas_node_example_A.py config.ini node_A
Start Node B : midas_node_example_B.py config.ini node_B
Start Dispatcher : midas_dispatcher_example.py config.ini dispatcher

then what should be the next step ?

I created client as mention in wiki. I am getting following output :
$ python client.py
{'metric_a': 'unknown metric and/or channel', '3': 'unknown metric and/or channel', '1': 'unknown metric and/or channel', 'Ch1': 'unknown metric and/or channel'}

Kindly guide on how to proceed further.

@jtorniainen
Copy link
Contributor

Hi msimar!

I tested the examples as you had and managed to replicate the error. Turns out the Python code for the client (https://github.com/bwrc/midas/wiki/Creating-a-client) contained some typos which have now been fixed.

For reference heres the output I get with the new client code:
$ python3 client.py
{'metric_a_Ch1_1_3': 0.8459284727850395}

-jt

@msimar
Copy link
Author

msimar commented Nov 25, 2014

Thanks, it works.
now getting an output !!

@msimar msimar closed this as completed Nov 25, 2014
@msimar msimar reopened this Nov 27, 2014
@msimar
Copy link
Author

msimar commented Nov 27, 2014

How metric evaluation happens in Midas from raw data ?

@jtorniainen
Copy link
Contributor

Hi!

How metric evaluation happens in Midas from raw data ?

  • Metric functions are (usually) internal class methods of the node.
  • You make metric functions "visible" to the MIDAS by adding them to the self.metric_functions list in init method
  • Each metric function must take at least one argument. The first positional argument is the data the user specified during their request. So for example

http://localhost:8080/example_node_A/metric/metric_b:Ch1/0.01

would call metric function 'metric_b' using 0.01 seconds of data from channel 'Ch1'
This means the first positional argument of 'metric_b' is a dict containing channel names and data values. For the example query above the input argument would be this (underlying data has a sampling rate of 500 Hz):

{'data': [[6.0, 7.0, 8.0, 9.0]], 'names': ['Ch1']}

It is also possible to call a metric function with multiple channels. Example:

http://localhost:8080/example_node_A/metric/metric_b:Ch1,Ch2/0.01

{'data': [[74.0, 75.0, 76.0, 77.0], [74.0, 75.0, 76.0, 77.0]], 'names': ['Ch1', 'Ch2']}

The midas_node_example_A.py is a little bit misleading because the method 'metric_b' does not calculate anything from the input argument. Heres an example metric function that calculates the mean of the first channel from the data it got as input.

def metric_b(self, x):
    result = numpy.mean(x['data'][0])
return result

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants