CAUTION if there are things that depend / stored on both sequence and instance will also need to updated here over time ie if we add something else that is unique to each sequence but stored on instance (like the "Number"). Assumes sequence is valid if file id matches. Assu
(
session,
project,
file_id: int,
sequence_id: int,
mode: str,
payload)
| 255 | |
| 256 | |
| 257 | def update_sequence_shared( |
| 258 | session, |
| 259 | project, |
| 260 | file_id: int, |
| 261 | sequence_id: int, |
| 262 | mode: str, |
| 263 | payload): |
| 264 | """ |
| 265 | CAUTION if there are things that depend / stored |
| 266 | on both sequence and instance will also need to updated here over time |
| 267 | ie if we add something else that is unique to each sequence |
| 268 | but stored on instance (like the "Number"). |
| 269 | |
| 270 | Assumes sequence is valid if file id matches. |
| 271 | Assumes label file is valid if it matches project. |
| 272 | |
| 273 | verifying label file |
| 274 | alternatively look at implmentation in annotation.py |
| 275 | ie get_allowed_label_file_ids() |
| 276 | |
| 277 | This is pretty "basic" right now... maybe other stuff |
| 278 | to think about in terms of what to update... |
| 279 | |
| 280 | The number could conflict... Need to update number to highest |
| 281 | could also just set it to big number... |
| 282 | """ |
| 283 | |
| 284 | if file_id is None or sequence_id is None or payload is None: |
| 285 | return "a required argument is none", 400, {'ContentType': 'application/json'} |
| 286 | |
| 287 | log = regular_log.default() |
| 288 | |
| 289 | sequence = session.query(Sequence).filter( |
| 290 | Sequence.video_file_id == file_id, |
| 291 | Sequence.id == sequence_id).first() |
| 292 | |
| 293 | if sequence is None: |
| 294 | return jsonify("Not found"), 400 |
| 295 | |
| 296 | if mode == "update_label": |
| 297 | |
| 298 | if sequence.label_file_id == payload.get('id'): |
| 299 | log['error']['label_file_id'] = "Same label selected, nothing to change." |
| 300 | return jsonify(log = log), 400 |
| 301 | |
| 302 | label_file = File.get_by_id_and_project( |
| 303 | project_id = project.id, |
| 304 | session = session, |
| 305 | file_id = payload.get('id') |
| 306 | ) |
| 307 | |
| 308 | if label_file is None: |
| 309 | return jsonify("Not found"), 400 |
| 310 | |
| 311 | highest_sequence_in_new_context = Sequence.get_by_highest_number( |
| 312 | session = session, |
| 313 | video_file_id = file_id, |
| 314 | label_file_id = label_file.id |
no test coverage detected