Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Process Graph Extraction From Recording Using pm4py #852

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
243 changes: 243 additions & 0 deletions openadapt/process-graph/dataout.csv

Large diffs are not rendered by default.

3,504 changes: 3,504 additions & 0 deletions openadapt/process-graph/output/tmpkbsu9k18.html

Large diffs are not rendered by default.

Large diffs are not rendered by default.

206 changes: 206 additions & 0 deletions openadapt/process-graph/output/tmpkbsu9k18_files/viz.js.download

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions openadapt/process-graph/process-query.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
SELECT
R.ID AS "case_id",
'Title: ' || WE.TITLE || ', Action: ' || AE.NAME || ', Action_Target: ' ||
CASE
WHEN AE.NAME = 'scroll' THEN '(' || AE.mouse_dx || ',' || AE.mouse_dy || ')'
WHEN AE.NAME = 'move' THEN '(' || AE.mouse_x || ',' || AE.mouse_y || ')'
WHEN AE.NAME = 'click' THEN AE.mouse_button_name
WHEN AE.NAME IN ('press', 'release') THEN AE.CANONICAL_KEY_NAME
ELSE 'N/A'
END AS "activity",
DATETIME(AE."timestamp", 'unixepoch', 'localtime') AS "timestamp",
COALESCE(AE."timestamp" - LAG(AE."timestamp") OVER (ORDER BY AE."timestamp"), 0) AS "costs",
AE.NAME AS "resource"
FROM
RECORDING R
INNER JOIN ACTION_EVENT AE ON R."timestamp" = AE.RECORDING_TIMESTAMP
INNER JOIN WINDOW_EVENT WE ON R."timestamp" = WE.RECORDING_TIMESTAMP AND WE."timestamp" = AE.WINDOW_EVENT_TIMESTAMP
WHERE
R.ID = 1
ORDER BY
R.ID,
AE."timestamp";
18 changes: 18 additions & 0 deletions openadapt/process-graph/process_graph_generation_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""Example of process graph generation using PM4Py library."""

import pm4py
import pandas


if __name__ == "__main__":
log = pandas.read_csv("dataout.csv", sep=",")
log = pm4py.format_dataframe(
log,
case_id="case_id",
activity_key="activity",
timestamp_key="timestamp",
timest_format="%Y-%m-%d %H:%M:%S",
)

dfg, start_activities, end_activities = pm4py.discover_dfg(log)
pm4py.view_dfg(dfg, start_activities, end_activities, format="html")
43 changes: 43 additions & 0 deletions openadapt/process-graph/running-example.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
case_id;activity;timestamp;costs;resource
3;register request;2010-12-30 14:32:00+01:00;50;Pete
3;examine casually;2010-12-30 15:06:00+01:00;400;Mike
3;check ticket;2010-12-30 16:34:00+01:00;100;Ellen
3;decide;2011-01-06 09:18:00+01:00;200;Sara
3;reinitiate request;2011-01-06 12:18:00+01:00;200;Sara
3;examine thoroughly;2011-01-06 13:06:00+01:00;400;Sean
3;check ticket;2011-01-08 11:43:00+01:00;100;Pete
3;decide;2011-01-09 09:55:00+01:00;200;Sara
3;pay compensation;2011-01-15 10:45:00+01:00;200;Ellen
2;register request;2010-12-30 11:32:00+01:00;50;Mike
2;check ticket;2010-12-30 12:12:00+01:00;100;Mike
2;examine casually;2010-12-30 14:16:00+01:00;400;Sean
2;decide;2011-01-05 11:22:00+01:00;200;Sara
2;pay compensation;2011-01-08 12:05:00+01:00;200;Ellen
1;register request;2010-12-30 11:02:00+01:00;50;Pete
1;examine thoroughly;2010-12-31 10:06:00+01:00;400;Sue
1;check ticket;2011-01-05 15:12:00+01:00;100;Mike
1;decide;2011-01-06 11:18:00+01:00;200;Sara
1;reject request;2011-01-07 14:24:00+01:00;200;Pete
6;register request;2011-01-06 15:02:00+01:00;50;Mike
6;examine casually;2011-01-06 16:06:00+01:00;400;Ellen
6;check ticket;2011-01-07 16:22:00+01:00;100;Mike
6;decide;2011-01-07 16:52:00+01:00;200;Sara
6;pay compensation;2011-01-16 11:47:00+01:00;200;Mike
5;register request;2011-01-06 09:02:00+01:00;50;Ellen
5;examine casually;2011-01-07 10:16:00+01:00;400;Mike
5;check ticket;2011-01-08 11:22:00+01:00;100;Pete
5;decide;2011-01-10 13:28:00+01:00;200;Sara
5;reinitiate request;2011-01-11 16:18:00+01:00;200;Sara
5;check ticket;2011-01-14 14:33:00+01:00;100;Ellen
5;examine casually;2011-01-16 15:50:00+01:00;400;Mike
5;decide;2011-01-19 11:18:00+01:00;200;Sara
5;reinitiate request;2011-01-20 12:48:00+01:00;200;Sara
5;examine casually;2011-01-21 09:06:00+01:00;400;Sue
5;check ticket;2011-01-21 11:34:00+01:00;100;Pete
5;decide;2011-01-23 13:12:00+01:00;200;Sara
5;reject request;2011-01-24 14:56:00+01:00;200;Mike
4;register request;2011-01-06 15:02:00+01:00;50;Pete
4;check ticket;2011-01-07 12:06:00+01:00;100;Mike
4;examine thoroughly;2011-01-08 14:43:00+01:00;400;Sean
4;decide;2011-01-09 12:02:00+01:00;200;Sara
4;reject request;2011-01-12 15:44:00+01:00;200;Ellen
23 changes: 23 additions & 0 deletions openadapt/process-graph/test_file.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
id|name|timestamp|recording_timestamp|screenshot_timestamp|window_event_timestamp|browser_event_timestamp|mouse_x|mouse_y|mouse_dx|mouse_dy|mouse_button_name|mouse_pressed|key_name|key_char|key_vk|canonical_key_name|canonical_key_char|canonical_key_vk|parent_id|element_state|active_segment_description|available_segment_descriptions|recording_id|screenshot_id|window_event_id|browser_event_id|scrubbed_text|scrubbed_canonical_text|disabled
1|move|1721000458.7605|1721000269.22083|1721000458.7053|1721000389.26989|1721000458.49984|709|823||||||||||||{}|||1|1|1|1|||
2|move|1721000458.76715|1721000269.22083|1721000458.7053|1721000389.26989|1721000458.49984|711|823||||||||||||{}|||1|1|1|1|||
...
224|move|1721000459.81649|1721000269.22083|1721000459.61459|1721000389.26989|1721000459.35587|2140|707||||||||||||{}|||1|4|1|3|||
225|click|1721000459.96644|1721000269.22083|1721000459.83566|1721000389.26989|1721000459.35587|2140|707|||left|1||||||||{}|||1|5|1|3|||
226|click|1721000460.10897|1721000269.22083|1721000459.83566|1721000389.26989|1721000459.35587|2140|707|||left|0||||||||{}|||1|5|1|3|||
227|scroll|1721000462.34067|1721000269.22083|1721000462.30201|1721000389.26989|1721000459.35587|2140|707|0|1||||||||||{}|||1|6|1|3|||
228|scroll|1721000462.44121|1721000269.22083|1721000462.30201|1721000389.26989|1721000459.35587|2140|707|0|1||||||||||{}|||1|6|1|3|||
229|scroll|1721000462.51473|1721000269.22083|1721000462.30201|1721000389.26989|1721000459.35587|2140|707|0|1||||||||||{}|||1|6|1|3|||
230|scroll|1721000464.28353|1721000269.22083|1721000464.23076|1721000389.26989|1721000459.35587|2140|707|0|-1||||||||||{}|||1|7|1|3|||
231|scroll|1721000464.32584|1721000269.22083|1721000464.23076|1721000389.26989|1721000459.35587|2140|707|0|-1||||||||||{}|||1|7|1|3|||
232|scroll|1721000464.38393|1721000269.22083|1721000464.23076|1721000389.26989|1721000459.35587|2140|707|0|-1||||||||||{}|||1|7|1|3|||
233|scroll|1721000464.4249|1721000269.22083|1721000464.23076|1721000389.26989|1721000459.35587|2140|707|0|-1||||||||||{}|||1|7|1|3|||
234|scroll|1721000464.8567|1721000269.22083|1721000464.80535|1721000389.26989|1721000459.35587|2140|707|0|-1||||||||||{}|||1|8|1|3|||
235|scroll|1721000464.90082|1721000269.22083|1721000464.80535|1721000389.26989|1721000459.35587|2140|707|0|-1||||||||||{}|||1|8|1|3|||
236|scroll|1721000464.98693|1721000269.22083|1721000464.80535|1721000389.26989|1721000459.35587|2140|707|0|-1||||||||||{}|||1|8|1|3|||
237|press|1721000466.65328|1721000269.22083|1721000466.5767|1721000389.26989|1721000459.35587|||||||ctrl_l|||ctrl||||null|||1|9|1|3|||
238|release|1721000466.67938|1721000269.22083|1721000466.5767|1721000389.26989|1721000459.35587|||||||ctrl_l|||ctrl||||null|||1|9|1|3|||
239|press|1721000466.75233|1721000269.22083|1721000466.5767|1721000389.26989|1721000459.35587|||||||ctrl_l|||ctrl||||null|||1|9|1|3|||
240|release|1721000466.81699|1721000269.22083|1721000466.5767|1721000389.26989|1721000459.35587|||||||ctrl_l|||ctrl||||null|||1|9|1|3|||
241|press|1721000466.89113|1721000269.22083|1721000466.82308|1721000389.26989|1721000459.35587|||||||ctrl_l|||ctrl||||null|||1|10|1|3|||
242|release|1721000466.9815|1721000269.22083|1721000466.82308|1721000389.26989|1721000459.35587|||||||ctrl_l|||ctrl||||null|||1|10|1|3|||
132 changes: 129 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ posthog = "^3.5.0"

wheel = "^0.43.0"
cython = "^3.0.10"
pm4py = "^2.7.11.11"
[tool.pytest.ini_options]
filterwarnings = [
# suppress warnings starting from "setuptools>=67.3"
Expand Down
Loading