Skip to content

Commit

Permalink
Merge pull request #14 from rwth-acis/release/0.1.10
Browse files Browse the repository at this point in the history
Add deserialize_remarks parameter to generateXESfile and generate_eventlog functions
  • Loading branch information
lakhoune authored Feb 27, 2024
2 parents 6fa4eb0 + 8c67d18 commit 0433de2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def send_xml_file_for_bot(botName):
app.run(port=port, debug=True)


def generateXESfile(db_connection, start_date=None, end_date=None, resource_ids=None, include_bot_messages=False, include_life_cycle_start=False):
def generateXESfile(db_connection, start_date=None, end_date=None, resource_ids=None, include_bot_messages=False, include_life_cycle_start=False,deserialize_remarks=False):
"""
This function generates an XES file from the events in the database
Expand Down Expand Up @@ -205,7 +205,7 @@ def generateXESfile(db_connection, start_date=None, end_date=None, resource_ids=
if not os.path.exists(os.path.join(current_dir, 'event_logs')):
os.makedirs(os.path.join(current_dir, 'event_logs'))
event_log = generate_eventlog(db_connection, start_date, end_date, resource_ids,
include_bot_messages=include_bot_messages, include_life_cycle_start=include_life_cycle_start)
include_bot_messages=include_bot_messages, include_life_cycle_start=include_life_cycle_start,deserialize_remarks=deserialize_remarks)
if event_log is None or event_log.empty:
logger.info('No events found for resource ids: '+str(resource_ids))
return None
Expand Down
6 changes: 4 additions & 2 deletions event_log_generator/event_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# pip install dogpile.cache for caching the sql results


def generate_eventlog(db_connection, start_date=None, end_date=None, resource_ids=None, include_bot_messages=False, include_life_cycle_start=False):
def generate_eventlog(db_connection, start_date=None, end_date=None, resource_ids=None, include_bot_messages=False, include_life_cycle_start=False, deserialize_remarks=False):
df = _read_events_into_df(db_connection, start_date, end_date, resource_ids,
include_bot_messages=include_bot_messages, include_life_cycle_start=include_life_cycle_start)

Expand All @@ -29,7 +29,8 @@ def generate_eventlog(db_connection, start_date=None, end_date=None, resource_id
end_date = df['time:timestamp'].max().strftime('%Y-%m-%d')

# extract fields from remarks column
df = df.apply(_extract_remarks, axis=1)
if deserialize_remarks:
df = df.apply(_extract_remarks, axis=1)
if ('lifecycle:transition' in df.columns):
df.loc[:, ['lifecycle:transition']] = df[[
'lifecycle:transition']].fillna('complete')
Expand Down Expand Up @@ -69,6 +70,7 @@ def _read_events_into_df(db_connection, start_date=None, end_date=None, resource

df = pd.read_sql(statement, con=db_connection,
params=params)
print(f'Read {len(df)} events from database')
df.rename(columns={'CASE_ID': 'case:concept:name', 'ACTIVITY_NAME': 'concept:name',
'TIME_STAMP': 'time:timestamp', 'LIFECYCLE_PHASE': 'lifecycle:transition'}, inplace=True)
# convert time:timestamp to datetime
Expand Down
2 changes: 1 addition & 1 deletion event_log_generator/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='event_reader',
version='0.1.9',
version='0.1.10',
description='A package to read events from a database using SQLAlchemy and Pandas',
author='Ben Lakhoune',
author_email='[email protected]',
Expand Down

0 comments on commit 0433de2

Please sign in to comment.