Skip to content

Commit

Permalink
Merge pull request #40 from Process-Discovery-Log-Skeleton/csv-fix
Browse files Browse the repository at this point in the history
🚑 CSV import fix.
  • Loading branch information
quangtinator authored Jan 10, 2021
2 parents acfd30e + 0ae894b commit 9b02c4e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
9 changes: 5 additions & 4 deletions src/api/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
EVENT_LOG = 'event-log'
FILE = 'file'
CASE_ID = 'case-id'
EVENT_ID = 'event-id'
CASE_PREFIX = 'case-prefix'

ALLOWED_EXTENSIONS = {'xes', 'csv'}

Expand Down Expand Up @@ -96,10 +96,10 @@ def event_log():
}), __BAD_REQUEST__

caseID = request.args.get(CASE_ID)
eventID = request.args.get(EVENT_ID)
casePrefix = request.args.get(CASE_PREFIX)

try:
id = put_event_log(file, caseID, eventID)
id = put_event_log(file, caseID, casePrefix)

importer = XES_Importer()

Expand All @@ -112,7 +112,8 @@ def event_log():
'id': id,
'activities': list(activities)
})
except: # noqa: E722
except Error as e: # noqa: E722
print(e)
return jsonify({
'error': "Could not import file."
}), __BAD_REQUEST__
Expand Down
8 changes: 4 additions & 4 deletions src/components/util/event_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def put_event_log_str(content) -> str:
return id


def put_event_log(file, caseID, eventID) -> str:
def put_event_log(file, caseID, casePrefix) -> str:
"""Cache the event log."""
id = uuid.uuid4().hex

Expand All @@ -112,15 +112,15 @@ def put_event_log(file, caseID, eventID) -> str:
if caseID is None:
raise CaseIdNotFoundError

if eventID is None:
raise EventIdNotFoundError
if casePrefix is None:
casePrefix = 'case:'

log_csv = pd.read_csv(path, sep=',')
# log_csv.rename(columns={'clientID': 'case:clientID'}, inplace=True)
parameters = {log_conv.Variants.
TO_EVENT_LOG.value.Parameters.CASE_ID_KEY: caseID,
log_conv.Variants.TO_EVENT_LOG.value.
Parameters.CASE_ATTRIBUTE_PREFIX: eventID}
Parameters.CASE_ATTRIBUTE_PREFIX: casePrefix}
event_log = log_conv.apply(log_csv,
parameters=parameters,
variant=log_conv.Variants.TO_EVENT_LOG)
Expand Down

0 comments on commit 9b02c4e

Please sign in to comment.