def case_finished(case, **kwargs): conf = wok_server.engine.projects.project_conf(PROJECT_NAME, platform_name=DEFAULT_PLATFORM_NAME) conf["user_id"] = case.owner.nick conf["workspace"] = DEFAULT_WORKSPACE results_path = get_results_path(conf) engine_case = wok_server.engine.case(case.engine_name) if engine_case is not None: download_files(wok_server.logger, engine_case.name, engine_case.storages, "results/", results_path)
def get_paths(project_id, conf=None): if conf is None: conf = get_project_conf() results_path = get_results_path(conf) project_path = get_project_path(conf, project_id) project_temp_path = get_temp_path(conf, project_id) ensure_path_exists(project_path) ensure_path_exists(project_temp_path) return results_path, project_path, project_temp_path
def __load_case_info(case, except_enabled=False, quality_enabled=False): wok = current_app.wok case_info = dict( id=case.id, name=case.name, state=case.state.title if case.state is not None else None,created=case.created, started=case.started, finished=case.finished, removed=case.removed) if case.state is not None: case_info["state"] = case.state.title if case.properties is not None: conf = get_project_conf() results_path = get_results_path(conf) project_path = os.path.join(results_path, case.properties["path"]) quality = None if quality_enabled: project_results = ProjectResults(path=project_path) quality = project_results.load_quality_control() zip_path = os.path.join(project_path, "results.zip") website_path = os.path.join(project_path, "website", "results", "project.tsv") case_info.update( analysis_type=case.properties["analysis_type"], results_available=os.path.exists(zip_path), website_available=os.path.exists(website_path), quality=quality if quality is not None and len(quality) > 0 else None) engine_case = wok.engine.case(case.engine_name) if engine_case is not None: exceptions = None if except_enabled: exceptions = __engine_case_exceptions(engine_case) case_info.update( state=engine_case.state.title, started=engine_case.started, finished=engine_case.finished, elapsed=engine_case.elapsed, progress=__engine_case_progress(engine_case), exceptions=exceptions) return case_info
def case_removed(case, **kwargs): conf = wok_server.engine.projects.project_conf(PROJECT_NAME, platform_name=DEFAULT_PLATFORM_NAME) conf["user_id"] = case.owner.nick conf["workspace"] = DEFAULT_WORKSPACE results_path = get_results_path(conf) project_path = os.path.join(results_path, case.properties["path"]) user = case.owner onexus_projects = conf.get("website.projects_list") if onexus_projects is not None and os.path.exists(os.path.join(project_path, "website")): wok_server.logger.info("[{}] Removing Onexus project {} ...".format(user.nick, case.name)) onexus = Onexus(onexus_projects) onexus.remove_project(user.nick, case.name) wok_server.logger.info("[{}] Removing case files {} ...".format(user.nick, case.name)) if os.path.exists(project_path): shutil.rmtree(project_path)
def download(case_id): case = current_app.wok.case_by_id(case_id, current_user) if case is None: flash("Case does not exist, there is nothing to download", "error") return redirect(url_for(".index")) current_app.logger.info("[{}] Downloading case results {} ({})...".format(current_user.nick, case.name, case.engine_name)) conf = get_project_conf() results_path = get_results_path(conf) project_path = os.path.join(results_path, case.properties["path"]) dest_path = os.path.join(project_path, "results.zip") if not os.path.exists(dest_path): flash("Sorry, there were an internal error and the results are not available", "error") app.logger.error("[{}] results.zip not available for case {} at {}".format(current_user.nick, case.id, project_path)) return redirect(url_for(".index")) return send_file( dest_path, mimetype="application/x-gzip", as_attachment=True, attachment_filename="IntOGen-Mutations-{}.zip".format(case.name))