-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from LuCEresearchlab/push-new-dataset-better-h…
…andling Push new dataset better handling
- Loading branch information
Showing
23 changed files
with
302 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
FLASK_APP=flaskr | ||
FLASK_ENV=development | ||
NR_WORKERS=2 | ||
NR_THREADS=5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM node:15.12-alpine3.10 | ||
FROM node:15.14.0-alpine3.10 | ||
|
||
EXPOSE 8080 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
test | ||
cache | ||
*.iml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from flask import request | ||
from flask_restx import Namespace, Resource, fields | ||
from flaskr.endpoints.upload_api import ANSWER | ||
from flaskr import cache | ||
from flaskr.util.mongo_helper import get_cluster, save_cluster | ||
|
||
api = Namespace('clusters', description='API to view available datasets') | ||
|
||
|
||
CLUSTERED_ANSWERS = api.model('Clustered Answers', { | ||
'dataset_id': fields.String(required=True, readonly=True, description='ID of the dataset', | ||
example='603501f39175ac3898e094cc'), | ||
'question_id': fields.String(required=True, readonly=True, description='ID of the question', | ||
example='6035089963cf6ef09a9c418e'), | ||
'clusters': fields.List(fields.List(fields.Nested(ANSWER))) | ||
}) | ||
|
||
|
||
@api.route('/dataset/<string:dataset_id>/question/<string:question_id>/user/<string:user_id>') | ||
@api.doc(description='API to get clusters for current user', | ||
params={ | ||
'dataset_id': 'ID of the dataset', | ||
'user_id': 'ID of the user' | ||
}) | ||
class Clusters(Resource): | ||
@api.marshal_list_with(CLUSTERED_ANSWERS) | ||
@cache.memoize() | ||
def get(self, dataset_id, question_id, user_id): | ||
return get_cluster(dataset_id=dataset_id, question_id=question_id, user_id=user_id)[0] | ||
|
||
@api.expect(CLUSTERED_ANSWERS) | ||
def post(self, dataset_id, question_id, user_id): | ||
data = request.get_json() | ||
save_cluster(dataset_id=dataset_id, question_id=question_id, user_id=user_id, | ||
cluster=data) | ||
cache.delete_memoized(Clusters.get, dataset_id, question_id, user_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.