flowcraft/generator/report.py
def _get_report_id(self):
        """Returns a hash of the reports JSON file
        """

        if self.watch:

            # Searches for the first occurence of the nextflow pipeline
            # file name in the .nextflow.log file
            pipeline_path = get_nextflow_filepath(self.log_file)

            # Get hash from the entire pipeline file
            pipeline_hash = hashlib.md5()
            with open(pipeline_path, "rb") as fh:
                for chunk in iter(lambda: fh.read(4096), b""):
                    pipeline_hash.update(chunk)
            # Get hash from the current working dir and hostname
            workdir = os.getcwd().encode("utf8")
            hostname = socket.gethostname().encode("utf8")
            hardware_addr = str(uuid.getnode()).encode("utf8")
            dir_hash = hashlib.md5(workdir + hostname + hardware_addr)

            return pipeline_hash.hexdigest() + dir_hash.hexdigest()

        else:
            with open(self.report_file) as fh:
                report_json = json.loads(fh.read())

            metadata = report_json["data"]["results"][0]["nfMetadata"]

            try:
                report_id = metadata["scriptId"] + metadata["sessionId"]
            except KeyError:
                raise eh.ReportError("Incomplete or corrupt report JSON file "
                                     "missing the 'scriptId' and/or 'sessionId' "
                                     "metadata information")

            return report_id
def _get_report_id(self):
        if self.watch:

            # Searches for the first occurence of the nextflow pipeline
            # file name in the .nextflow.log file
            pipeline_path = get_nextflow_filepath(self.log_file)

            # Get hash from the entire pipeline file
            pipeline_hash = hashlib.md5()
            with open(pipeline_path, "rb") as fh:
                for chunk in iter(lambda: fh.read(4096), b""):
                    pipeline_hash.update(chunk)
            # Get hash from the current working dir and hostname
            workdir = os.getcwd().encode("utf8")
            hostname = socket.gethostname().encode("utf8")
            hardware_addr = str(uuid.getnode()).encode("utf8")
            dir_hash = hashlib.md5(workdir + hostname + hardware_addr)

            return pipeline_hash.hexdigest() + dir_hash.hexdigest()

        else:
            with open(self.report_file) as fh:
                report_json = json.loads(fh.read())

            metadata = report_json["data"]["results"][0]["nfMetadata"]

            try:
                report_id = metadata["scriptId"] + metadata["sessionId"]
            except KeyError:
                raise eh.ReportError("Incomplete or corrupt report JSON file "
                                     "missing the 'scriptId' and/or 'sessionId' "
                                     "metadata information")

            return report_id
def _get_report_id ( self ) : if self . watch : # Searches for the first occurence of the nextflow pipeline # file name in the .nextflow.log file pipeline_path = get_nextflow_filepath ( self . log_file ) # Get hash from the entire pipeline file pipeline_hash = hashlib . md5 ( ) with open ( pipeline_path , "rb" ) as fh : for chunk in iter ( lambda : fh . read ( 4096 ) , b"" ) : pipeline_hash . update ( chunk ) # Get hash from the current working dir and hostname workdir = os . getcwd ( ) . encode ( "utf8" ) hostname = socket . gethostname ( ) . encode ( "utf8" ) hardware_addr = str ( uuid . getnode ( ) ) . encode ( "utf8" ) dir_hash = hashlib . md5 ( workdir + hostname + hardware_addr ) return pipeline_hash . hexdigest ( ) + dir_hash . hexdigest ( ) else : with open ( self . report_file ) as fh : report_json = json . loads ( fh . read ( ) ) metadata = report_json [ "data" ] [ "results" ] [ 0 ] [ "nfMetadata" ] try : report_id = metadata [ "scriptId" ] + metadata [ "sessionId" ] except KeyError : raise eh . ReportError ( "Incomplete or corrupt report JSON file " "missing the 'scriptId' and/or 'sessionId' " "metadata information" ) return report_id
Returns a hash of the reports JSON file
Returns a hash of the reports JSON file