Skip to content

Commit

Permalink
Merge pull request #30 from gyorilab/fix-cors
Browse files Browse the repository at this point in the history
Fix cors, docker build and requirements
  • Loading branch information
kkaris authored Apr 5, 2024
2 parents 248239c + decf225 commit fcc2bf6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
3 changes: 1 addition & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:latest
FROM ubuntu:20.04

ENV DIRPATH /sw
WORKDIR $DIRPATH
Expand All @@ -20,7 +20,6 @@ RUN git clone https://github.com/indralab/indra_network_search.git && \
python -m indra.ontology.bio build

ADD indranet_dir_graph.pkl $NETWORK_CACHE
ADD indranet_sign_edge_graph.pkl $NETWORK_CACHE
ADD indranet_sign_node_graph.pkl $NETWORK_CACHE

ENV PYTHONPATH /sw/depmap_analysis:/sw/indra_network_search
Expand Down
11 changes: 5 additions & 6 deletions indra_network_search/data_models/rest_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

__all__ = ["Health", "ServerStatus"]


STR_STATUS = Literal["booting", "available"]


Expand All @@ -26,9 +25,9 @@ class Health(BaseModel):
class ServerStatus(BaseModel):
"""Status with more detail than health"""

unsigned_nodes: Optional[int] = Field(None, description="Number of " "unsigned nodes " "in the graph")
signed_nodes: Optional[int] = Field(None, description="Number of signed " "nodes in the graph")
unsigned_edges: Optional[int] = Field(None, description="Number of " "unsigned edges " "in the graph")
signed_edges: Optional[int] = Field(None, description="Number of signed " "edges in the graph")
graph_date: Optional[date] = Field(None, description="Date of the " "graph creation from the database")
unsigned_nodes: Optional[int] = Field(None, description="Number of unsigned nodes in the graph")
signed_nodes: Optional[int] = Field(None, description="Number of signed nodes in the graph")
unsigned_edges: Optional[int] = Field(None, description="Number of unsigned edges in the graph")
signed_edges: Optional[int] = Field(None, description="Number of signed edges in the graph")
graph_date: Optional[date] = Field(None, description="Date of the graph creation from the database")
status: STR_STATUS = Field(..., description="Status of the server")
10 changes: 10 additions & 0 deletions indra_network_search/rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from fastapi import Query as RestQuery
from indra.databases import get_identifiers_url
from pydantic import ValidationError
from fastapi.middleware.cors import CORSMiddleware
from tqdm import tqdm

from indra_network_search.autocomplete import NodesTrie, Prefixes
Expand Down Expand Up @@ -44,6 +45,15 @@
version=VERSION,
)

# Add cors middleware for https://discovery.indra.bio
app.add_middleware(
CORSMiddleware,
allow_origins=["https://discovery.indra.bio"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)

DEBUG = environ.get("API_DEBUG") == "1"
USE_CACHE = environ.get("USE_CACHE") == "1"
HEALTH = Health(status="booting")
Expand Down
6 changes: 3 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description = INDRA Network Search
long_description = file: README.md
long_description_content_type = text/markdown
author = Klas Karis
author_email = [email protected].edu
author_email = k.karis@northeastern.edu
url = https://github.com/indralab/indra_network_search
download_url = https://github.com/indralab/indra_network_search/releases
license_file = LICENSE
Expand All @@ -25,8 +25,8 @@ classifiers =
install_requires =
indra @ git+https://github.com/sorgerlab/indra.git
indra_db @ git+https://github.com/indralab/indra_db.git
pydantic
fastapi
fastapi<0.100.0
pydantic!=1.8,!=1.8.1,<2.0.0,>=1.7.4
networkx
boto3
requests
Expand Down

0 comments on commit fcc2bf6

Please sign in to comment.