The Python client interface to the Loud ML model server.
loudml-python requires a running Loud ML model server . See Loud ML's quickstart for installation instructions.
loudml-python can be installed using pip similar to other Python packages. Do not use sudo with pip. It is usually good to work in a virtualenv or venv to avoid conflicts with other package managers and Python projects. For a quick introduction see Python Virtual Environments in Five Minutes.
To install loudml-python, simply:
$ pip install loudml-python
or from source:
$ python setup.py install
If you’ve installed loudml-python locally, the loudml command should be available via the command line. Executing loudml will start the CLI and automatically connect to the local Loud ML model server instance (assuming you have already started the server with systemctl start loudmld or by running loudmld directly). The output should look like this:
$ loudml
Connected to localhost:8077 version 1.6.0-577c87de
Loud ML shell 1.6.0-42136d38
>
You can get a description of the available commands:
> help
The main helper in the Python client library is the Loud class. You can create an instance that connects to a remote Loud ML model server and run queries.
>>> from loudml_py.client import Loud
>>> loud = Loud(hosts=['localhost:8077'])
>>> models = loud.models.get(
model_names=['first_model'],
fields=['settings', 'state'],
include_fields=True,
)
>>> len(models)
1
>>> print(models[0]['state'])
{'trained': False}
Long running commands eg training return a job name. Use loudml.jobs.id(job_name) to create a class instance and then track the progress of the job or cancel it. loudml uses tqdm to display progress information.
def cancel_job_handler(*args):
job.cancel()
print('Signal received. Canceled job: ', job.id)
sys.exit()
signal.signal(signal.SIGINT, cancel_job_handler)
while not job.done():
time.sleep(1)
job.fetch()
The loudml-wave tool is included in this package. You can use the application to output time series data with a given pattern and write the data to a bucket.
The output should look like this:
$ loudml-wave -v -f now-1h -t now --shape sin --tags tag_one:foo,tag_two:bar output_bucket
INFO:root:generating data from 2019-09-21 07:23:51.350293 to 2019-09-21 08:23:51.350316
Connected to localhost:8077 version 1.5.0.88.g5ad0216
INFO:root:writing 131 points
timestamp value tags
1569043431.35 38369.884 tag_one=foo,tag_two=bar
1569043431.85 70881.022 tag_one=foo,tag_two=bar
1569043491.35 33949.816 tag_one=foo,tag_two=bar
1569043551.35 30892.148 tag_one=foo,tag_two=bar
1569043551.6833332 10851.922 tag_one=foo,tag_two=bar
You can get a description of the available commands:
$ loudml-wave -h
Please see CHANGELOG.md.
If you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker.
loudml-python is developed and maintained by Sebastien Leger (@regel). It can be found here: https://github.com/loudml/loudml-python
Special thanks to:
- Christophe Osuna (@osunac) for all the review and packaging support.
This project is licensed under the MIT license. See the LICENSE file for more info.