This may be a long running operation for longer videos. Prior we had this start running on a new thread, but that doesn't really make sense since * The user likely wants to see results from this before proceeding * We want to make errors louder, ie not having enough instances etc.
(project_string_id, video_file_id)
| 563 | methods = ['POST']) |
| 564 | @Project_permissions.user_has_project(["admin", "Editor"]) |
| 565 | def interpolate_all_frames(project_string_id, video_file_id): |
| 566 | """ |
| 567 | |
| 568 | This may be a long running operation for longer videos. |
| 569 | Prior we had this start running on a new thread, but that doesn't really make sense since |
| 570 | * The user likely wants to see results from this before proceeding |
| 571 | * We want to make errors louder, ie not having enough instances etc. |
| 572 | * For an "average" case it completes in less < 10 seconds so it's not really that long running |
| 573 | |
| 574 | """ |
| 575 | |
| 576 | spec_list = [{'directory_id': int}] |
| 577 | |
| 578 | log, input, untrusted_input = regular_input.master(request = request, |
| 579 | spec_list = spec_list) |
| 580 | if len(log["error"].keys()) >= 1: |
| 581 | return jsonify(log = log), 400 |
| 582 | |
| 583 | with sessionMaker.session_scope() as session: |
| 584 | |
| 585 | project = Project.get(session, project_string_id) |
| 586 | |
| 587 | directory = WorkingDir.get_with_fallback( |
| 588 | session = session, |
| 589 | project = project, |
| 590 | directory_id = input['directory_id']) |
| 591 | |
| 592 | if directory is False or directory is None: |
| 593 | print("Invalid directory") |
| 594 | return jsonify("Invalid directory"), 400 |
| 595 | |
| 596 | try: |
| 597 | video_file = File.get_by_id_untrusted( |
| 598 | session = session, |
| 599 | user_id = None, |
| 600 | project_string_id = project_string_id, |
| 601 | file_id = video_file_id, |
| 602 | directory_id = directory.id, |
| 603 | with_for_update = True, |
| 604 | nowait = True) |
| 605 | except Exception as e: |
| 606 | trace = traceback.format_exc() |
| 607 | logger.error(f"File {video_file_id} is Locked") |
| 608 | logger.error(trace) |
| 609 | log['error']['file_locked'] = 'File is being saved by another process, please try again later.' |
| 610 | return jsonify(log), 400 |
| 611 | |
| 612 | return interpolate_api_shared(session, log, project, video_file) |
| 613 | |
| 614 | |
| 615 | def interpolate_api_shared( |
nothing calls this directly
no test coverage detected