Skip to main content

A python client for the memri Pod, and tools to create Plugins

Project description

Pymemri

Pymemri is a python library for creating Plugins for the Memri Personal online datastore (pod). Pymemri has a PodClient to communicate with the pod, and tools to build and test plugins.

Gitlab pipeline status (self-hosted) Discord Twitter URL

Plugins connect and add the information to your Pod. Plugins that import your data from external services are called Importers (Gmail, WhatsApp, etc.). Plugins that connect new data to the existing data are called indexers (face recognition, spam detection, object detection, etc.). Lastly there are plugins that execute actions (sending messages, uploading files). This repository is built with nbdev, which means that the repo structure has a few differences compared to a standard python repo.

Installing

As a package

pip install pymemri

Development

To install the Python package, and correctly setup nbdev for development run:

pip install -e . && nbdev_install_git_hooks

The last command configures git to automatically clean metadata from your notebooks before a commit.

Quickstart: Pod Client

All interaction between plugins and the pod goes via the Pymemri PodClient. To use this client in development, we first need to have a pod running locally. The quickest way to do this is to install from the pod repo, and run ./examples/run_development.sh.

If you have a running pod, you can define and add your own item definitions:

from pymemri.data.itembase import Item
from pymemri.pod.client import PodClient

class Dog(Item):
    properties = Item.properties + ["name", "age"]

    def __init__(self, name: str = None, age: int = None, **kwargs):
        super().__init__(**kwargs)
        self.name = name
        self.age = age

# Connect to the pod and add the Dog item definition
client = PodClient()
client.add_to_schema(Dog)

# Add a Dog to the pod
dog = Dog("bob", 3)
client.create(dog)

Quickstart: Running a plugin

After installation, users can use the plugin CLI to manually run a plugin. For more information on how to build a plugin, see run_plugin.

With the pod running, run in your terminal|:

store_keys
run_plugin --metadata "example_plugin.json"

This stores a random owner key and database key on your disk for future use, and runs the pymemri example plugin. If everything works correctly, the output should read Plugin run success.

Docs

pymemri docs

Nbdev & Jupyter Notebooks

The Python integrators are written in nbdev (video). With nbdev, it is encouraged to write code in Jupyter Notebooks. Nbdev syncs all the notebooks in /nbs with the python code in /pymemri. Tests are written side by side with the code in the notebooks, and documentation is automatically generated from the code and markdown in the notebooks and exported into the /docs folder. Check out the nbdev quickstart for an introduction, watch the video linked above, or see the nbdev documentation for a all functionalities and tutorials.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pymemri-0.0.24.tar.gz (63.0 kB view hashes)

Uploaded Source

Built Distribution

pymemri-0.0.24-py3-none-any.whl (76.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page