m42e / mayan-automatic-metadata

A (to be) framework for automatic, external processing of mayan documents for assigning tags and metadata
13 stars 4 forks source link

About Mayan automatic metadata

[!WARNING]
This is currently unmaintained, as my use-case is done and I see this as a proof of concept. Feel free to contact me if you like to maintain it.

I wanted to be able to have my documents automatically tagged as I don't like to repeat these kinds of tasks over and over again.

This MAM mayan automatic metadata tool consists of three parts:

HowTo

The prequesites you have to have:

You could either let MAM have its own docker stack (including network) then you have to publish some ports. Or the prefered way, having it in the same network which is what is described here.

Add the contents of the docker-compose file to the one you are using for mayan already.

version: '2'

services:
  mayan-mam-web:
    container_name: mayan-mam-web
    image: m42e/mayan-mam-web
    restart: always
    environment:
      REDIS_URL: redis://results:6379/

  mayan-mam-worker:
    container_name: mayan-mam-worker
    image: m42e/mayan-mam-worker
    restart: always
    environment:
      REDIS_URL: redis://results:6379/
      MAYAN_USER: mam-user
      MAYAN_PASSWORD: secretpassword
      MAYAN_URL: https://yourinstance/api/
      USE_GIT_PLUGINS: 0
      GIT_PLUGINS_URL: https://mygithubuser:<applicationtoken>@github.com/mygithubuser/mam-plugins

We are having twos services here, one is the webfrontend (hilarious to call it so, as it only creates tasks for the worker, no real frontend). This offers and endpoint to use in mayan workflows. The endpoint is located at the base url, so from inside the stack: http://mayam-mam-web:8000/.

The following environment variables are relevant:

You could also mount (with docker) the /app/plugins directory to a folder of your choice, where you place the plugins.

Trigger it

The way of triggering is quite simple. Just drop a POST or GET request to the endpoint with the documentid attached. E. g. http://mayan-mam-web:8000/345 This will enqueue the task for the worker.

NB: This should be done after the OCR content is available.

The workers job

The worker receiving the processing request, will get the required information from mayan, read the documents data and applies its strategies to get the values and add tags.

That's all folks.