Mayan Mindee metadata/tag provider plugin

A few ideas what might be wrong (my guess is No. 3):

  1. Is http://app:8000 the correct server address? It should be if you use the standard docker compose setup.

  2. Are both containers in the same docker network?

  3. Have you configured DNS servers for your docker daemon? I always had these „Temporary failure in name resolution“ in my docker containers when the daemon did not have dns servers configured. See for example here: Fix Docker's networking DNS config

There is no mayan app container. I think this because of the big changes in the mayan docker-compose.yml that have happened recently. Where it’s using inheritance. I think the container name to use now would be

frontend

Here’s a list of all my Mayan containers.

CONTAINER ID   IMAGE                                       COMMAND                  CREATED        STATUS                 PORTS                                                                                  NAMES
110eab445cb6   mayanedms/mayanedms:s4.5                    "/usr/local/bin/entr…"   23 hours ago   Up 23 hours            8000/tcp                                                                               mayan-worker_e-1
ff0ac3d0c8cb   mayanedms/mayanedms:s4.5                    "/usr/local/bin/entr…"   23 hours ago   Up 23 hours            8000/tcp                                                                               mayan-worker_c-1
c51835acde46   mayanedms/mayanedms:s4.5                    "/usr/local/bin/entr…"   23 hours ago   Up 23 hours            8000/tcp                                                                               mayan-frontend-1
b6e8c9684380   mayanedms/mayanedms:s4.5                    "/usr/local/bin/entr…"   23 hours ago   Up 23 hours            8000/tcp                                                                               mayan-worker_d-1
a961f172faa5   mayanedms/mayanedms:s4.5                    "/usr/local/bin/entr…"   23 hours ago   Up 23 hours            8000/tcp                                                                               mayan-worker_b-1
e10f788a9d1a   mayanedms/mayanedms:s4.5                    "/usr/local/bin/entr…"   23 hours ago   Up 23 hours            8000/tcp                                                                               mayan-worker_a-1
568b6dec7e99   mayanedms/mayanedms:s4.5                    "/usr/local/bin/entr…"   23 hours ago   Up 23 hours            8000/tcp                                                                               mayan-celery_beat-1
ea88cd42c93c   redis:7.0.10-alpine                         "docker-entrypoint.s…"   23 hours ago   Up 23 hours                                                                                                   mayan-redis-1
1238fb1cc435   rabbitmq:3.11.13-management-alpine          "docker-entrypoint.s…"   23 hours ago   Up 23 hours                                                                                                   mayan-rabbitmq-1
172fff33b355   drrsatzteil/mayan-mindee-web:latest         "/entrypoint.sh web"     23 hours ago   Up 23 hours                                                                                                   mayan-mayan-mindee-web-1
33742aa3df30   elasticsearch:7.17.9                        "/bin/tini -- /usr/l…"   23 hours ago   Up 23 hours                                                                                                   mayan-elasticsearch-1
48e8a0bc3fce   drrsatzteil/mayan-mindee-worker:latest      "/entrypoint.sh rq"      23 hours ago   Up 23 hours                                                                                                   mayan-mayan-mindee-worker-1
12e3da0caa92   postgres:13.10-alpine                       "docker-entrypoint.s…"   23 hours ago   Up 23 hours                                                                                                   mayan-postgresql-1

Yeah you are right it should be „frontend“ now. I have made this change on my instance as well but in my repo it unfortunately still says „app“.

I edited mayan’s .env file with this change

MAYAN_URL=http://frontend:8000/api/v4/

Then ran the curl test again, and still get an error message about trying to find the app container.

No you need to edit your docker-compose file: change the MAYAN_URL environment variable for the mindee worker container. Don’t forget to recreate the container afterwards.

That worked for the curl test.

Now I need to figure out why I’m not getting it to work in the workflow on Mayan.

I can see from the event viewer that it’s getting triggered.

Should I be using GET or POST for the HTTP method?

image

Either would work. Make sure that your url is correct:

