Skip to content

Commit 4324164

Browse files
chore(formatting)[automatic]: formatting using black
1 parent f83e8fa commit 4324164

File tree

17 files changed

+96
-301
lines changed

17 files changed

+96
-301
lines changed

discopop_profiler/__init__.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@ def update_filemapping(self):
3535
# Do not regenerate if FileMapping.txt is still up-to-date.
3636
filemapping_mtime = os.stat("FileMapping.txt").st_mtime
3737
if os.stat(cwd).st_mtime < filemapping_mtime and all(
38-
[
39-
not entry.is_dir() or entry.stat().st_mtime < filemapping_mtime
40-
for entry in recursive_scandir(cwd)
41-
]
38+
[not entry.is_dir() or entry.stat().st_mtime < filemapping_mtime for entry in recursive_scandir(cwd)]
4239
):
4340
return
4441
logging.info("Generating FileMapping.txt.")

discopop_profiler/utils.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ def get_library(name: str) -> str:
3737

3838

3939
def is_compile(clang_args: List[str]) -> bool:
40-
return "-c" in clang_args or any(
41-
[re.match(r"^[^-].+\.(?:c|cc|cpp)$", arg) for arg in clang_args]
42-
)
40+
return "-c" in clang_args or any([re.match(r"^[^-].+\.(?:c|cc|cpp)$", arg) for arg in clang_args])
4341

4442

4543
def is_link(clang_args: List[str]) -> bool:

discopop_wizard/classes/CodePreview.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,7 @@ def show_in(self, parent_element: tk.Text):
9898
for line_idx, line in enumerate(self.lines):
9999
# offset line_id to account for start with 1
100100
offset_line_id = line_idx + 1
101-
cast(CodePreviewLine, line).display(
102-
self.wizard, parent_element, offset_line_id, self.max_line_num
103-
)
101+
cast(CodePreviewLine, line).display(self.wizard, parent_element, offset_line_id, self.max_line_num)
104102

105103
def jump_to_first_modification(self, parent_element: tk.Text):
106104
"""Jumps to the location of the first modified source code location."""

discopop_wizard/classes/Console.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ def __show_console(self):
5656
y_scrollbar = ttk.Scrollbar(self.parent_frame, command=self.log_screen.yview)
5757
y_scrollbar.grid(row=0, column=1, sticky="nsew")
5858
self.log_screen["yscrollcommand"] = y_scrollbar.set
59-
x_scrollbar = ttk.Scrollbar(
60-
self.parent_frame, orient="horizontal", command=self.log_screen.xview
61-
)
59+
x_scrollbar = ttk.Scrollbar(self.parent_frame, orient="horizontal", command=self.log_screen.xview)
6260
x_scrollbar.grid(row=1, column=0, columnspan=2, sticky="nsew")
6361
self.log_screen["xscrollcommand"] = x_scrollbar.set
6462

discopop_wizard/classes/ExecutionConfiguration.py

Lines changed: 23 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,10 @@ def __extract_values_from_help_string(self):
9393
self.value_dict[target_name + "_" + value_name] = ""
9494
# self.type_dict[target_name + "_" + value_name] = value_type
9595

