<commit_before>import numpy as np
import pandas as pd
from ipywidgets import interact
from ipywidgets import fixed
from ipywidgets import widgets
from itertools import chain

from ..workflow.entities.join import RequestjoinActivity
from ..workflow.entities.request import RequestInstance

from .automated_suite import generate_reports
from .statistics_engine import generate_dataframes
from .draw_engine import DrawEngine
from .draw_engine import getcolor_byint
from .draw_engine import (REMOTE_C, LOCALREMOTE_C, LOCAL_C)


class Requests_D(object):
    def __init__(self, name, requestins_byreq, graph):
        self.name = "reqs(%s)<<%s" % (graph.name, name)
        self.graph = graph
        self._draw_engine = DrawEngine(None)
        self._requestins_byreq = requestins_byreq

        ret = generate_dataframes(requestins_byreq)
        (requestinss_bytype,
         targetobjs_bytarget,
         self._workflow_bytype,
         # seconds -> start/end/last
         # time -> start/end/last
         self._start_end,
         df_ints_join_all,
         df_ints_thread,
         # *"request",
         # "request_type",
         # "int_name",
         # "lapse",
         # "path",
         # "from_seconds",
         # "to_seconds",
         # "from_time",
         # "to_time",
         # "from_keyword",
         # "to_keyword",
         # "int_type",
         # ---------
         # "request_state",
         # "last_seconds",
         # "last_time",
         # "len_paces",
         # "len_main_paces",
         # "len_threads",
         # "len_threadinss",
         # "len_targets",
         # "len_hosts"
         self.df_requests,
         # *"target",
         # "component",
         # "host"
         self.df_targets,
         self.df_request_vars) = ret
        df_ints_join = df_ints_join_all[df_ints_join_all["int_type"]!=RequestjoinActivity.__name__]
        self._intervals_d = Intervals_D(
                "Ints<<"+self.name, self, None, df_ints_thread, df_ints_join)
        (self._report_r, self._report_i) = generate_reports(name, graph, *ret)
        (self._report_r, self._report_i) = generate_reports(
                name, graph, *ret[0:-1])

    @property
    def Intervals(self):
        return self._intervals_d

    def __repr__(self):
        ret = "<Requests %s: num_reqs=%d, graph=%s, lapse=[%s, %s]>" % (
                self.name, len(self._requestins_byreq),
                self.graph.name,
                self._start_end["time"]["start"],
                self._start_end["time"]["end"])
        return ret

    def __str__(self):
        ret = repr(self)
        ret += "\n\n" + str(self._report_i)
        for rtype, workflow in self._workflow_bytype.items():
            ret += "\n\n" + str(workflow)
        ret += "\n\n" + str(self._report_r)
        return ret

    def _ipython_display_(self):
        print(repr(self))
        self.display_profiling()

    def display_profiling(self):
        for r_type, workflow in self._workflow_bytype.items():
            self._draw_engine.draw_workflow(self._start_end,<commit_msg>fix display error<commit_after>import numpy as np
import pandas as pd
from ipywidgets import interact
from ipywidgets import fixed
from ipywidgets import widgets
from itertools import chain

from ..workflow.entities.join import RequestjoinActivity
from ..workflow.entities.request import RequestInstance

from .automated_suite import generate_reports
from .statistics_engine import generate_dataframes
from .draw_engine import DrawEngine
from .draw_engine import getcolor_byint
from .draw_engine import (REMOTE_C, LOCALREMOTE_C, LOCAL_C)


class Requests_D(object):
    def __init__(self, name, requestins_byreq, graph):
        self.name = "reqs(%s)<<%s" % (graph.name, name)
        self.graph = graph
        self._draw_engine = DrawEngine(None)
        self._requestins_byreq = requestins_byreq

        ret = generate_dataframes(requestins_byreq)
        (requestinss_bytype,
         targetobjs_bytarget,
         self._workflow_bytype,
         # seconds -> start/end/last
         # time -> start/end/last
         self._start_end,
         df_ints_join_all,
         df_ints_thread,
         # *"request",
         # "request_type",
         # "int_name",
         # "lapse",
         # "path",
         # "from_seconds",
         # "to_seconds",
         # "from_time",
         # "to_time",
         # "from_keyword",
         # "to_keyword",
         # "int_type",
         # ---------
         # "request_state",
         # "last_seconds",
         # "last_time",
         # "len_paces",
         # "len_main_paces",
         # "len_threads",
         # "len_threadinss",
         # "len_targets",
         # "len_hosts"
         self.df_requests,
         # *"target",
         # "component",
         # "host"
         self.df_targets,
         self.df_request_vars) = ret
        df_ints_join = df_ints_join_all[df_ints_join_all["int_type"]!=RequestjoinActivity.__name__]
        self._intervals_d = Intervals_D(
                "Ints<<"+self.name, self, None, df_ints_thread, df_ints_join)
        (self._report_r, self._report_i) = generate_reports(name, graph, *ret)

    @property
    def Intervals(self):
        return self._intervals_d

    def __repr__(self):
        ret = "<Requests %s: num_reqs=%d, graph=%s, lapse=[%s, %s]>" % (
                self.name, len(self._requestins_byreq),
                self.graph.name,
                self._start_end["time"]["start"],
                self._start_end["time"]["end"])
        return ret

    def __str__(self):
        ret = repr(self)
        ret += "\n\n" + str(self._report_i)
        for rtype, workflow in self._workflow_bytype.items():
            ret += "\n\n" + str(workflow)
        ret += "\n\n" + str(self._report_r)
        return ret

    def _ipython_display_(self):
        print(repr(self))
        self.display_profiling()

    def display_profiling(self):
        for r_type, workflow in self._workflow_bytype.items():
            self._draw_engine.draw_workflow(self._start_end,
{'fraction_non_alphanumeric': 0.11664460622104567, 'fraction_numerical': 0.00033090668431502316, 'mean_word_length': 2.255250403877221, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7048881', 'n_tokens_mistral': 1954, 'n_tokens_neox': 1889, 'n_words': 363}