jayrbolton / KBaseReport

experiments with a report data type for the kbase sdk

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Status

KBaseReport


The KBaseReports module is the preferred way to communicate results to users. The example module contains a minimal use case where a string is displayed to the user (supplied in the 'text_message' field) along with links to new objects created by the app (supplied in the 'objects_created' field). However this module also contains functionality to create and display HTML webpages and serve files directly for user download. A more typical and feature rich example can be found in KBase's implementation of Ballgown

An annotated copy of the master function is copied below:

def _generate_report(self, params, result_directory, diff_expression_matrix_set_ref):
        """
        _generate_report: generate summary report
        """
        print('creating report')
        # Files to be presented directly to the user are copied to a output directory, zipped and returned as a list of paths
        output_files = self._generate_output_file_list(result_directory)
        
        # A folder for the display web page is created(L74 in ballgown repo linked above), reference data (could also be 
        # embedded images) for the page are copied in(L78), custom html is generated(L81-95), template is updated with 
        # custom html(L98-104), the complete web page is saved to SHOCK which will serve the data(L106) and an object with 
        # that reference is returned(L109)
        output_html_files = self._generate_html_report(result_directory, params, diff_expression_matrix_set_ref)

        report_params = {
              'message': '',
              'workspace_name': params.get('workspace_name'),
              'file_links': output_files,
              'html_links': output_html_files,
              'direct_html_link_index': 0,
              'html_window_height': 333,
              'report_object_name': 'kb_ballgown_report_' + str(uuid.uuid4())}
        
        # Make the client, generate the report
        kbase_report_client = KBaseReport(self.callback_url)
        output = kbase_report_client.create_extended_report(report_params)
        # Return references which will allow inline display of the report in the Narrative
        report_output = {'report_name': output['name'], 'report_ref': output['ref']}

        return report_output

About

experiments with a report data type for the kbase sdk

License:MIT License


Languages

Language:HTML 64.0%Language:Perl 32.3%Language:Python 1.4%Language:Java 1.2%Language:CSS 0.6%Language:JavaScript 0.2%Language:Ruby 0.1%Language:Makefile 0.1%Language:Shell 0.0%