Exemplo n.º 1
0
    def load_log_on_request(self, log_name):
        """
        Loads an event log on request

        Parameters
        ------------
        log_path
            Log name
        """
        handler = None
        file_path = self.logs_correspondence[log_name]

        if file_path.endswith(".parquet"):
            handler = ParquetHandler(is_lazy=True)
            handler.build_from_path(file_path)
        elif file_path.endswith(".csv"):
            handler = ParquetHandler(is_lazy=True)
            handler.build_from_csv(file_path)
        elif file_path.endswith(".xes") or file_path.endswith(".xes.gz"):
            handler = XesHandler()
            handler.build_from_path(file_path)
        elif file_path.endswith("xml"):
            handler = XmlHandler()
            handler.build_from_path(file_path)
        return handler
Exemplo n.º 2
0
    def load_log_static(self, log_name, file_path, parameters=None):
        """
        Loads an event log inside the known handlers

        Parameters
        ------------
        log_name
            Log name
        file_path
            Full path (in the services machine) to the log
        parameters
            Possible parameters
        """
        if log_name not in self.handlers:
            if file_path.endswith(".parquet"):
                self.handlers[log_name] = ParquetHandler()
                self.handlers[log_name].build_from_path(file_path,
                                                        parameters=parameters)
            elif file_path.endswith(".csv"):
                self.handlers[log_name] = ParquetHandler()
                self.handlers[log_name].build_from_csv(file_path,
                                                       parameters=parameters)
            elif file_path.endswith(".xes") or file_path.endswith(".xes.gz"):
                self.handlers[log_name] = XesHandler()
                self.handlers[log_name].build_from_path(file_path,
                                                        parameters=parameters)
Exemplo n.º 3
0
    def load_temp_log_if_it_is_there(self, log_name, session, parameters=None):
        """
        Load a log associated to a session if it exists in the temp logs folder

        Parameters
        --------------
        log_name
            Log name
        session
            Session ID
        parameters
            Possible parameters of the algorithm
        """
        if parameters is None:
            parameters = {}
        force_reload = parameters["force_reload"] if "force_reload" in parameters else False
        if force_reload:
            return None

        handler = None
        file_path = self.logs_correspondence[log_name]
        is_parquet = False
        extension = "xes"
        if file_path.endswith(".parquet") or file_path.endswith(".csv"):
            is_parquet = True
            extension = "parquet"
        temp_log_path = os.path.join(Configuration.temp_logs_path, str(log_name)+"_"+str(session)+"."+extension)
        if os.path.exists(temp_log_path):
            if is_parquet:
                handler = ParquetHandler(is_lazy=True)
                handler.build_from_path(temp_log_path)
            else:
                handler = XesHandler()
                handler.build_from_path(temp_log_path)
        return handler
Exemplo n.º 4
0
    def manage_upload(self, user, basename, filepath, is_temporary=False):
        """
        Manages an event log that is uploaded

        Parameters
        ------------
        user
            Current user
        basename
            Name of the log
        filepath
            Log path
        """

        if filepath.endswith(".parquet"):
            self.handlers[basename] = ParquetHandler()
            self.handlers[basename].build_from_path(filepath)
        elif filepath.endswith(".csv"):
            self.handlers[basename] = ParquetHandler()
            self.handlers[basename].build_from_csv(filepath)
        else:
            self.handlers[basename] = XesHandler()
            self.handlers[basename].build_from_path(filepath)
        conn_logs = sqlite3.connect(self.database_path)
        curs_logs = conn_logs.cursor()
        if is_temporary:
            curs_logs.execute("INSERT INTO EVENT_LOGS VALUES (?,?,1,0,1)",
                              (basename, filepath))
        else:
            curs_logs.execute("INSERT INTO EVENT_LOGS VALUES (?,?,0,1,1)",
                              (basename, filepath))
        curs_logs.execute("INSERT INTO USER_LOG_VISIBILITY VALUES (?,?)",
                          (user, basename))
        curs_logs.execute("INSERT INTO USER_LOG_DOWNLOADABLE VALUES (?,?)",
                          (user, basename))
        curs_logs.execute("INSERT INTO USER_LOG_REMOVAL VALUES (?,?)",
                          (user, basename))
        conn_logs.commit()
        conn_logs.close()
