Skip to content

Commit

Permalink
fix: restablish mongo repository declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
celian-garcia authored Oct 2, 2022
1 parent 66bd8f1 commit c51acb2
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions cerebro/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,19 @@ def _to_uppercase(self, obj: Dict[str, Any]) -> Dict[str, Any]:
return retval


def build_repository(**params) -> Repository:
if params["use_mongo"]:
return NLPRepositoryMongo(
url=params["mongo_url"],
database=params["mongo_database"]
)
else:
return NLPRepositoryFake()


logger = logging.getLogger()

# Initialize the sanic app
config = YamlConfig(path="cerebro.yaml")
app = Sanic(name="cerebro", config=config)

# repository = build_repository(**params)
repository = NLPRepositoryFake()
if config["CEREBRO"]["FEATURES"]["USE_MONGO"]:
repository = NLPRepositoryMongo(
url=["CEREBRO"]["MONGODB"]["URL"],
database=["CEREBRO"]["MONGODB"]["DATABASE"]
)
else:
repository = NLPRepositoryFake()

app.add_route(HtmlView.as_view(), '/')
app.add_route(SamplesView.as_view(repository), '/models/<model_id:str>/samples')
Expand Down

0 comments on commit c51acb2

Please sign in to comment.