You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"""Add a new dataset to a project and import data.
73
+
Parameter values are validated by DataService.
73
74
74
75
NOTE: Permissions are not handled here. The
75
76
SMID in the dataset form is coming from
76
77
one of the "allowed" projects for this user, i.e.
77
78
the user is only able to select from his own projects.
78
79
"""
79
80
dataset_form=request.json
80
-
session=get_session()
81
81
try:
82
82
data_service=DataService.from_new(
83
-
session,
83
+
get_session(),
84
84
dataset_form["smid"],
85
85
dataset_form["title"],
86
86
dataset_form["path"],
@@ -89,53 +89,36 @@ def add_dataset():
89
89
technology_id=dataset_form["technology_id"],
90
90
organism_id=dataset_form["organism_id"],
91
91
)
92
+
exceptSelectionExistsError:
93
+
return {
94
+
"message": "Invalid combination of RNA type, modification, organism, and/or technology. Modify the form and try again."
95
+
}, 422
92
96
exceptInstantiationErrorasexc:
93
-
# no need to log these errors, users should normally handle them
94
-
# ValueError during instantiation should not happen as we are using pre-defined values (Dropdown, MultiSelect, CascadeSelect)
95
-
# unless database corruption...
96
-
return (
97
-
jsonify(
98
-
{
99
-
"message": f'Failed to upload dataset. Verify the input value for SMID or select a project using the button. The selected combination of modification, organism, and technology may be invalid for this project. Modify the form and try again. The message received from the server was: "{exc}"'
100
-
}
101
-
),
102
-
500,
103
-
)
97
+
logger.error(f"{exc}. The request was: {dataset_form}.")
98
+
return {
99
+
"message": "Invalid selection. Try again or contact the administrator."
100
+
}, 422
104
101
exceptExceptionasexc:
105
-
# all others
106
-
logger.error(
107
-
f"Failed to instantiate dataservice: {exc}. The form received was: {dataset_form}."
108
-
)
109
-
return (
110
-
jsonify(
111
-
{"message": "Failed to upload dataset. Contact the administrator."}
112
-
),
113
-
500,
114
-
)
102
+
logger.error(f"{exc}. The request was: {dataset_form}.")
103
+
return {"message": "Failed to create dataset. Contact the administrator."}, 500
115
104
116
105
try:
117
106
data_service.create_dataset()
118
-
# TODO: feedback to user e.g. liftover, etc. and finally successful upload (return EUFID?)
119
-
exceptDatasetErrorasexc:
120
-
# no need to log these errors, users should normally handle them
121
-
return (
122
-
jsonify(
123
-
{
124
-
"message": f'Failed to upload dataset. The message received from the server was: "{exc}". If you are unsure about what happened, click "Cancel" and contact the administrator.'
125
-
}
126
-
),
127
-
500,
128
-
)
129
-
exceptDatasetHeaderErrorasexc:
130
-
# no need to log these errors, users should normally handle them
131
-
return (
132
-
jsonify(
133
-
{
134
-
"message": f'Failed to upload dataset. Your bedRMod file header does not match the values you entered. Modify the form or the file header and try again. The message received from the server was: "{exc}". If you are unsure about what happened, click "Cancel" and contact the administrator.'
135
-
}
136
-
),
137
-
500,
138
-
)
107
+
exceptDatasetHeaderError:
108
+
return {
109
+
"message": 'File upload failed. The file header does not match the value you entered for organism and/or assembly. Click "Cancel". Modify the form or the file header and start again.'
110
+
}, 422
111
+
exceptDatasetExistsErrorasexc:
112
+
return {
113
+
"message": f"File upload failed. {str(exc).replace('Aborting transaction!', '')} If you are unsure about what happened, click \"Cancel\" and contact the administrator."
114
+
}, 422
115
+
exceptEOFErrorasexc:
116
+
return {"message": f"File upload failed. File {str(exc)} is empty!"}, 500
117
+
exceptSpecsErrorasexc:
118
+
return {
119
+
"message": f"File upload failed. File is not conform to bedRMod specifications: {str(exc)}"
0 commit comments