Пример #1
0
def create_properties(log: EventLog) -> dict:
    """Create read-only dict with methods in this class"""
    return {
        'events': events_by_date(log),
        'resources': resources_by_date(log),
        'maxEventsInLog': max_events_in_log(log),
        'traceAttributes': trace_attributes(log),
        'newTraces': new_trace_start(log)
    }
Пример #2
0
def get_intercase_attributes(log: EventLog, encoding: Encoding):
    """Dict of kwargs
    These intercase attributes are expensive operations!!!
    """
    # Expensive operations
    executed_events = events_by_date(log) if encoding.add_executed_events else None
    resources_used = resources_by_date(log) if encoding.add_resources_used else None
    new_traces = new_trace_start(log) if encoding.add_new_traces else None
    kwargs = {'executed_events': executed_events, 'resources_used': resources_used, 'new_traces': new_traces}
    # 'label': label}  TODO: is it really necessary to add this field in the dict?
    return kwargs
Пример #3
0
def create_properties(log: EventLog) -> dict:
    """Create read-only dict with methods in this class"""
    return {
        'events': events_by_date(log),
        'resources': resources_by_date(log),
        'maxEventsInLog': max_events_in_log(log),
        'avgEventsInLog': avg_events_in_log(log),
        'stdVarEventsInLog': std_var_events_in_log(log),
        'traceAttributes': trace_attributes(log),
        'newTraces': new_trace_start(log),
        # 'alpha_miner_result': vis_factory.apply(*alpha_miner.apply(log)) #TODO ADD alpha miner
    }
Пример #4
0
def get_log_stats(request, pk, stat):
    """Get log statistics

    DEPRECATED ENDPOINT. LOGS HAVE PROPERTIES.

    End URL with
    * events for event_by_date
    * resources for resources_by_date
    * executions for event_executions
    * traceAttributes for trace_attributes
    * eventsInTrace for events_in_trace
    * newTraces for new_trace_start
    """
    try:
        log = Log.objects.get(pk=pk)
    except Log.DoesNotExist:
        return Response({'error': 'not in database'},
                        status=status.HTTP_404_NOT_FOUND)
    try:
        log_file = log.get_file()
    except FileNotFoundError:
        logger.error("Log id: %s, path %s not found", log.id, log.path)
        return Response({'error': 'log file not found'},
                        status=status.HTTP_404_NOT_FOUND)

    if stat == 'events':
        data = events_by_date(log_file)
    elif stat == 'resources':
        data = resources_by_date(log_file)
    elif stat == 'traceAttributes':
        data = trace_attributes(log_file)
    elif stat == 'eventsInTrace':
        data = events_in_trace(log_file)
    elif stat == 'executions':
        data = event_executions(log_file)
    elif stat == 'newTraces':
        data = new_trace_start(log_file)
    elif stat == 'alpha_miner':
        data = alpha_miner.apply(log)
    else:
        logger.info('stats error in get_log_stats, setting data to None')
        data = None
    return Response(data)
Пример #5
0
 def test_events_by_date(self):
     result = events_by_date(self.log)
     self.assertEqual(18, len(result.keys()))
     self.assertEqual(4, result['2011-01-08'])
 def test_count_on_event_day_event_out_of_range(self):
     event_dict = log_metrics.events_by_date(self.log)
     count = count_on_event_day(self.log[0], event_dict, 100)
     self.assertEqual(0, count)
 def test_count_on_event_day(self):
     event_dict = log_metrics.events_by_date(self.log)
     count = count_on_event_day(self.log[0], event_dict, 0)
     self.assertEqual(7, count)