Skip to content

Commit

Permalink
WIP comparison service: operations
Browse files Browse the repository at this point in the history
  • Loading branch information
eboileau committed May 13, 2024
1 parent c33389f commit 4394d56
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 195 deletions.
2 changes: 1 addition & 1 deletion client/src/views/CompareView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const onExport = () => {
function load(operation) {
records.value = undefined
loading.value = true
HTTP.get('/compare', {
HTTP.get('/dataset/compare', {
params: {
reference: selectedDatasetA.value,
comparison: selectedDatasetB.value,
Expand Down
17 changes: 0 additions & 17 deletions server/src/scimodom/api/access.py

This file was deleted.

34 changes: 33 additions & 1 deletion server/src/scimodom/api/dataset.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from flask import Blueprint
from flask import Blueprint, request, jsonify
from flask_cors import cross_origin
from flask_jwt_extended import jwt_required, get_jwt_identity

from scimodom.services.comparison import get_comparison_service
from scimodom.services.dataset import get_dataset_service
from scimodom.services.user import get_user_service

Expand All @@ -21,3 +23,33 @@ def list_mine():
email = get_jwt_identity()
user = user_service.get_user_by_email(email)
return dataset_service.get_datasets(user)


@dataset_api.route("/compare", methods=["GET"])
@cross_origin(supports_credentials=True)
def compare():
"""Compare dataset (Compare View)."""
reference_ids = request.args.getlist("reference", type=str)
comparison_ids = request.args.getlist("comparison", type=str)
upload_path = request.args.get("upload", type=str)
query_operation = request.args.get("operation", type=str)
print(f"{reference_ids}, {comparison_ids}, {upload_path}, {query_operation}")

# TODO
operation, strand = query_operation.split("S")
comparison_service = get_comparison_service(operation, eval(strand))
if upload_path:
try:
comparison_service.upload_records(upload_path)
except: # FileNotFoundError, FailedUploadError, NoRecordsFoundError
pass
else:
try:
comparison_service.query_comparison_records(comparison_ids)
except: # NoRecordsFoundErrror - querying from FE this will not occur...
pass
comparison_service.query_reference_records(reference_ids)
# try:
return comparison_service.compare_dataset()
# except: # what errors pybedtools can rise here?
# return jsonify({"message": "Failed"}), 400
15 changes: 0 additions & 15 deletions server/src/scimodom/api/public.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from scimodom.services.dataset import get_dataset_service
from scimodom.services.public import get_public_service
from scimodom.services.comparison import get_comparison_service

api = Blueprint("api", __name__)

Expand Down Expand Up @@ -111,20 +110,6 @@ def get_search():
return response


@api.route("/compare", methods=["GET"])
@cross_origin(supports_credentials=True)
def get_compare():
"""Compare view API."""
reference_ids = request.args.getlist("reference", type=str)
comparison_ids = request.args.getlist("comparison", type=str)
upload_path = request.args.get("upload", type=str)
query_operation = request.args.get("operation", type=str)

# TODO
compare_service = get_comparison_service()
return "Not implemented", 404


@api.route("/upload", methods=["POST"])
@cross_origin(supports_credentials=True)
def upload_file():
Expand Down
16 changes: 0 additions & 16 deletions server/src/scimodom/api/upload.py

This file was deleted.

6 changes: 0 additions & 6 deletions server/src/scimodom/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
from scimodom.api.public import api
from scimodom.api.user import user_api
from scimodom.api.dataset import dataset_api
from scimodom.api.access import access_api
from scimodom.api.management import management_api
from scimodom.api.upload import upload_api
from scimodom.api.transfer import transfer_api
from scimodom.app_singleton import create_app_singleton
from scimodom.database.database import make_session, init
Expand All @@ -28,9 +26,7 @@
from scimodom.utils.url_routes import (
API_PREFIX,
USER_API_ROUTE,
ACCESS_API_ROUTE,
DATASET_API_ROUTE,
UPLOAD_API_ROUTE,
TRANSFER_API_ROUTE,
DATA_MANAGEMENT_API_ROUTE,
)
Expand All @@ -54,9 +50,7 @@ def create_app():

app.register_blueprint(api, url_prefix=f"/{API_PREFIX}")
app.register_blueprint(user_api, url_prefix=USER_API_ROUTE)
app.register_blueprint(access_api, url_prefix=ACCESS_API_ROUTE)
app.register_blueprint(dataset_api, url_prefix=DATASET_API_ROUTE)
app.register_blueprint(upload_api, url_prefix=UPLOAD_API_ROUTE)
app.register_blueprint(transfer_api, url_prefix=TRANSFER_API_ROUTE)
app.register_blueprint(management_api, url_prefix=DATA_MANAGEMENT_API_ROUTE)

Expand Down
Loading

0 comments on commit 4394d56

Please sign in to comment.