96-
def get_as_button(
97-
self, wizard, main_screen_obj, parent_frame: tk.Frame, all_buttons: List[tk.Button]
98-
) -> tk.Button:
96+
def get_as_button(self, wizard, main_screen_obj, parent_frame: tk.Frame, all_buttons: List[tk.Button]) -> tk.Button:
9997
button = tk.Button(parent_frame, text=self.value_dict["label"])
10098
button.config(
101-
command=lambda: self.highlight_and_update_notebook_screens(
102-
wizard, main_screen_obj, button, all_buttons
103-
)
99+
command=lambda: self.highlight_and_update_notebook_screens(wizard, main_screen_obj, button, all_buttons)
104100
)
105101
self.button = button
106102
return button
@@ -129,12 +125,8 @@ def highlight_and_update_notebook_screens(
129125
self.show_details_screen(wizard, main_screen_obj)
130126

131127
# update results screen of pressed configuration button and set results tab state based on result existence
132-
main_screen_obj.notebook.tab(
133-
main_screen_obj.results_frame, state=self.__button_state_from_result_existence()
134-
)
135-
main_screen_obj.notebook.tab(
136-
main_screen_obj.optimizer_frame, state=self.__button_state_from_result_existence()
137-
)
128+
main_screen_obj.notebook.tab(main_screen_obj.results_frame, state=self.__button_state_from_result_existence())
129+
main_screen_obj.notebook.tab(main_screen_obj.optimizer_frame, state=self.__button_state_from_result_existence())
138130

139131
if self.__button_state_from_result_existence() == "normal":
140132
show_suggestions_overview_screen(wizard, main_screen_obj.results_frame, self)
@@ -153,69 +145,51 @@ def show_details_screen(self, wizard, main_screen_obj):
153145
canvas.grid(row=1)
154146

155147
# show labels
156-
tk.Label(
157-
canvas, text="Label:", justify=tk.RIGHT, anchor="e", font=wizard.style_font_bold_small
158-
).grid(row=1, column=1, sticky="ew")
159-
tk.Label(canvas, text="Description", justify=tk.RIGHT, anchor="e").grid(
160-
row=2, column=1, sticky="ew"
148+
tk.Label(canvas, text="Label:", justify=tk.RIGHT, anchor="e", font=wizard.style_font_bold_small).grid(
149+
row=1, column=1, sticky="ew"
161150
)
151+
tk.Label(canvas, text="Description", justify=tk.RIGHT, anchor="e").grid(row=2, column=1, sticky="ew")
162152
tk.Label(
163153
canvas,
164154
text="Executable name:",
165155
justify=tk.RIGHT,
166156
anchor="e",
167157
font=wizard.style_font_bold_small,
168158
).grid(row=3, column=1, sticky="ew")
169-
tk.Label(canvas, text="Executable arguments:", justify=tk.RIGHT, anchor="e").grid(
170-
row=4, column=1, sticky="ew"
171-
)
172-
tk.Label(canvas, text="Make flags:", justify=tk.RIGHT, anchor="e").grid(
173-
row=5, column=1, sticky="ew"
174-
)
159+
tk.Label(canvas, text="Executable arguments:", justify=tk.RIGHT, anchor="e").grid(row=4, column=1, sticky="ew")
160+
tk.Label(canvas, text="Make flags:", justify=tk.RIGHT, anchor="e").grid(row=5, column=1, sticky="ew")
175161
tk.Label(
176162
canvas,
177163
text="Project path:",
178164
justify=tk.RIGHT,
179165
anchor="e",
180166
font=wizard.style_font_bold_small,
181167
).grid(row=6, column=1, sticky="ew")
182-
tk.Label(canvas, text="Project linker flags:", justify=tk.RIGHT, anchor="e").grid(
183-
row=7, column=1, sticky="ew"
184-
)
185-
tk.Label(canvas, text="Make target:", justify=tk.RIGHT, anchor="e").grid(
186-
row=8, column=1, sticky="ew"
187-
)
168+
tk.Label(canvas, text="Project linker flags:", justify=tk.RIGHT, anchor="e").grid(row=7, column=1, sticky="ew")
169+
tk.Label(canvas, text="Make target:", justify=tk.RIGHT, anchor="e").grid(row=8, column=1, sticky="ew")
188170
tk.Label(
189171
canvas,
190172
text="Memory Profiling:",
191173
justify=tk.RIGHT,
192174
anchor="e",
193175
font=wizard.style_font_bold_small,
194176
).grid(row=9, column=1, sticky="ew")
195-
tk.Label(canvas, text="Skip function params:", justify=tk.RIGHT, anchor="e").grid(
196-
row=10, column=1, sticky="ew"
197-
)
177+
tk.Label(canvas, text="Skip function params:", justify=tk.RIGHT, anchor="e").grid(row=10, column=1, sticky="ew")
198178
tk.Label(
199179
canvas,
200180
text="Additional:",
201181
justify=tk.RIGHT,
202182
anchor="e",
203183
font=wizard.style_font_bold_small,
204184
).grid(row=11, column=1, sticky="ew")
205-
tk.Label(canvas, text="Tags:", justify=tk.RIGHT, anchor="e").grid(
206-
row=12, column=1, sticky="ew"
207-
)
208-
tk.Label(canvas, text="Notes:", justify=tk.RIGHT, anchor="e").grid(
209-
row=13, column=1, sticky="ew"
210-
)
185+
tk.Label(canvas, text="Tags:", justify=tk.RIGHT, anchor="e").grid(row=12, column=1, sticky="ew")
186+
tk.Label(canvas, text="Notes:", justify=tk.RIGHT, anchor="e").grid(row=13, column=1, sticky="ew")
211187

212188
# show input fields
213189
label = tk.Entry(canvas)
214190
label.grid(row=1, column=2, sticky="ew")
215191
label.insert(tk.END, self.value_dict["label"])
216-
create_tool_tip(
217-
label, "Name of the configuration. Used to distinguish configurations in the main menu."
218-
)
192+
create_tool_tip(label, "Name of the configuration. Used to distinguish configurations in the main menu.")
219193

220194
description = tk.Entry(canvas)
221195
description.grid(row=2, column=2, sticky="ew")
@@ -235,8 +209,7 @@ def show_details_screen(self, wizard, main_screen_obj):
235209
executable_args.insert(tk.END, self.value_dict["executable_arguments"])
236210
create_tool_tip(
237211
executable_args,
238-
"Specify arguments which shall be forwarded to the call of the created executable for the "
239-
"profiling.",
212+
"Specify arguments which shall be forwarded to the call of the created executable for the " "profiling.",
240213
)
241214

242215
make_flags = tk.Entry(canvas)
@@ -250,28 +223,23 @@ def show_details_screen(self, wizard, main_screen_obj):
250223
project_path = tk.Entry(canvas)
251224
project_path.grid(row=6, column=2, sticky="ew")
252225
project_path.insert(tk.END, self.value_dict["project_path"])
253-
create_tool_tip(
254-
project_path, "Path to the project which shall be analyzed for potential parallelism."
255-
)
226+
create_tool_tip(project_path, "Path to the project which shall be analyzed for potential parallelism.")
256227

257228
def overwrite_with_selection(target: tk.Entry):
258229
prompt_result = tk.filedialog.askdirectory()
259230
if len(prompt_result) != 0:
260231
target.delete(0, tk.END)
261232
target.insert(0, prompt_result)
262233

263-
project_path_selector = tk.Button(
264-
canvas, text="Select", command=lambda: overwrite_with_selection(project_path)
265-
)
234+
project_path_selector = tk.Button(canvas, text="Select", command=lambda: overwrite_with_selection(project_path))
266235
project_path_selector.grid(row=6, column=3)
267236

268237
project_linker_flags = tk.Entry(canvas)
269238
project_linker_flags.grid(row=7, column=2, sticky="ew")
270239
project_linker_flags.insert(tk.END, self.value_dict["linker_flags"])
271240
create_tool_tip(
272241
project_linker_flags,
273-
"Linker flags which need to be passed to the build system in order to create a valid "
274-
"executable.",
242+
"Linker flags which need to be passed to the build system in order to create a valid " "executable.",
275243
)
276244

277245
make_target = tk.Entry(canvas)
@@ -281,9 +249,7 @@ def overwrite_with_selection(target: tk.Entry):
281249

282250
mpsfp_var = tk.IntVar()
283251
mpsfp_var.set(self.value_dict["memory_profiling_skip_function_parameters"])
284-
memory_profiling_skip_function_parameters = tk.Checkbutton(
285-
canvas, onvalue=1, offvalue=0, variable=mpsfp_var
286-
)
252+
memory_profiling_skip_function_parameters = tk.Checkbutton(canvas, onvalue=1, offvalue=0, variable=mpsfp_var)
287253
memory_profiling_skip_function_parameters.grid(row=10, column=2, sticky="w")
288254
create_tool_tip(
289255
memory_profiling_skip_function_parameters,
@@ -415,9 +381,7 @@ def save_changes(
415381
self.value_dict["working_copy_path"] = self.value_dict["project_path"] + "/.discopop"
416382
self.value_dict["linker_flags"] = project_linker_flags.get()
417383
self.value_dict["make_target"] = make_target.get()
418-
self.value_dict[
419-
"memory_profiling_skip_function_parameters"
420-
] = memory_profiling_skip_function_parameters.get()
384+
self.value_dict["memory_profiling_skip_function_parameters"] = memory_profiling_skip_function_parameters.get()
421385
self.value_dict["tags"] = tags.get()
422386
self.value_dict["notes"] = additional_notes.get("1.0", tk.END)
423387

@@ -491,12 +455,8 @@ def execute_configuration(
491455
# create execution view and update results frame
492456
ExecutionView(self, wizard, main_screen_obj.results_frame)
493457
# set results tab state based on result existence
494-
main_screen_obj.notebook.tab(
495-
main_screen_obj.results_frame, state=self.__button_state_from_result_existence()
496-
)
497-
main_screen_obj.notebook.tab(
498-
main_screen_obj.optimizer_frame, state=self.__button_state_from_result_existence()
499-
)
458+
main_screen_obj.notebook.tab(main_screen_obj.results_frame, state=self.__button_state_from_result_existence())
459+
main_screen_obj.notebook.tab(main_screen_obj.optimizer_frame, state=self.__button_state_from_result_existence())
500460

501461
# show results tab
502462
main_screen_obj.notebook.select(main_screen_obj.results_frame)

discopop_wizard/classes/ProfilingContainer.py

Lines changed: 11 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,9 @@ def start(self):
2525
)
2626
self.__execute_command("docker kill discopop_container")
2727
self.__execute_command("docker rm discopop_container")
28-
exit_code = self.__execute_command(
29-
"docker build -t discopop_container " + docker_context_path
30-
)
28+
exit_code = self.__execute_command("docker build -t discopop_container " + docker_context_path)
3129
assert exit_code == 0
32-
exit_code = self.__execute_command(
33-
"docker run --name discopop_container -d -t discopop_container"
34-
)
30+
exit_code = self.__execute_command("docker run --name discopop_container -d -t discopop_container")
3531
assert exit_code == 0
3632

3733
def stop(self):
@@ -75,9 +71,7 @@ def copy_results_from_container(self, target_path: str, execution_view):
7571
def analyze_project(self, execution_view):
7672
# copy project folder to container. Note: mounting would be nicer but requires restarting the container.
7773
# might be a nicer solution in the long run, especially for larger projects
78-
self.copy_project_folder_to_container(
79-
execution_view.execution_configuration.value_dict["project_path"]
80-
)
74+
self.copy_project_folder_to_container(execution_view.execution_configuration.value_dict["project_path"])
8175

8276
# settings
8377
command = "/discopop/build/scripts/runDiscoPoP "
@@ -91,49 +85,25 @@ def analyze_project(self, execution_view):
9185
command += "--gllvm /software/go/bin "
9286
# execution configuration
9387
command += "--project /project "
94-
command += (
95-
'--linker-flags "'
96-
+ execution_view.execution_configuration.value_dict["linker_flags"]
97-
+ '" '
98-
)
99-
command += (
100-
'--executable-name "'
101-
+ execution_view.execution_configuration.value_dict["executable_name"]
102-
+ '" '
103-
)
88+
command += '--linker-flags "' + execution_view.execution_configuration.value_dict["linker_flags"] + '" '
89+
command += '--executable-name "' + execution_view.execution_configuration.value_dict["executable_name"] + '" '
10490
command += (
10591
'--executable-arguments "'
10692
+ execution_view.execution_configuration.value_dict["executable_arguments"]
10793
+ '" '
10894
)
109-
command += (
110-
'--make-flags "'
111-
+ execution_view.execution_configuration.value_dict["make_flags"]
112-
+ '" '
113-
)
114-
command += (
115-
'--make-target "'
116-
+ execution_view.execution_configuration.value_dict["make_target"]
117-
+ '" '
118-
)
119-
command += (
120-
'--explorer-flags "'
121-
+ execution_view.execution_configuration.value_dict["explorer_flags"]
122-
+ '" '
123-
)
95+
command += '--make-flags "' + execution_view.execution_configuration.value_dict["make_flags"] + '" '
96+
command += '--make-target "' + execution_view.execution_configuration.value_dict["make_target"] + '" '
97+
command += '--explorer-flags "' + execution_view.execution_configuration.value_dict["explorer_flags"] + '" '
12498

12599
self.__execute_command("docker exec -it discopop_container " + command)
126100

127101
# copy results from container into working copy path
128-
if not os.path.exists(
129-
execution_view.execution_configuration.value_dict["working_copy_path"]
130-
):
102+
if not os.path.exists(execution_view.execution_configuration.value_dict["working_copy_path"]):
131103
os.mkdir(execution_view.execution_configuration.value_dict["working_copy_path"])
132104

133105
# remove previous results
134-
self.remove_previous_results(
135-
execution_view.execution_configuration.value_dict["working_copy_path"]
136-
)
106+
self.remove_previous_results(execution_view.execution_configuration.value_dict["working_copy_path"])
137107

138108
# copy results from container
139109
self.copy_results_from_container(
@@ -157,9 +127,7 @@ def __correct_file_mapping_paths(self, execution_view):
157127
file.write(contents)
158128

159129
def __execute_command(self, command: str) -> int:
160-
with subprocess.Popen(
161-
command, stdout=subprocess.PIPE, bufsize=1, universal_newlines=True, shell=True
162-
) as p:
130+
with subprocess.Popen(command, stdout=subprocess.PIPE, bufsize=1, universal_newlines=True, shell=True) as p:
163131
if p.stdout is None:
164132
print("executing command was not successfull")
165133
else:

discopop_wizard/classes/Settings.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ class Settings(object):
3333
code_preview_show_line_numbers: int = 1 # 1 = True, 0 = False
3434
code_preview_disable_compile_check: int = 0 # 1 = True, 0 = False
3535

36-
def __init__(
37-
self, discopop_build_dir="", go_bin_dir="", use_docker_container: bool = True
38-
) -> None:
36+
def __init__(self, discopop_build_dir="", go_bin_dir="", use_docker_container: bool = True) -> None:
3937
self.discopop_build_dir = discopop_build_dir
4038
self.go_bin = go_bin_dir
4139
self.use_docker_container_for_profiling = use_docker_container
@@ -45,11 +43,7 @@ def __init__(
4543
# get llvm_bin_dir from stored build configuration
4644
llvm_bin_dir = ""
4745
if settings_valid:
48-
command = (
49-
"cat "
50-
+ self.discopop_build_dir
51-
+ '/build_config.txt | grep -oP "(?<=LLVM_BIN_DIR=).*"'
52-
)
46+
command = "cat " + self.discopop_build_dir + '/build_config.txt | grep -oP "(?<=LLVM_BIN_DIR=).*"'
5347
llvm_bin_dir = os.popen(command).read().replace("\n", "")
5448
if not os.path.exists(llvm_bin_dir):
5549
llvm_bin_dir = ""
@@ -143,9 +137,7 @@ def load_from_config_file(config_dir: str) -> Settings:
143137
settings.code_preview_show_metadata_regions = __load_or_get_default(
144138
value_dict, "code_preview_show_metadata_regions"
145139
)
146-
settings.code_preview_show_line_numbers = __load_or_get_default(
147-
value_dict, "code_preview_show_line_numbers"
148-
)
140+
settings.code_preview_show_line_numbers = __load_or_get_default(value_dict, "code_preview_show_line_numbers")
149141
settings.code_preview_show_metadata_live_device_variables = __load_or_get_default(
150142
value_dict, "code_preview_show_metadata_live_device_variables"
151143
)

0 commit comments

Comments
 (0)