Exemplo n.º 5
0
 def test_xes(self):
     handler = XesHandler()
     path = os.path.join("..", "running-example.xes")
     handler.build_from_path(path)
     handler.get_schema(variant="dfg_freq")
     handler.get_schema(variant="dfg_perf")
     handler.get_schema(variant="alpha_freq")
     handler.get_schema(variant="alpha_perf")
     handler.get_schema(variant="inductive_freq")
     handler.get_schema(variant="inductive_perf")
     handler.get_schema(variant="tree_freq")
     handler.get_schema(variant="tree_perf")
     handler.get_case_duration_svg()
     handler.get_events_per_time_svg()
     handler.get_sna(variant="handover")
     handler.get_sna(variant="working_together")
     handler.get_sna(variant="subcontracting")
     handler.get_sna(variant="jointactivities")
     handler.get_transient(86400)
Exemplo n.º 6
0
def basic_test(path):
    handler = XesHandler()
    handler.build_from_path(path)
    handler.get_schema(variant="dfg_freq")
    handler.get_schema(variant="dfg_perf")
    handler.get_schema(variant="inductive_freq")
    handler.get_schema(variant="inductive_perf")
    handler.get_schema(variant="indbpmn_freq")
    handler.get_schema(variant="indbpmn_perf")
    handler.get_schema(variant="heuristics_freq")
    handler.get_schema(variant="heuristics_perf")
    handler.get_schema(variant="tree_freq")
    handler.get_schema(variant="tree_perf")
    handler.get_case_duration_svg()
    handler.get_events_per_time_svg()
    handler.get_sna(variant="handover")
    handler.get_sna(variant="working_together")
    handler.get_sna(variant="subcontracting")
    handler.get_sna(variant="jointactivities")
    handler.get_transient(86400)
Exemplo n.º 7
0
 def test_ru_filtering(self):
     handler = XesHandler()
     handler.build_from_path("logs//running-example.xes")
     handler = handler.add_filter(
         ['timestamp_trace_intersecting', '1293703320@@@1294667760'],
         ['timestamp_trace_intersecting', '1293703320@@@1294667760'])
     handler.get_start_activities()
     handler.get_end_activities()
     handler.get_variant_statistics()
     handler = handler.add_filter(
         ['timestamp_trace_containing', '1293703320@@@1294667760'],
         [['timestamp_trace_intersecting', '1293703320@@@1294667760'],
          ['timestamp_trace_containing', '1293703320@@@1294667760']])
     handler.get_start_activities()
     handler.get_end_activities()
     handler.get_variant_statistics()
     handler = handler.remove_filter(
         ['timestamp_trace_containing', '1293703320@@@1294667760'],
         [['timestamp_trace_intersecting', '1293703320@@@1294667760']])
     handler.get_start_activities()
     handler.get_end_activities()
     handler.get_variant_statistics()
     handler = handler.remove_filter(
         ['timestamp_trace_intersecting', '1293703320@@@1294667760'], [])
     handler.get_start_activities()
     handler.get_end_activities()
     handler.get_variant_statistics()
     handler = handler.add_filter(['end_activities', ['reject request']],
                                  [['end_activities', ['reject request']]])
     handler.get_start_activities()
     handler.get_end_activities()
     handler.get_variant_statistics()
     handler = handler.add_filter(
         ['attributes_pos_trace', ['concept:name', ['check ticket']]],
         [['end_activities', ['reject request']],
          ['attributes_pos_trace', ['concept:name', ['check ticket']]]])
     handler.get_start_activities()
     handler.get_end_activities()
     handler.get_variant_statistics()
     handler = handler.remove_filter(
         ['attributes_pos_trace', ['concept:name', ['check ticket']]],
         [['end_activities', ['reject request']]])
     handler = handler.remove_filter(['end_activities', ['reject request']],
                                     [])
     handler.get_start_activities()
     handler.get_end_activities()
     handler.get_variant_statistics()
Exemplo n.º 8
0
def process_quantities_test(path):
    handler = XesHandler()
    handler.build_from_path(path)
    handler.get_start_activities()
    handler.get_end_activities()
    handler.get_variant_statistics()
    cases = handler.get_case_statistics()
    case_id_0 = cases[0]['caseId']
    handler.get_variant_statistics()
    handler.get_paths("concept:name")
    handler.get_attribute_values("concept:name")
    handler.get_events(case_id_0)