From bcdc3721efe7d3cb7960cb06e0093bb8ae3ec80f Mon Sep 17 00:00:00 2001
From: Patrick Jentsch
Date: Mon, 25 Sep 2023 13:28:48 +0200
Subject: [PATCH] Don't use container name as host for cqiclient
---
app/corpora/cqi_over_sio/__init__.py | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/app/corpora/cqi_over_sio/__init__.py b/app/corpora/cqi_over_sio/__init__.py
index 888bfaae..a5564d39 100644
--- a/app/corpora/cqi_over_sio/__init__.py
+++ b/app/corpora/cqi_over_sio/__init__.py
@@ -1,13 +1,14 @@
from cqi import CQiClient
from cqi.errors import CQiException
from cqi.status import CQiStatus
-from flask import session
+from docker.models.containers import Container
+from flask import current_app, session
from flask_login import current_user
from flask_socketio import Namespace
from inspect import signature
from threading import Lock
from typing import Callable, Dict, List, Optional
-from app import db, hashids, socketio
+from app import db, docker_client, hashids, socketio
from app.decorators import socketio_login_required
from app.models import Corpus, CorpusStatus
from . import extensions
@@ -121,7 +122,10 @@ class CQiNamespace(Namespace):
socketio.sleep(3)
retry_counter -= 1
db.session.refresh(db_corpus)
- cqi_client: CQiClient = CQiClient(f'cqpserver_{db_corpus_id}')
+ cqpserver_container_name: str = f'cqpserver_{db_corpus_id}'
+ cqpserver_container: Container = docker_client.containers.get(cqpserver_container_name)
+ cqpserver_host: str = cqpserver_container.attrs['NetworkSettings']['Networks'][current_app.config['NOPAQUE_DOCKER_NETWORK_NAME']]['IPAddress']
+ cqi_client: CQiClient = CQiClient(cqpserver_host)
session['cqi_over_sio'] = {
'cqi_client': cqi_client,
'cqi_client_lock': Lock(),