No project description provided
Project description
signalflow-client-python
Table of Contents
Installation
To install the SignalFlow Python client library, open a terminal and run the following command:
pip install signalflow-client-python
Run a SignalFlow computation
The following example allows you run a SignalFlow computation from the command line. For additional examples, see the examples directory.
-
Install the
signalfx
package:pip install signalfx
-
Create a
.py
file that includes the following content:#!/usr/bin/env python import argparse import signalfx # noqa from signalfx.signalflow import messages, SignalFlowClient # noqa if __name__ == "__main__": parser = argparse.ArgumentParser( description="SignalFx SignalFlow streaming analytics demo" ) parser.add_argument( "--stream-endpoint", help="SignalFx SignalFlow stream API endpoint", default="https://stream.signalfx.com", ) parser.add_argument("token", help="Your SignalFx API access token") parser.add_argument("program", help="SignalFlow program to execute") options = parser.parse_args() client = SignalFlowClient( token=options.token, endpoint=options.stream_endpoint, ) try: # Execute the computation and iterate over the message stream print("Requesting computation: {0}".format(options.program)) c = client.execute(options.program) print("Waiting for data...") for msg in c.stream(): if isinstance(msg, messages.DataMessage): print( "\033[34;1m{0}\033[;0m @{1}: {2}".format( "data", msg.logical_timestamp_ms, ", ".join( [ "\033[;1m{0}\033[;0m: {1}".format(k, v) for k, v in msg.data.items() ] ), ) ) elif isinstance(msg, messages.EventMessage): print( "\033[35;1m{0}\033[34;1m@\033[;0m @{1}: {2}".format( "event", msg.timestamp_ms, ", ".join( [ "\033[;1m{0}\033[;0m: {1}".format(k, v) for k, v in msg.properties.items() ] ), ) ) elif isinstance(msg, messages.MetadataMessage): print( "\033[32;1m{0}\033[;0m for \033[;1m{1}\033[;0m:\n {2}".format( "metadata", msg.tsid, "\n ".join( [ "\033[;1m{0}\033[;0m: {1}".format(k, v) for k, v in msg.properties.items() ] ), ) ) except KeyboardInterrupt: print(" Detaching from computation...") finally: client.close() print("Done.")
-
Run the Python script, specifying values for the streaming endpoint (optional), the API access token, and the SignalFlow program.
For example:
python <file-name>.py --stream-endpoint https://stream.us0.signalfx.com <api-token> "data('sf.org.num.orguser').publish()"
License
signalflow-client-python
is distributed under the terms of the Apache-2.0 license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file signalflow_client_python-1.3.0.tar.gz
.
File metadata
- Download URL: signalflow_client_python-1.3.0.tar.gz
- Upload date:
- Size: 17.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.27.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15d89c7e80c193288d72b7fba88cce2aac4ede225a29d80015f491b3b3a6e454 |
|
MD5 | 19caf29aca30eb570b60cc27f375f63e |
|
BLAKE2b-256 | a0713bc728855485be0c54a23aa98f6915513b43137a2130c4a677ac860dcb80 |
File details
Details for the file signalflow_client_python-1.3.0-py3-none-any.whl
.
File metadata
- Download URL: signalflow_client_python-1.3.0-py3-none-any.whl
- Upload date:
- Size: 20.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.27.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1567268c937853771e90584002dd257cff8615d96146c786917b17047606701c |
|
MD5 | 88a4d6c387ef194d44c5fbc3fcd3541f |
|
BLAKE2b-256 | ab0a3603dac5fe3d4f13e9e977ec860d8205bc4cc242a71a48deb8f2d2eb2dcd |