You can also use conditions here like:

{% if entry_log.workflow_instance.document.document_type.label == “Bezügemitteilung” %}http://mayan-mindee-web:8000/payroll/{{ entry_log.workflow_instance.document.pk }}{% elif entry_log.workflow_instance.document.document_type.label == “Rechnung” %}http://mayan-mindee-web:8000/invoice/{{ entry_log.workflow_instance.document.pk }}{% elif entry_log.workflow_instance.document.document_type.label == “Vertragsunterlagen” %}http://mayan-mindee-web:8000/general/{{ entry_log.workflow_instance.document.pk }}{% elif entry_log.workflow_instance.document.document_type.label == “Befund” %}http://mayan-mindee-web:8000/general/{{ entry_log.workflow_instance.document.pk }}{% else %}http://mayan-mam-web:8000/{{ entry_log.workflow_instance.document.pk }}{% endif %}

Thinking about it this would also work of course as long you specified that the .env file is used by your mindee worker container.

1 Like

I’ve finally made some progress, after fixing some silly mistakes on my part.

I can get Mayan to send the HTTP request, and I can see both mindee containers processing the document in their logs. When I use a standard API.

But when I try to use our custom API, I don’t even see the web container receiving the document in it’s log.

I’m sure it’s because I did something wrong in the api.json or service.py files. I have them both listed below. Can you tell me what I did wrong?

Thanks

api.json

    "custom": [
        {
            "documenttype": "Mindee",
            "account": "MyCompany",
            "endpoint": "invoice-12-demo",
            "pagelimit": 1,
            "storeocr": "mindee",
            "metadata": {
                "BillToCustomer": {
                    "fieldname": "sold_to",
                    "overwrite": true
                },
                "InvoiceNumber": {
                    "fieldname": "order_number",
                    "overwrite": true
                },
                "OrderDate":{
                    "fieldname": "date",
                    "overwrite": true
                },
                "OrderPONumber": {
                    "fieldname": "customer_po_number",
                    "overwrite": true
                },
                "SerialNumbers": {
                    "fieldname": "serial_number",
                    "overwrite": true
                },
                "ShipToCustomer": {
                     "fieldname": "ship_to",
                     "overwrite": true
                },
                "description": {
                  "fieldname": "description",
                  "overwrite": true
                }
            }
        }
    ],

service.py

@app.route("/invoice-12-demo/<int:document_id>", methods=["GET", "POST"])
def trigger_invoice-12-demo(document_id):
    q.enqueue(process_custom, document_id, "invoice-12-demo")
    return "OK"

I think I might have led you on a wrong track here when I gave you the advice to mount the changed service.py file. I realised that I install the package without the -e flash when I’m building the container. Could you please try the following just to validate that I’m on the right track here. Please exec in your web container with your changed file mounted:

python -m pip install /app

If you can use your endpoint after that we can think about a more permanent solution.

Unfortunately the web container log does not show any documents being processed after following your above directions.

Could you please stop and start the container? Don’t use “compose down” though, just stop and start please :blush:

Just to double check. Do you want me to use this command?

docker compose restart mayan-mindee-web

Exactly :+1:

Just restart the container after the install of your changed files so that the changes should hopefully take effect :face_with_peeking_eye:

Restarted the container, then added a new document.

Nothing shows up in the log. :disappointed_relieved:

I just added a generic api endpoint:

/custom/<api_name>/int:document_id

Give it a few minutes to build than you can pull the new image and try that. I haven’t tested it though but I hope it should work :grimacing:

Should I disable my mount for service.py?

It should not really matter but you might as well disable it. Make sure that you use the charged url to trigger (you might want to try to use curl first)

Edit: hmm, the latest built was apparently too long ago… let me check…

Are you making this custom api, to match the api.json I provided above?

Because I redacted that for public display.

No it should be usable for any custom api which makes more sense anyway. So this was something on my list anyway.

The build is finished btw. You may pull the new image now.