From a9d8c3e4bae62e209930ddb606780121801c9c47 Mon Sep 17 00:00:00 2001
From: daxid <david.rouquet@tetras-libre.fr>
Date: Tue, 2 May 2023 14:16:51 +0000
Subject: [PATCH] Add config.ini

---
 config.sample.ini       | 12 +++++++
 selfContainedDemo.ipynb | 72 ++++++++++++++---------------------------
 2 files changed, 37 insertions(+), 47 deletions(-)
 create mode 100644 config.sample.ini

diff --git a/config.sample.ini b/config.sample.ini
new file mode 100644
index 0000000..d5ad9d5
--- /dev/null
+++ b/config.sample.ini
@@ -0,0 +1,12 @@
+[LIB]
+AMR_BATCH_PATH = /opt/lib/TetrasMARS/amrbatch/
+TENET_PATH = /opt/lib/TetrasMARS/tenet/
+AMRLD_PATH = /opt/lib/TetrasMARS/amrld/
+owl2vowlPath = /opt/lib/owl2vowl_0.3.7/owl2vowl.jar
+WEBVOWL_PATH = /opt/webvowl/
+AMR_MODEL_PATH = /opt/lib/TetrasMARS/corpus/cm-tool/amrModel/model_parse_xfm_bart_large-v0_1_0
+
+[CONF]
+BASE_URL = https://mars.tetras-lab.io
+DASHBOARD_NUM = 1
+onto_prefix = ontologyTarget
diff --git a/selfContainedDemo.ipynb b/selfContainedDemo.ipynb
index 735204d..8d6cc10 100644
--- a/selfContainedDemo.ipynb
+++ b/selfContainedDemo.ipynb
@@ -2,7 +2,7 @@
  "cells": [
   {
    "cell_type": "code",
-   "execution_count": 1,
+   "execution_count": null,
    "id": "0d91640d-23ea-4079-b765-2eea030926c5",
    "metadata": {},
    "outputs": [],
@@ -30,25 +30,33 @@
     "from dash.dependencies import Input, Output, State\n",
     "import base64\n",
     "import xml.etree.ElementTree as ET\n",
+    "import configparser\n",
     "\n",
-    "AMR_BATCH_PATH = \"/opt/lib/TetrasMARS/amrbatch/\"\n",
+    "config = configparser.ConfigParser()\n",
+    "config.read('config.ini')\n",
+    "#config['LIB']['']\n",
+    "\n",
+    "AMR_BATCH_PATH = config['LIB']['AMR_BATCH_PATH']\n",
     "sys.path.insert(0, os.path.abspath(AMR_BATCH_PATH))\n",
     "import amrbatch\n",
     "\n",
-    "TENET_PATH = \"/opt/lib/TetrasMARS/tenet/\"\n",
+    "TENET_PATH = config['LIB']['TENET_PATH']\n",
     "sys.path.insert(0, os.path.abspath(TENET_PATH))\n",
     "import tenet\n",
     "\n",
     "BASE_URL = 'https://mars.tetras-lab.io'\n",
-    "AMR_MODEL_PATH=\"/opt/lib/TetrasMARS/corpus/cm-tool/amrModel/model_parse_xfm_bart_large-v0_1_0\"\n",
-    "MEDIA_PATH = \"/opt/dashboards/media/17/\"\n",
-    "MEDIA_URL = BASE_URL+\"/dashboard/17/media/\"\n",
-    "ROOT_PATH = \"/opt/dashboards/TetrasMARS/tetras-mars-demo-prod/\"\n",
-    "AMRLD_PATH = \"/opt/lib/TetrasMARS/amrld/\"\n",
-    "owl2vowlPath = '/opt/dashboards/tools/owl2vowl_0.3.7/owl2vowl.jar'\n",
-    "WEBVOWL_PATH = '/opt/webvowl/'\n",
+    "DASHBOARD_NUM = '1'\n",
     "onto_prefix=\"ontologyTarget\"\n",
     "\n",
+    "AMR_MODEL_PATH = config['LIB']['AMR_MODEL_PATH']\n",
+    "AMRLD_PATH = config['LIB']['AMRLD_PATH']\n",
+    "owl2vowlPath = config['LIB']['owl2vowlPath']\n",
+    "WEBVOWL_PATH = config['LIB']['WEBVOWL_PATH']\n",
+    "\n",
+    "MEDIA_PATH = \"/opt/dashboards/media/\"+DASHBOARD_NUM+\"/\"\n",
+    "MEDIA_URL = BASE_URL+\"/dashboard/\"+DASHBOARD_NUM+\"/media/\"\n",
+    "\n",
+    "\n",
     "# The following is basically `import tenet`\n",
     "#spec=importlib.util.spec_from_file_location(\"tenet\",TENET_PATH+'tenet/__init__.py')\n",
     "#tenet = importlib.util.module_from_spec(spec)\n",
@@ -57,7 +65,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 2,
+   "execution_count": null,
    "id": "295e4aef-bbd8-40f0-8d84-0b8032b7b039",
    "metadata": {},
    "outputs": [],
@@ -74,7 +82,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 3,
+   "execution_count": null,
    "id": "a410a6b3-865d-441f-9b83-90a1badae291",
    "metadata": {},
    "outputs": [],
@@ -131,7 +139,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 4,
+   "execution_count": null,
    "id": "5fd9cf0c-990a-4776-b206-8cc94f87c7be",
    "metadata": {},
    "outputs": [],
@@ -175,42 +183,12 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 5,
+   "execution_count": null,
    "id": "0cd10e8b-cf7a-4fd4-b8ac-540fcb943325",
    "metadata": {
     "tags": []
    },
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "Dash is running on https://mars.tetras-lab.io:443/jupyter/app_proxy/8050/\n",
-      "\n"
-     ]
-    },
-    {
-     "data": {
-      "text/html": [
-       "\n",
-       "        <iframe\n",
-       "            width=\"100%\"\n",
-       "            height=\"2000\"\n",
-       "            src=\"https://mars.tetras-lab.io:443/jupyter/app_proxy/8050/jupyter/app_proxy/8050/\"\n",
-       "            frameborder=\"0\"\n",
-       "            allowfullscreen\n",
-       "            \n",
-       "        ></iframe>\n",
-       "        "
-      ],
-      "text/plain": [
-       "<IPython.lib.display.IFrame at 0x7f3acf0ae850>"
-      ]
-     },
-     "metadata": {},
-     "output_type": "display_data"
-    }
-   ],
+   "outputs": [],
    "source": [
     "##################################################################################################\n",
     "# THE FOLLOWING PART IS SPECIFIC TO TÉTRAS LAB\n",
@@ -271,13 +249,13 @@
     "app.layout = html.Div([\n",
     "    html.H4(\"Enter an english text and click on the button bellow to construct an ontology.\", style={'text-align': 'center'}),\n",
     "    html.Br(),\n",
-    "    html.P(\"It should take about 10 sec/sentence. You can then browse the results online or download them as a zip file.\", style={'text-align': 'center'}),\n",
+    "    html.P(\"It should take about 10 to 30 sec/sentence. You can then browse the results online or download them as a zip file.\", style={'text-align': 'center'}),\n",
     "    html.P(\"The text must be a simple succession of sentences. Fancy formating is not supported at the moment. \", style={'text-align': 'center'}),    \n",
     "    html.Br(),\n",
     "    html.Br(),\n",
     "    html.Div(dbc.Textarea(\n",
     "        id='textarea-state',\n",
-    "        value='Jupiter is a gas giant. Earth is a rock planet.',style={'width': '100%', 'height': 130}),\n",
+    "        value='The Solar System is the gravitationally bound system of the Sun. The inner system planets are terrestrial planets composed of rock and metal. The outer system planets are giant planets. The two largest planets, Jupiter and Saturn, are gas giants, being composed of hydrogen and helium.',style={'width': '100%', 'height': 130}),\n",
     "        style={'width': '60%', 'height': 130, 'margin-left': 'auto', 'margin-right': 'auto'},\n",
     "    ),\n",
     "    html.Br(), html.Br(),\n",
-- 
GitLab