def dot_plot_results(means: str, pvalues: str, rows: str, columns: str, job_id: str): with tempfile.TemporaryDirectory() as output_path: with tempfile.NamedTemporaryFile(suffix=os.path.splitext(means)[-1]) as means_file: with tempfile.NamedTemporaryFile(suffix=os.path.splitext(pvalues)[-1]) as pvalues_file: with tempfile.NamedTemporaryFile() as rows_file: with tempfile.NamedTemporaryFile() as columns_file: _from_s3_to_temp(means, means_file) _from_s3_to_temp(pvalues, pvalues_file) _from_s3_to_temp(rows, rows_file) _from_s3_to_temp(columns, columns_file) output_name = 'plot__{}.png'.format(job_id) dot_plot(means_file.name, pvalues_file.name, output_path, output_name, rows_file.name, columns_file.name) output_file = os.path.join(output_path, output_name) if not os.path.exists(output_file): raise PlotException('Could not generate output file for plot of type dot_plot') response = { 'job_id': job_id, 'files': { 'plot': output_name, }, 'success': True } write_image_to_s3(output_file, output_name) return response
def heatmaps_plot_results(meta: str, pvalues: str, job_id: str): with tempfile.TemporaryDirectory() as output_path: with tempfile.NamedTemporaryFile(suffix=os.path.splitext(pvalues)[-1]) as pvalues_file: with tempfile.NamedTemporaryFile() as meta_file: _from_s3_to_temp(pvalues, pvalues_file) _from_s3_to_temp(meta, meta_file) count_name = 'plot_count__{}.png'.format(job_id) count_log_name = 'plot_count_log__{}.png'.format(job_id) heatmaps_plot(meta_file.name, pvalues_file.name, output_path, count_name, count_log_name) output_count_file = os.path.join(output_path, count_name) output_count_log_file = os.path.join(output_path, count_log_name) if not os.path.exists(output_count_file) or not os.path.exists(output_count_log_file): raise PlotException('Could not generate output file for plot of type dot_plot') response = { 'job_id': job_id, 'files': { 'count_plot': count_name, 'count_log_plot': count_log_name }, 'success': True } write_image_to_s3(output_count_file, count_name) write_image_to_s3(output_count_log_file, count_log_name) return response