Skip to content

Commit 8b83725

Browse files
authored
Merge pull request #10 from EvoTestOps/directory-path-improvements
Directory path improvements
2 parents c2c2cdf + 32a0391 commit 8b83725

131 files changed

Lines changed: 282185 additions & 46 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
test_data
2-
log_data
2+
3+
log_data/*
4+
!log_data/LO2/
5+
36
output
47
__pycache__/
58
.env

dash_app/callbacks/callback_functions.py

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ def run_anomaly_detection(
8181
test_data,
8282
detectors,
8383
enhancement,
84-
include_items,
84+
include_test_items,
85+
include_train_items,
8586
mask_type,
8687
vectorizer_type,
8788
analysis_name=None,
@@ -94,7 +95,8 @@ def run_anomaly_detection(
9495
log_format,
9596
detectors,
9697
enhancement,
97-
include_items,
98+
include_test_items,
99+
include_train_items,
98100
mask_type,
99101
vectorizer_type,
100102
analysis_name,
@@ -215,8 +217,9 @@ def fetch_project_name(project_id: int) -> str:
215217
return response.json().get("name", "404")
216218

217219

218-
def get_log_data_directory_options():
219-
labels, values = get_all_root_log_directories()
220+
def get_log_data_directory_options(project_id: int):
221+
base_path = _fetch_project_base_path(project_id).get("base_path")
222+
labels, values = get_all_root_log_directories(base_path)
220223
return [{"label": lab, "value": val} for (lab, val) in zip(labels, values)]
221224

222225

@@ -238,6 +241,15 @@ def fetch_project_settings(project_id: int) -> dict:
238241
return response.json()
239242

240243

244+
def _fetch_project_base_path(project_id: int) -> dict:
245+
response, error = make_api_call({}, f"projects/{project_id}/base_path", "GET")
246+
if error or response is None:
247+
raise ValueError(
248+
f"Was not able to retrieve base_path for project id {project_id}: {error}"
249+
)
250+
return response.json()
251+
252+
241253
def _fetch_analysis_results(analysis_id: int) -> bytes:
242254
response, error = make_api_call({}, f"analyses/{analysis_id}", "GET")
243255
if error or response is None:
@@ -264,7 +276,8 @@ def _build_test_train_payload(
264276
log_format,
265277
detectors,
266278
enhancement,
267-
include_items,
279+
include_test_items,
280+
include_train_items,
268281
mask_type,
269282
vectorizer_type,
270283
analysis_name,
@@ -282,17 +295,20 @@ def _build_test_train_payload(
282295
}
283296

284297
if level == "directory":
285-
payload["runs_to_include"] = include_items
298+
payload["runs_to_include"] = include_test_items
299+
payload["runs_to_include_train"] = include_train_items
286300
payload["run_level"] = True
287301
elif level == "file":
288-
payload["files_to_include"] = include_items
302+
payload["files_to_include"] = include_test_items
303+
payload["files_to_include_train"] = include_train_items
289304
payload["file_level"] = True
290305
elif level == "line":
291-
payload["runs_to_include"] = include_items
306+
payload["runs_to_include"] = include_test_items
307+
payload["runs_to_include_train"] = include_train_items
292308
payload["file_level"] = False
293309
payload["run_level"] = False
294310
else:
295-
raise ValueError("Level must be either 'file' or 'directory'")
311+
raise ValueError("Level must be 'line', 'file' or 'directory'")
296312

297313
return payload
298314

dash_app/components/form_inputs.py

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def delete_button(id, label):
9393
)
9494

9595

96-
def runs_filter_input(id, manual=False):
96+
def runs_filter_input(id, label=None, manual=False):
9797
if manual:
9898
return dbc.Col(
9999
[
@@ -111,7 +111,11 @@ def runs_filter_input(id, manual=False):
111111
)
112112
return dbc.Col(
113113
[
114-
dbc.Label("Runs to include in test data", html_for=id, width="auto"),
114+
dbc.Label(
115+
label if label else "Directories to include in test data",
116+
html_for=id,
117+
width="auto",
118+
),
115119
dcc.Dropdown(
116120
multi=True,
117121
id=id,
@@ -124,12 +128,12 @@ def runs_filter_input(id, manual=False):
124128
)
125129

126130

127-
def files_filter_input(id, manual=False):
131+
def files_filter_input(id, label=None, manual=False):
128132
if manual:
129133
return dbc.Col(
130134
[
131135
dbc.Label(
132-
"Files to include in test data (manual, comma-separated)",
136+
f"{label if label else 'Files to include in test data'} (manual, comma-separated)",
133137
html_for=id,
134138
width="auto",
135139
),
@@ -142,7 +146,11 @@ def files_filter_input(id, manual=False):
142146
)
143147
return dbc.Col(
144148
[
145-
dbc.Label("Files to include in test data", html_for=id, width="auto"),
149+
dbc.Label(
150+
label if label else "Files to include in test data",
151+
html_for=id,
152+
width="auto",
153+
),
146154
dcc.Dropdown(
147155
multi=True,
148156
id=id,
@@ -405,3 +413,28 @@ def analysis_name_input(id):
405413
dbc.Input(id=id, placeholder="Optional", type="text"),
406414
],
407415
)
416+
417+
418+
def base_path_input(id):
419+
label_id = f"{id}-label"
420+
return dbc.Col(
421+
[
422+
dbc.Label(
423+
"Base path",
424+
id=label_id,
425+
html_for=id,
426+
width="auto",
427+
style={"textDecoration": "underline", "cursor": "pointer"},
428+
),
429+
dbc.Tooltip(
430+
"Optional. Must be directory inside log_data/. Leave empty or unchanged to use the default. Directory must already exist.",
431+
target=label_id,
432+
placement="bottom",
433+
),
434+
dbc.Input(
435+
id=id,
436+
type="text",
437+
value="./log_data",
438+
),
439+
],
440+
)

dash_app/components/forms.py

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
files_to_include_input,
2323
columns_to_include_input,
2424
analysis_name_input,
25+
base_path_input,
2526
)
2627

2728

@@ -32,6 +33,7 @@ def test_train_form(
3233
detectors_id,
3334
enhancement_id,
3435
runs_filter_id,
36+
runs_filter_train_id,
3537
mask_input_id,
3638
vectorizer_id,
3739
results_redirect_id,
@@ -61,15 +63,24 @@ def test_train_form(
6163
),
6264
dbc.Row(
6365
[
64-
detectors_unsupervised_input(detectors_id),
66+
runs_filter_input(
67+
id=runs_filter_train_id,
68+
label="Directories to include in train data",
69+
),
6570
runs_filter_input(runs_filter_id),
6671
],
6772
class_name="mb-3",
6873
),
6974
dbc.Row(
7075
[
71-
enhancement_input(enhancement_id),
76+
detectors_unsupervised_input(detectors_id),
7277
vectorizer_input(vectorizer_id),
78+
],
79+
class_name="mb-3",
80+
),
81+
dbc.Row(
82+
[
83+
enhancement_input(enhancement_id),
7384
mask_input(mask_input_id),
7485
],
7586
class_name="mb-3",
@@ -90,6 +101,7 @@ def test_train_file_level_form(
90101
detectors_id,
91102
enhancement_id,
92103
runs_filter_id,
104+
runs_filter_train_id,
93105
mask_input_id,
94106
vectorizer_id,
95107
results_redirect_id,
@@ -122,6 +134,20 @@ def test_train_file_level_form(
122134
],
123135
class_name="mb-3",
124136
),
137+
dbc.Row(
138+
dcc.Loading(
139+
type="circle",
140+
overlay_style={"visibility": "visible", "filter": "blur(2px)"},
141+
children=[
142+
files_filter_input(
143+
runs_filter_train_id,
144+
label="Files to include in train data",
145+
manual=manual_filenames,
146+
),
147+
],
148+
),
149+
class_name="mb-3",
150+
),
125151
dbc.Row(
126152
dcc.Loading(
127153
type="circle",
@@ -340,13 +366,14 @@ def distance_file_level_form(
340366
return form
341367

342368

343-
def project_form(submit_id, name_id):
369+
def project_form(submit_id, name_id, base_path_id):
344370
submit_btn = submit_button(submit_id, "Create")
345371
form = dbc.Form(
346372
[
347373
dbc.Row(
348374
[
349-
name_input((name_id)),
375+
dbc.Col(name_input((name_id))),
376+
dbc.Col(base_path_input((base_path_id))),
350377
dbc.Col(
351378
submit_btn,
352379
class_name="d-flex justify-content-end align-middle align-items-end",

dash_app/components/layouts.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ def create_project_layout(
377377

378378
task_error_modal = dbc.Row(dbc.Modal(id=task_error_modal_id, is_open=False))
379379
task_logs_modal = dbc.Row(
380-
dbc.Modal(id=task_logs_modal_id, size="lg", is_open=False)
380+
dbc.Modal(id=task_logs_modal_id, size="xl", is_open=False)
381381
)
382382

383383
analysis_edit_name_modal = dbc.Row(
@@ -454,7 +454,7 @@ def create_high_level_viz_result_layout(
454454

455455
layout = [
456456
dbc.Container([table_row, error_toast_row, success_toast_row]),
457-
dbc.Container(plot_row, fluid=True),
457+
dbc.Container(plot_row, fluid=True, style={"paddingBottom": "200px"}),
458458
]
459459

460460
return layout

dash_app/page_templates/new_analysis_page_base.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,20 +103,20 @@ def get_project_id(search):
103103

104104
@callback(
105105
Output(form_ids["directory_id"], "options"),
106-
Input(base_ids["url_id"], "search"),
106+
Input(base_ids["project_store_id"], "data"),
107107
)
108-
def get_log_data_directories(_):
109-
return get_log_data_directory_options()
108+
def get_log_data_directories(project_id):
109+
return get_log_data_directory_options(project_id)
110110

111111
else:
112112

113113
@callback(
114114
Output(form_ids["train_data_id"], "options"),
115115
Output(form_ids["test_data_id"], "options"),
116-
Input(base_ids["url_id"], "search"),
116+
Input(base_ids["project_store_id"], "data"),
117117
)
118-
def get_log_data_directories(_):
119-
options = get_log_data_directory_options()
118+
def get_log_data_directories(project_id):
119+
options = get_log_data_directory_options(project_id)
120120
return options, options
121121

122122
if (
@@ -144,15 +144,24 @@ def get_comparison_and_target_options(directory_path, manual_filenames):
144144

145145
@callback(
146146
Output(form_ids["runs_filter_id"], "options"),
147+
Output(form_ids["runs_filter_train_id"], "options"),
147148
Input(form_ids["test_data_id"], "value"),
149+
Input(form_ids["train_data_id"], "value"),
148150
State(base_ids["manual_filenames_id"], "data"),
149151
)
150-
def get_comparison_options(directory_path, manual_filenames):
152+
def get_comparison_options(dir_path_test, dir_path_train, manual_filenames):
151153
if manual_filenames:
152154
return [], []
153155
runs_or_files = "files" if config["level"] == "file" else "runs"
154-
options = get_filter_options(directory_path, runs_or_files=runs_or_files)
155-
return options
156+
157+
options_test = get_filter_options(
158+
dir_path_test, runs_or_files=runs_or_files
159+
)
160+
options_train = get_filter_options(
161+
dir_path_train, runs_or_files=runs_or_files
162+
)
163+
164+
return options_test, options_train
156165

157166
@callback(
158167
Output(base_ids["error_toast_id"], "children", allow_duplicate=True),

dash_app/pages/create_analysis_pages/new_ano_directory_level.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"detectors_id": "detectors-ano-dir-new",
2929
"enhancement_id": "enhancement-ano-dir-new",
3030
"runs_filter_id": "filter-ano-dir-new",
31+
"runs_filter_train_id": "filter-train-ano-dir-new",
3132
"mask_input_id": "mask-ano-dir-new",
3233
"vectorizer_id": "vectorizer-ano-dir-new",
3334
"results_redirect_id": "results-redirect-ano-dir-new",
@@ -39,6 +40,7 @@
3940
"detectors_id",
4041
"enhancement_id",
4142
"runs_filter_id",
43+
"runs_filter_train_id",
4244
"mask_input_id",
4345
"vectorizer_id",
4446
"results_redirect_id",

dash_app/pages/create_analysis_pages/new_ano_file_level.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"detectors_id": "detectors-ano-file-new",
3232
"enhancement_id": "enhancement-ano-file-new",
3333
"runs_filter_id": "filter-ano-file-new",
34+
"runs_filter_train_id": "filter-train-ano-file-new",
3435
"mask_input_id": "mask-ano-file-new",
3536
"vectorizer_id": "vectorizer-ano-file-new",
3637
"results_redirect_id": "results-redirect-ano-file-new",
@@ -42,6 +43,7 @@
4243
"detectors_id",
4344
"enhancement_id",
4445
"runs_filter_id",
46+
"runs_filter_train_id",
4547
"mask_input_id",
4648
"vectorizer_id",
4749
"results_redirect_id",

dash_app/pages/create_analysis_pages/new_ano_line_level.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"detectors_id": "detectors-ano-line-new",
2929
"enhancement_id": "enhancement-ano-line-new",
3030
"runs_filter_id": "filter-ano-line-new",
31+
"runs_filter_train_id": "filter-train-ano-line-new",
3132
"mask_input_id": "mask-ano-line-new",
3233
"vectorizer_id": "vectorizer-ano-line-new",
3334
"results_redirect_id": "results-redirect-ano-line-new",
@@ -39,6 +40,7 @@
3940
"detectors_id",
4041
"enhancement_id",
4142
"runs_filter_id",
43+
"runs_filter_train_id",
4244
"mask_input_id",
4345
"vectorizer_id",
4446
"results_redirect_id",

0 commit comments

Comments
 (0)