Skip to content

Commit

Permalink
split notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
viktor-lt committed Dec 8, 2023
1 parent 5db7d81 commit bf5fecb
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 6,321 deletions.
77 changes: 0 additions & 77 deletions text-to-graph-custom-ontology/document_to_graph.ipynb
Original file line number Diff line number Diff line change
@@ -1,82 +1,5 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Send ontology file for importation"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import requests\n",
"\n",
"app_api_host = 'https://api.app.lettria.com'\n",
"file_name = 'ontology.owl'\n",
"file_location = './data/'\n",
"api_route = app_api_host + '/app/knowledge/import'\n",
"jwt_token_file = 'jwt_token.txt'\n",
"jwt_token = open(jwt_token_file, 'r').read()\n",
"knowlede_id = None\n",
"\n",
"with open(file_location + file_name, 'rb') as file:\n",
" response = requests.post(\n",
" api_route,\n",
" files=[('file', ( file_name, file, \"application/rdf+xml\"))],\n",
" headers={\"Authorization\":\"LettriaProKey \" + jwt_token}\n",
" )\n",
" print(response.json())\n",
" knowlede_id = response.json()['knowledgeId']"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Polling to wait for the end of the import"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"SUCCESS \r"
]
}
],
"source": [
"import time\n",
"import requests\n",
"\n",
"api_route = app_api_host + '/app/knowledge/read'\n",
"importation_is_finished = False\n",
"\n",
"knowledge = None\n",
"importation_status = None\n",
"while not importation_is_finished:\n",
" response = requests.post(\n",
" api_route,\n",
" headers={\"Authorization\":\"LettriaProKey \" + jwt_token}\n",
" ).json()\n",
" imported_knowledge = next((item for item in response['documents'] if item[\"_id\"] == knowlede_id), None)\n",
" importation_status = imported_knowledge.get('importationStatus')\n",
" print(importation_status + \" \", end='\\r')\n",
" importation_is_finished = importation_status != 'PROCESSING'\n",
" time.sleep(1)\n",
"if importation_status != 'SUCCESS':\n",
" print('Importation failed')\n",
" exit(1)"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
Loading

0 comments on commit bf5fecb

Please sign in to comment.