Giter Site home page Giter Site logo

balena_client's Introduction

Balena Client

This is made to be a more robust method to giving access to Balena for different python project that what we have done in the past at Smart Vision Works. It simplifies and streamlines our use of the Balena SDK.

Features

  • Uses a configurable on-disk cache to store the balena data to speed up the use of the balena SDK. The first calls will take awhile but all subsequent calls will be fast. All calls have the option to bypass the cache.
  • Uses MontyDB as the cache, which allows us to search the balena data using mongo queries. More than 90% of other balena wrappers were functions to filter the API data in different ways. This greatly simplifies the interface
  • The package is published to the Smart Vision Works GitHub package registry and can be more easily integrated into other projects. You can use it in your project by pip install -e git+https://github.com/Smart-Vision-Works/balena_client#egg=balena_client.
  • Dependencies for this python module are managed by PDM.
  • Gives the ability to preload balena data if you wanted to do it at program startup to speed up the use of the balena SDK. Best to make calls in a thread.

Example usage

    client = BalenaClient(1000)

    query = {"device_name":{"$regex": "SVW-CB.*"}}
    projection = {"device_name": 1, "uuid": 1, "is_online": 1, "device_tags": 1}
    devices = client.get_devices(query, projection)

    applications = client.get_applications({"app_name": "Tater_SAI"}, {"app_name": 1, "id": 1, "uuid": 1})

    releases = client.get_releases(fleet="FM_HUB_K1", query={"release_tags.version": "v1.0.10"})

Running the development environment

PDM is used to manage the dependencies for this project. PDM sets up its own virtual environment and installs the dependencies in that environment. To run the development environment, run the following commands:

pdm install
pdm run python src/balena_client/balena_client.py

By prepending pdm run before anything you want to run it ensures that the correct virtual environment is used. To run the tests, run the following command:

pdm run pytest

Using secrets in development

The scripts uses secrets for accessing balena. For development use a .env file with the secrets listed there. It will get loaded automatically if it exists.

BALENA_AUTH_TOKEN=GarbageymkUdhgjGo32C2WBlUXfwdno0C

balena_client's People

Contributors

kfrance 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.