Skip to content

Latest commit

 

History

History
84 lines (60 loc) · 2.16 KB

README.md

File metadata and controls

84 lines (60 loc) · 2.16 KB

Seer Python Client

Build Status Python Version Coverage Status

The python client for the seer forecasting server.

Installation

The seer python client is available on PyPi, so just:

pip install seer

to get the latest release.

Usage

Since this is a client library, you'll need a server to communicate with. To get up and running just:

docker run -d -p 8080:8080 cshenton/seer

Check out the project repo over here

Then, to interact over localhost

import datetime
import seer


HOST = "localhost:8080"

def graph(times, values, forecast):
    pass

def main():
    name = "myStream"
    period = 3600
    times = [...]
    values = [...]
    forecast_length = 100

    # Connect to the server and create a stream
    client = seer.Client(HOST)
    client.create_stream(name, period)

    # Feed in most of the data, generate a forecast
    client.update_stream(name, times, values)
    f = client.get_forecast(name, forecast_length)

    # Graph the forecast against the true result
    graph(times, values, f)

if __name__ == '__main__':
    main()

(For Contributors) Generating gRPC stubs

Assuming this repo is stored in cshenton/seer-python, next to cshenton/seer, we generate client stubs with:

# Generates seer_pb2.py and seer_pb2_grpc.py
python -m grpc_tools.protoc -I ../seer/seer --python_out=./seer --grpc_python_out=./seer ../seer/seer/seer.proto

Then, because the grpc devs don't care about python 3, we need to fix the relative imports.

# in seer_pb2_grpc.py
# From this
import seer_pb2 as seer__pb2

# To this
from . import seer_pb2 as seer__pb2

I also manually remove SeerServicer and add_SeerServicer_to_server. protoc doesn't provide an option to just generate client stubs, and I want test coverage numbers to be correct.