diff --git a/setup.cfg b/setup.cfg index ff159331d..3a4e40169 100644 --- a/setup.cfg +++ b/setup.cfg @@ -74,6 +74,7 @@ web = docstring-parser indralab_auth_tools @ git+https://github.com/indralab/ui_util.git#egg=indralab_auth_tools&subdirectory=indralab_auth_tools pusher + markupsafe<2.1.0 gunicorn = gunicorn gsea = diff --git a/src/indra_cogex/apps/chat_page/app/deploy.sh b/src/indra_cogex/apps/chat_page/app/deploy.sh index 7fef45bc7..a77296697 100755 --- a/src/indra_cogex/apps/chat_page/app/deploy.sh +++ b/src/indra_cogex/apps/chat_page/app/deploy.sh @@ -61,7 +61,7 @@ echo "Deploying to $S3_URI" # Copy the content of the dist directory to the S3 bucket # See https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3/sync.html for more details -aws s3 sync --exact-timestamps --delete dist/ "${S3_URI}" +aws s3 sync --exact-timestamps --delete dist/ "${S3_URI}" --acl public-read echo "Deployment complete" echo "" diff --git a/src/indra_cogex/apps/chat_page/app/src/components/AgentModal.vue b/src/indra_cogex/apps/chat_page/app/src/components/AgentModal.vue index cce212117..241108de8 100644 --- a/src/indra_cogex/apps/chat_page/app/src/components/AgentModal.vue +++ b/src/indra_cogex/apps/chat_page/app/src/components/AgentModal.vue @@ -216,8 +216,8 @@ export default { } if (Object.entries(this.lookupData).length === 0) { - // Call biolookup.io, e.g. http://biolookup.io/api/lookup/DOID:14330 - const bioluUrl = `http://biolookup.io/api/lookup/${topNsUpper}:${this.topGrounding[1]}`; // Currently only supports http + // Call the biolookup.io wrapper, e.g. https://discovery.indra.bio/biolookup/DOID:14330 + const bioluUrl = `https://discovery.indra.bio/biolookup/${topNsUpper}:${this.topGrounding[1]}`; const bioluResp = await fetch(bioluUrl); const bioluData = await bioluResp.json(); this.lookupData = await bioluData; diff --git a/src/indra_cogex/apps/chat_page/app/src/components/StmtList.vue b/src/indra_cogex/apps/chat_page/app/src/components/StmtList.vue index ab4546748..c918cbc7f 100644 --- a/src/indra_cogex/apps/chat_page/app/src/components/StmtList.vue +++ b/src/indra_cogex/apps/chat_page/app/src/components/StmtList.vue @@ -96,20 +96,22 @@ export default { for (let source of Object.keys(metaEntry.sourceCounts)) { // If the source is a reader, add it to the readers array const lowerSource = source.toLowerCase(); + const mappedLowerSource = + this.$source_mapping[lowerSource] ?? lowerSource; if ( - this.$sources.readers.includes(lowerSource) && - !availableSources.readers.includes(lowerSource) + this.$sources.readers.includes(mappedLowerSource) && + !availableSources.readers.includes(mappedLowerSource) ) { - availableSources.readers.push(lowerSource); + availableSources.readers.push(mappedLowerSource); } else if ( - this.$sources.databases.includes(lowerSource) && - !availableSources.databases.includes(lowerSource) + this.$sources.databases.includes(mappedLowerSource) && + !availableSources.databases.includes(mappedLowerSource) ) { - availableSources.databases.push(lowerSource); + availableSources.databases.push(mappedLowerSource); } else if ( - !this.$sources.databases.includes(lowerSource) && - !this.$sources.readers.includes(lowerSource) + !this.$sources.databases.includes(mappedLowerSource) && + !this.$sources.readers.includes(mappedLowerSource) ) { console.warn(`Unknown source: ${source}`); } @@ -189,7 +191,7 @@ export default { return `${firstAgent.name} ${verb} ${restOfAgentsString}`; }, async getEnglishArray() { - const indraApi = "http://api.indra.bio:8000/assemblers/english"; + const indraApi = "https://discovery.indra.bio/get_english_stmts"; // POST to get the English assembly of the statements const response = await fetch(indraApi, { method: "POST", diff --git a/src/indra_cogex/apps/chat_page/app/src/main.js b/src/indra_cogex/apps/chat_page/app/src/main.js index 93f647cb5..5d9168e08 100644 --- a/src/indra_cogex/apps/chat_page/app/src/main.js +++ b/src/indra_cogex/apps/chat_page/app/src/main.js @@ -62,6 +62,13 @@ app.config.globalProperties.$sources = { "acsn", ], }; +app.config.globalProperties.$source_mapping = { + bel: "bel_lc", + phosphoelm: "pe", + biopax: "pc", + virhostnet: "vhn", + phosphosite: "psp", +}; const GStore = reactive({ xrefs: {}, diff --git a/src/indra_cogex/apps/data_display/__init__.py b/src/indra_cogex/apps/data_display/__init__.py index da19ddb4b..5b7a3c4e9 100644 --- a/src/indra_cogex/apps/data_display/__init__.py +++ b/src/indra_cogex/apps/data_display/__init__.py @@ -12,10 +12,13 @@ from http import HTTPStatus from typing import Any, Dict, Iterable, List, Optional, Set +import requests from flask import Blueprint, Response, abort, jsonify, render_template, request from flask_jwt_extended import jwt_optional + +from indra.assemblers.english import EnglishAssembler from indra.sources.indra_db_rest import IndraDBRestAPIError -from indra.statements import Statement +from indra.statements import Statement, stmts_from_json from indralab_auth_tools.auth import resolve_auth from indra_cogex.apps.proxies import client, curation_cache @@ -173,6 +176,51 @@ def get_stmts(): abort(Response("Parameter 'stmt_hash' unfilled", status=415)) +@data_display_blueprint.route("/get_english_stmts", methods=["POST"]) +def get_english_stmts(): + """Get English statements from a list of INDRA statements in JSON format + + This does the same thing as http://api.indra.bio:8000/assemble/english, + we do it here to avoid CORS issues and blocking by the browser + when calling http from a https page + """ + stmts_json = request.json.get("statements") + if isinstance(stmts_json, dict): + stmts_json = [stmts_json] + if not stmts_json or not isinstance(stmts_json, list): + logger.warning("No statements provided to generate English statements") + abort(HTTPStatus.UNPROCESSABLE_ENTITY, + "No statements provided, cannot generate English statements from empty list") + stmts = stmts_from_json(stmts_json) + english = {} + for stmt in stmts: + english[stmt.uuid] = EnglishAssembler([stmt]).make_model() + return jsonify({"sentences": english}) + + +@data_display_blueprint.route("/biolookup/", methods=["GET"]) +def biolookup(curie): + """A simple wrapper to biolookup that returns the results as JSON + + We use this wrapper to avoid browser blocking when calling the biolookup + service (that's running on http) from a https page. + + Parameters + ---------- + curie : + The CURIE to look up + + Returns + ------- + : + The JSON response from biolookup + """ + res = requests.get("http://biolookup.io/api/lookup/%s" % curie) + if res.status_code != 200: + abort(res.status_code, res.text) + return jsonify(res.json()) + + # Endpoint for getting evidence @data_display_blueprint.route("/expand/", methods=["GET"]) @jwt_optional