aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMunyoki Kilyungi2022-11-23 12:14:38 +0300
committerBonfaceKilz2022-11-23 12:51:51 +0300
commit0886baf8971c48a13c78c3c6397f486898ff4700 (patch)
treef0ba79a989595cf89eb0dadbeb8b3006764df967
parent79dc777ccb0811aee6f804c1188f3a0dbd6b9388 (diff)
downloadgenenetwork2-0886baf8971c48a13c78c3c6397f486898ff4700.tar.gz
Replace GN3 library rdf queries with a call to a gn3 endpoint
* wqflask/wqflask/database.py: Delete SPARQLWrapper, JSON imports (sparql_connection): Delete. * wqflask/wqflask/views.py: Import requests and urljoin. Delete get_dataset_metadata and sparql_connection import. (show_trait_page): Fetch metadata by calling a GN enpoint.
-rw-r--r--wqflask/wqflask/database.py8
-rw-r--r--wqflask/wqflask/views.py17
2 files changed, 9 insertions, 16 deletions
diff --git a/wqflask/wqflask/database.py b/wqflask/wqflask/database.py
index d2929488..663e2ebf 100644
--- a/wqflask/wqflask/database.py
+++ b/wqflask/wqflask/database.py
@@ -1,7 +1,6 @@
# Module to initialize sqlalchemy with flask
import os
import sys
-from SPARQLWrapper import JSON, SPARQLWrapper
from typing import Tuple, Protocol, Any, Iterator
from urllib.parse import urlparse
import importlib
@@ -61,10 +60,3 @@ def database_connection() -> Iterator[Connection]:
yield connection
finally:
connection.close()
-
-
-def sparql_connection():
- """Create a sparql objection that is used to query RDF"""
- return SPARQLWrapper(
- get_setting("SPARQL_ENDPOINT")
- )
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index 1b34e2f8..91a04c62 100644
--- a/wqflask/wqflask/views.py
+++ b/wqflask/wqflask/views.py
@@ -11,6 +11,7 @@ import numpy as np
import os
import pickle as pickle
import random
+import requests
import sys
import traceback
import uuid
@@ -21,6 +22,8 @@ from zipfile import ZIP_DEFLATED
from uuid import UUID
+from urllib.parse import urljoin
+
from wqflask import app
from gn3.computations.gemma import generate_hash_of_string
@@ -76,6 +79,7 @@ from utility.tools import TEMPDIR
from utility.tools import USE_REDIS
from utility.tools import REDIS_URL
from utility.tools import GN_SERVER_URL
+from utility.tools import GN3_LOCAL_URL
from utility.tools import GN_VERSION
from utility.tools import JS_TWITTER_POST_FETCHER_PATH
from utility.tools import JS_GUIX_PATH
@@ -83,14 +87,11 @@ from utility.helper_functions import get_species_groups
from utility.redis_tools import get_redis_conn
import utility.hmac as hmac
-from gn3.db.rdf import get_dataset_metadata
-
from base.webqtlConfig import TMPDIR
from base.webqtlConfig import GENERATED_IMAGE_DIR
from wqflask.database import database_connection
-from wqflask.database import sparql_connection
import jobs.jobs as jobs
@@ -492,13 +493,13 @@ def show_trait_page():
metadata = (
template_vars.dataset.accession_id
.bind(
- lambda idx: get_dataset_metadata(
- sparql_connection(),
- f"GN{idx}"
+ lambda idx: requests.get(
+ urljoin(
+ GN3_LOCAL_URL,
+ f"/api/metadata/dataset/GN{idx}")
)
)
- ).data
-
+ ).json()
return render_template("show_trait.html",
metadata=metadata, **template_vars.__dict__)