Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ numpy==1.26.1
pandas==1.3.3
pyflapjack @ git+https://github.com/flapjacksynbio/pyFlapjack@xdc_features2
excel2flapjack==1.0.11
tricahue==0.0b6
# tricahue @ git+https://github.com/MyersResearchGroup/Tricahue/@dev
# tricahue==0.0b6
tricahue @ git+https://github.com/MyersResearchGroup/Tricahue/@dev
sbol2build
flask_swagger_ui
xlsxwriter
Expand Down
35 changes: 14 additions & 21 deletions backend/sbs_server/app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import os
import json
import xml.etree.ElementTree as ET

import tricahue
import sbol2 as sb2
import pudu
Expand Down Expand Up @@ -39,9 +38,7 @@ def upload_experiment():
Helper function to upload to SynBioHub and Flapjack using XDC/XDE
'''
def sbh_fj_upload(files):

if 'Metadata' not in files:
print(request)
return 'No file part', 400
metadata_file = files['Metadata']
if metadata_file.filename == '':
Expand All @@ -65,6 +62,10 @@ def sbh_fj_upload(files):
if params_file.filename == '':
return 'No selected Params file', 400
params_from_request = json.loads(params_file.read())
sbh_url = params_from_request.get('sbh_url')
if sbh_url and not (sbh_url.startswith('http://') or sbh_url.startswith('https://')):
params_from_request['sbh_url'] = 'https://' + sbh_url

required_params = ['sbh_url', 'sbh_token', 'sbh_user', 'sbh_pass',
'fj_url', 'fj_token', 'fj_user', 'fj_pass',
'sbh_collec', 'sbh_collec_desc',
Expand All @@ -78,26 +79,18 @@ def sbh_fj_upload(files):
return 'No SBH credentials provided', 400

# Attachment files to upload to SBH
attachments = None
if 'Attachments' in files:
if 'Attachments' in files and 'attachments' in params_from_request:
attachment_files = files.getlist("Attachments")
attachment_metadata = params_from_request.get('attachments')

if attachment_metadata is None:
return 'Attachment metadata not provided', 400
if not isinstance(attachment_metadata, dict):
return 'Attachment metadata must be a JSON object keyed by filename', 400

attachments = {}
missing_metadata = [file.filename for file in attachment_files if file.filename not in attachment_metadata]
if missing_metadata:
missing_list = ', '.join(missing_metadata)
return f'Missing attachment metadata for files: {missing_list}', 400

for file in attachment_files:
attachments[attachment_metadata[file.filename]] = file

print(attachments)
if file.filename not in params_from_request['attachments']:
return (
f"Attachment metadata for file '{file.filename}' not found in request",
400,
)
attachments[params_from_request['attachments'][file.filename]] = file
else:
attachments = None

# instantiate the XDC class using the params_from_request dictionary
xdc = tricahue.XDC(input_excel_path = files['Metadata'],
Expand All @@ -113,8 +106,8 @@ def sbh_fj_upload(files):
fj_overwrite = params_from_request['fj_overwrite'],
fj_token = params_from_request['fj_token'],
sbh_token = params_from_request['sbh_token'],
attachments = attachments,
homespace = "https://example.org/",
attachments = attachments
)

try:
Expand Down
18 changes: 12 additions & 6 deletions backend/sbs_server/files/sbs_params.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
{
"attachments": {"ExpNOTs_GFP_trans.xlsx": "LB", "example.jpg": "ExampleMedia"},
"fj_overwrite": 1,
"fj_pass": null,
"fj_token": null,
"fj_url": "charmmefj-api.synbiohub.org",
"fj_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImV4cCI6MTc1Mzk4MDI2NywianRpIjoiNTg5MTFmM2IxZTlhNGZlN2FjOTA2YzI2NmIwYzJmMjUiLCJ1c2VyX2lkIjoyfQ.hYVb65i4XinKOMsRgCG2EHrvFcYDx4vvzWg_wImDsDA",
"fj_user": null,
"sbh_collec": "sbs_backend_test",
"sbh_collec_desc": "Uploaded via SBS_server using XDC to SBH",
"sbh_overwrite": 1,
"sbh_pass": null,
"sbh_token": "REPLACE_WITH_SYN_BIO_HUB_TOKEN",
"sbh_url": "https://synbiohub.org",
"sbh_token": "37ae0d50-ba67-4f66-bb06-79619d8ba7d3",
"sbh_collec": "xdc_sbs_test_uploader_file",
"sbh_collec_desc": "xdc_sbs_test_uploader_file_description",
"fj_overwrite": false,
"sbh_overwrite": false
"sbh_user": null,
"version": ""
}
7 changes: 3 additions & 4 deletions frontend/src/API.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export async function upload_resource(
sbh_collec,
sbh_collec_desc,
workingDirectory = null,
sbh_overwrite = false
sbh_overwrite = 0
) {
try {
let data = new FormData();
Expand All @@ -57,15 +57,15 @@ export async function upload_resource(
const paramsObj = {
sbh_url: sbh_url,
sbh_token: sbh_token,
fj_url: "charmmefj-api.synbiohub.org",
sbh_user: null,
sbh_pass: null,
fj_url: "charmmefj-api.synbiohub.org",
fj_token: null,
fj_user: null,
fj_pass: null,
sbh_collec: sbh_collec,
sbh_collec_desc: sbh_collec_desc,
sbh_overwrite: sbh_overwrite ? 2 : 0,
sbh_overwrite: sbh_overwrite,
fj_overwrite: 1,
version: "",
attachments: {}
Expand All @@ -88,7 +88,6 @@ export async function upload_resource(
return response.data;
} catch (error) {
console.error("Upload Resource error:", error);
showErrorNotification('Error', error.message);
throw error;
}
}
Expand Down
Loading