pm4py / pm4py-core

Public repository for the PM4Py (Process Mining for Python) project.
https://pm4py.fit.fraunhofer.de
GNU General Public License v3.0
722 stars 286 forks source link

EventLog Object #451

Closed isobelKeen closed 11 months ago

isobelKeen commented 11 months ago

Hi, I want to add an artificial start and end date to my log and I used these lines of code:

log = xes_importer.apply(sys.argv[1], variant=variant, parameters=parameters) log_new=pm4py.objects.log.util.log.add_artficial_start_and_end(log, start='[start>', end='[end]', activity_key='concept:name')

But I get this error:

File "/Users/IsobelKeen/Documents/Year 3/AMP III/DiscoveryTemplate-main/main.py", line 268, in log_new=pm4py.objects.log.util.log.add_artficial_start_and_end(log, start='[start>', end='[end]', activity_key='concept:name') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/IsobelKeen/anaconda3/lib/python3.11/site-packages/pm4py/objects/log/util/log.py", line 150, in add_artficial_start_and_end trace.insert(0, event_log.Event({activity_key: start})) ^^^^^^^^^^^^^^^ AttributeError: 'EventLog' object has no attribute 'Event'

Thanks for your help!

fit-alessandro-berti commented 11 months ago

Dear @isobelKeen

Please use:

log = pm4py.insert_artificial_start_end(log, activity_key="concept:name")

If you need to use custom symbols, please put before the aforementioned command these lines:

pm4py.util.constants.DEFAULT_ARTIFICIAL_START_ACTIVITY = '[start>'
pm4py.util.constants.DEFAULT_ARTIFICIAL_END_ACTIVITY = '[end]'

isobelKeen commented 11 months ago

Thanks!