diff options
author | BonfaceKilz | 2022-06-16 13:55:39 +0300 |
---|---|---|
committer | BonfaceKilz | 2022-06-21 11:46:56 +0300 |
commit | c6d6b1b59531d44b514f97184160d4bb096b01b5 (patch) | |
tree | e45cf71dec6c286b0fa5f220c463bcfbb59ce7ef | |
parent | 42e7643d6bd2e3b26ca35a91c73bfd65e95bb386 (diff) | |
download | genenetwork2-c6d6b1b59531d44b514f97184160d4bb096b01b5.tar.gz |
wqflask: views: Delete noisy logging and dead code
- Remove commented out code-blocks
- Remove calls with this pattern:
logger.info("Sending ...")
logger.info(request.url)
Should you want to inspect the local context of an
environment when troubleshooting, set a
breakpoint() and inspect the environment. To view
everything in the local context, use "pp
locals()"; and to view everything in the global
context, use "pp globals()".
-rw-r--r-- | wqflask/wqflask/views.py | 104 |
1 files changed, 0 insertions, 104 deletions
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index a371d983..63f3b3bb 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -158,8 +158,6 @@ def handle_generic_exceptions(e): stack={formatted_lines}, error_image=animation, version=GN_VERSION)) - - # logger.error("Set cookie %s with %s" % (err_msg, animation)) resp.set_cookie(err_msg[:32], animation) return resp @@ -171,8 +169,6 @@ def no_access_page(): @app.route("/") def index_page(): - logger.info("Sending index_page") - logger.info(request.url) params = request.args if 'import_collections' in params: import_collections = params['import_collections'] @@ -184,11 +180,7 @@ def index_page(): @app.route("/tmp/<img_path>") def tmp_page(img_path): - logger.info("In tmp_page") - logger.info("img_path:", img_path) - logger.info(request.url) initial_start_vars = request.form - logger.info("initial_start_vars:", initial_start_vars) imgfile = open(GENERATED_IMAGE_DIR + img_path, 'rb') imgdata = imgfile.read() imgB64 = base64.b64encode(imgdata) @@ -224,22 +216,14 @@ def twitter(filename): @app.route("/search", methods=('GET',)) def search_page(): - logger.info("in search_page") - logger.info(request.url) result = None if USE_REDIS: with Bench("Trying Redis cache"): key = "search_results:v1:" + \ json.dumps(request.args, sort_keys=True) - logger.debug("key is:", pf(key)) result = Redis.get(key) if result: - logger.info("Redis cache hit on search results!") result = pickle.loads(result) - else: - logger.info("Skipping Redis cache (USE_REDIS=False)") - - logger.info("request.args is", request.args) the_search = SearchResultPage(request.args) result = the_search.__dict__ valid_search = result['search_term_exists'] @@ -256,15 +240,7 @@ def search_page(): @app.route("/search_table", methods=('GET',)) def search_page_table(): - logger.info("in search_page table") - logger.info(request.url) - - logger.info("request.args is", request.args) the_search = search_results.SearchResultPage(request.args) - - logger.info(type(the_search.trait_list)) - logger.info(the_search.trait_list) - current_page = server_side.ServerSideTable( len(the_search.trait_list), the_search.trait_list, @@ -277,7 +253,6 @@ def search_page_table(): @app.route("/gsearch", methods=('GET',)) def gsearchact(): - logger.info(request.url) result = GSearch(request.args).__dict__ type = request.args['type'] if type == "gene": @@ -288,8 +263,6 @@ def gsearchact(): @app.route("/gsearch_table", methods=('GET',)) def gsearchtable(): - logger.info(request.url) - gsearch_table_data = GSearch(request.args) current_page = server_side.ServerSideTable( gsearch_table_data.trait_count, @@ -303,15 +276,12 @@ def gsearchtable(): @app.route("/gsearch_updating", methods=('POST',)) def gsearch_updating(): - logger.info("REQUEST ARGS:", request.values) - logger.info(request.url) result = UpdateGSearch(request.args).__dict__ return result['results'] @app.route("/docedit") def docedit(): - logger.info(request.url) try: if g.user_session.record['user_email_address'] == "zachary.a.sloan@gmail.com" or g.user_session.record['user_email_address'] == "labwilliams@gmail.com": doc = Docs(request.args['entry'], request.args) @@ -324,13 +294,11 @@ def docedit(): @app.route('/generated/<filename>') def generated_file(filename): - logger.info(request.url) return send_from_directory(GENERATED_IMAGE_DIR, filename) @app.route("/help") def help(): - logger.info(request.url) doc = Docs("help", request.args) return render_template("docs.html", **doc.__dict__) @@ -338,8 +306,6 @@ def help(): @app.route("/wgcna_setup", methods=('POST',)) def wcgna_setup(): # We are going to get additional user input for the analysis - logger.info("In wgcna, request.form is:", request.form) - logger.info(request.url) # Display them using the template return render_template("wgcna_setup.html", **request.form) @@ -353,8 +319,6 @@ def wcgna_results(): @app.route("/ctl_setup", methods=('POST',)) def ctl_setup(): # We are going to get additional user input for the analysis - logger.info("In ctl, request.form is:", request.form) - logger.info(request.url) # Display them using the template return render_template("ctl_setup.html", **request.form) @@ -362,7 +326,6 @@ def ctl_setup(): @app.route("/ctl_results", methods=["POST"]) def ctl_results(): - ctl_results = run_ctl(request.form) return render_template("gn3_ctl_results.html", **ctl_results) @@ -400,7 +363,6 @@ def update_page(): @app.route("/submit_trait") def submit_trait_form(): - logger.info(request.url) species_and_groups = get_species_groups() return render_template( "submit_trait.html", @@ -411,7 +373,6 @@ def submit_trait_form(): @app.route("/create_temp_trait", methods=('POST',)) def create_temp_trait(): - logger.info(request.url) doc = Docs("links") return render_template("links.html", **doc.__dict__) @@ -422,9 +383,6 @@ def export_trait_excel(): trait_name, sample_data = export_trait_data.export_sample_table( request.form) app.logger.info(request.url) - logger.info("sample_data - type: %s -- size: %s" % - (type(sample_data), len(sample_data))) - buff = io.BytesIO() workbook = xlsxwriter.Workbook(buff, {'in_memory': True}) worksheet = workbook.add_worksheet() @@ -443,15 +401,9 @@ def export_trait_excel(): @app.route('/export_trait_csv', methods=('POST',)) def export_trait_csv(): """CSV file consisting of the sample data from the trait data and analysis page""" - logger.info("In export_trait_csv") - logger.info("request.form:", request.form) - logger.info(request.url) trait_name, sample_data = export_trait_data.export_sample_table( request.form) - logger.info("sample_data - type: %s -- size: %s" % - (type(sample_data), len(sample_data))) - buff = io.StringIO() writer = csv.writer(buff) for row in sample_data: @@ -467,9 +419,6 @@ def export_trait_csv(): @app.route('/export_traits_csv', methods=('POST',)) def export_traits_csv(): """CSV file consisting of the traits from the search result page""" - logger.info("In export_traits_csv") - logger.info("request.form:", request.form) - logger.info(request.url) file_list = export_traits(request.form, "metadata") if len(file_list) > 1: @@ -501,7 +450,6 @@ def export_collection_csv(): @app.route('/export_perm_data', methods=('POST',)) def export_perm_data(): """CSV file consisting of the permutation data for the mapping results""" - logger.info(request.url) perm_info = json.loads(request.form['perm_info']) now = datetime.datetime.now() @@ -572,9 +520,6 @@ def show_trait_page(): @app.route("/heatmap", methods=('POST',)) def heatmap_page(): - logger.info("In heatmap, request.form is:", pf(request.form)) - logger.info(request.url) - start_vars = request.form temp_uuid = uuid.uuid4() @@ -583,18 +528,14 @@ def heatmap_page(): version = "v5" key = "heatmap:{}:".format( version) + json.dumps(start_vars, sort_keys=True) - logger.info("key is:", pf(key)) with Bench("Loading cache"): result = Redis.get(key) if result: - logger.info("Cache hit!!!") with Bench("Loading results"): result = pickle.loads(result) else: - logger.info("Cache miss!!!") - template_vars = heatmap.Heatmap(request.form, temp_uuid) template_vars.js_data = json.dumps(template_vars.js_data, default=json_default_handler, @@ -602,12 +543,7 @@ def heatmap_page(): result = template_vars.__dict__ - for item in list(template_vars.__dict__.keys()): - logger.info( - " ---**--- {}: {}".format(type(template_vars.__dict__[item]), item)) - pickled_result = pickle.dumps(result, pickle.HIGHEST_PROTOCOL) - logger.info("pickled result length:", len(pickled_result)) Redis.set(key, pickled_result) Redis.expire(key, 60 * 60) @@ -623,9 +559,6 @@ def heatmap_page(): @app.route("/bnw_page", methods=('POST',)) def bnw_page(): - logger.info("In run BNW, request.form is:", pf(request.form)) - logger.info(request.url) - start_vars = request.form traits = [trait.strip() for trait in start_vars['trait_list'].split(',')] @@ -643,9 +576,6 @@ def bnw_page(): @app.route("/webgestalt_page", methods=('POST',)) def webgestalt_page(): - logger.info("In run WebGestalt, request.form is:", pf(request.form)) - logger.info(request.url) - start_vars = request.form traits = [trait.strip() for trait in start_vars['trait_list'].split(',')] @@ -663,9 +593,6 @@ def webgestalt_page(): @app.route("/geneweaver_page", methods=('POST',)) def geneweaver_page(): - logger.info("In run WebGestalt, request.form is:", pf(request.form)) - logger.info(request.url) - start_vars = request.form traits = [trait.strip() for trait in start_vars['trait_list'].split(',')] @@ -683,9 +610,6 @@ def geneweaver_page(): @app.route("/comparison_bar_chart", methods=('POST',)) def comp_bar_chart_page(): - logger.info("In comp bar chart, request.form is:", pf(request.form)) - logger.info(request.url) - start_vars = request.form traits = [trait.strip() for trait in start_vars['trait_list'].split(',')] @@ -712,7 +636,6 @@ def mapping_results_container_page(): @app.route("/loading", methods=('POST',)) def loading_page(): - # logger.info(request.url) initial_start_vars = request.form start_vars_container = {} n_samples = 0 # ZS: So it can be displayed on loading page @@ -769,7 +692,6 @@ def loading_page(): @app.route("/run_mapping", methods=('POST',)) def mapping_results_page(): initial_start_vars = request.form - logger.info(request.url) temp_uuid = initial_start_vars['temp_uuid'] wanted = ( 'trait_id', @@ -838,18 +760,11 @@ def mapping_results_page(): version) + json.dumps(start_vars, sort_keys=True) with Bench("Loading cache"): result = None # Just for testing - #result = Redis.get(key) - - #logger.info("************************ Starting result *****************") - #logger.info("result is [{}]: {}".format(type(result), result)) - #logger.info("************************ Ending result ********************") if result: - logger.info("Cache hit!!!") with Bench("Loading results"): result = pickle.loads(result) else: - logger.info("Cache miss!!!") with Bench("Total time in RunMapping"): try: template_vars = run_mapping.RunMapping(start_vars, temp_uuid) @@ -883,8 +798,6 @@ def mapping_results_page(): @app.route("/export_mapping_results", methods=('POST',)) def export_mapping_results(): - logger.info("request.form:", request.form) - logger.info(request.url) file_path = request.form.get("results_path") results_csv = open(file_path, "r").read() response = Response(results_csv, @@ -908,8 +821,6 @@ def export_corr_matrix(): @app.route("/export", methods=('POST',)) def export(): - logger.info("request.form:", request.form) - logger.info(request.url) svg_xml = request.form.get("data", "Invalid data") filename = request.form.get("filename", "manhattan_plot_snp") response = Response(svg_xml, mimetype="image/svg+xml") @@ -920,10 +831,7 @@ def export(): @app.route("/export_pdf", methods=('POST',)) def export_pdf(): import cairosvg - logger.info("request.form:", request.form) - logger.info(request.url) svg_xml = request.form.get("data", "Invalid data") - logger.info("svg_xml:", svg_xml) filename = request.form.get("filename", "interval_map_pdf") pdf_file = cairosvg.svg2pdf(bytestring=svg_xml) response = Response(pdf_file, mimetype="application/pdf") @@ -933,8 +841,6 @@ def export_pdf(): @app.route("/network_graph", methods=('POST',)) def network_graph_page(): - logger.info("In network_graph, request.form is:", pf(request.form)) - logger.info(request.url) start_vars = request.form traits = [trait.strip() for trait in start_vars['trait_list'].split(',')] if traits[0] != "": @@ -963,9 +869,6 @@ def test_corr_compute_page(): @app.route("/corr_matrix", methods=('POST',)) def corr_matrix_page(): - logger.info("In corr_matrix, request.form is:", pf(request.form)) - logger.info(request.url) - start_vars = request.form traits = [trait.strip() for trait in start_vars['trait_list'].split(',')] if len(traits) > 1: @@ -981,7 +884,6 @@ def corr_matrix_page(): @app.route("/corr_scatter_plot") def corr_scatter_plot_page(): - logger.info(request.url) template_vars = corr_scatter_plot.CorrScatterPlot(request.args) template_vars.js_data = json.dumps(template_vars.js_data, default=json_default_handler, @@ -991,7 +893,6 @@ def corr_scatter_plot_page(): @app.route("/snp_browser", methods=('GET',)) def snp_browser_page(): - logger.info(request.url) template_vars = snp_browser.SnpBrowser(request.args) return render_template("snp_browser.html", **template_vars.__dict__) @@ -1006,7 +907,6 @@ def db_info_page(): @app.route("/snp_browser_table", methods=('GET',)) def snp_browser_table(): - logger.info(request.url) snp_table_data = snp_browser.SnpBrowser(request.args) current_page = server_side.ServerSideTable( snp_table_data.rows_count, @@ -1021,20 +921,17 @@ def snp_browser_table(): @app.route("/tutorial/WebQTLTour", methods=('GET',)) def tutorial_page(): # ZS: Currently just links to GN1 - logger.info(request.url) return redirect("http://gn1.genenetwork.org/tutorial/WebQTLTour/") @app.route("/tutorial/security", methods=('GET',)) def security_tutorial_page(): # ZS: Currently just links to GN1 - logger.info(request.url) return render_template("admin/security_help.html") @app.route("/submit_bnw", methods=('POST',)) def submit_bnw(): - logger.info(request.url) return render_template("empty_collection.html", **{'tool': 'Correlation Matrix'}) # Take this out or secure it before putting into production @@ -1042,7 +939,6 @@ def submit_bnw(): @app.route("/get_temp_data") def get_temp_data(): - logger.info(request.url) temp_uuid = request.args['key'] return flask.jsonify(temp_data.TempData(temp_uuid).get_all()) |