Giter Club home page Giter Club logo

mona-uds-client's Introduction

Mona's Unix Domain Socket client code

This repository contains all Mona python client for UDS code. The main package is under the dir "client", and is published to PyPi as "mona-uds-client".

The Mona UDS client requires a Mona Agent deployed locally in order to run. Other packages contain required information about how to install the Mona Agent in different environments and are published separately.

With any issues please email [email protected].

Example use:

Example code can be found in client/mona_uds_client_test.py.

In a nutshell, after installing the PyPi package: $ pip install mona_uds_client

This is the common use:

from mona_uds_client.mona_uds_client import MonaUdsClient, MonaSingleMessage

# Use User ID as supplied by Mona team here.
client = MonaUdsClient("test_user")

# Use relevant context ID as defined in Mona configuration.
context_class = "MY_CONTEXT"

# Export a batch of two messages to Mona.
message1 = {"x": 1, "s": "some_str", "l": ["a"], "o": {"k": ["v1", "v2"]}}
message2 = {"x": 2, "s": "another_str", "l": ["b"], "o": {"k": ["v3", "v4"]}}

# Actual export
client.export(
    [
        MonaSingleMessage(
            contextId="context_id1",
            message=message1,
            arcClass=context_class,
        ),  # No export timestamp means use current time
        MonaSingleMessage(
            contextId="context_id2",
            message=message2,
            arcClass=context_class,
            exportTimestamp=1234567890
        ),
    ]
)

Deployment

The UDS client uses a local folder to communicate with Mona UDS agent. As a result, when deployed on a container, the following mounts are required to be added to the container's YAML:

In spec.template.spec:

volumes:
- name: uds-mona-socket
  hostPath:
    path: /var/run/mona-agent/

In spec.template.spec.container:

volumeMounts:
- mountPath: /uds/mona
  name: uds-mona-socket

Uploading new version to PyPI

The main reference to follow to do that is on: https://packaging.python.org/tutorials/packaging-projects/

Prerequisites:

  1. Register on PyPI with your mona email: https://pypi.org/
  2. Ask [email protected] or [email protected] to add you as collaborator
  3. If not installed, install twine: $ python3 -m pip install --user --upgrade twine
  4. If not installed, install build tools: $ python3 -m pip install --user --upgrade setuptools wheel

Actual upload:

  1. Change version number under setup.py
  2. If a new dependency is required, add it under setup.py under "install_requires"
  3. Build new version:
$ python3 setup.py sdist bdist_wheel
  1. Upload new version (can change '*' to actual version):
$ python -m twine upload dist/*

mona-uds-client's People

Contributors

nemo-mona avatar tzachmona avatar razvantudorica-gl avatar monalabs avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.