def get(self, project_id, solution_id): project = Project.find_project_with_id(project_id) user_id = get_jwt_identity() if not project or not project.belongs_to_user(user_id): return self.project_does_not_exist_response() solution = Solution.find_solution_with_id(project.type, solution_id) if not solution or not solution.if_belongs_to(project.id): return self.solution_does_not_exist_response() analytics = Analytics(solution) status = analytics.get_status() main_stats, secondary_stats = status["main_status"], status["secondary_status"] parameters = status["hyperparameters"] if not solution.analytics_filled(): if analytics.solution_has_completed(main_stats): solution.update_analytics(analytics.get_solution_metrics()) return { "type": project.type, "status": main_stats, "secondary_status": secondary_stats, "parameters": parameters, "solution": solution.json() }
def get(self, project_id, solution_id): # Check if project belongs to correct user project = Project.find_project_with_id(project_id) user_id = get_jwt_identity() if not project or not project.belongs_to_user(user_id): return self.project_does_not_exist_response() # Check if solution belongs to project solution = Solution.find_solution_with_id(project.type, solution_id) if not solution or not solution.if_belongs_to(project.id): return self.solution_does_not_exist_response() # Get download link downloader = SolutionDownloader(solution) download_url = downloader.get_solution_url() # Return return { "url": download_url }, 201 # Created URL