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

Generate log files for Python Profiling cli #1366

Merged
merged 1 commit into from
Oct 3, 2024
Merged
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
7 changes: 2 additions & 5 deletions user_tools/src/spark_rapids_pytools/common/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def get_and_setup_logger(cls, type_label: str, debug_mode: bool = False):
return logger

@classmethod
def modify_log4j_properties(cls, prop_file_path: str, new_log_dir: str) -> str:
def modify_log4j_properties(cls, prop_file_path: str, new_log_file: str) -> str:
"""
Modifies the log file path in a log4j properties file to redirect logging output to a new location.

Expand All @@ -242,15 +242,12 @@ def modify_log4j_properties(cls, prop_file_path: str, new_log_dir: str) -> str:

:param prop_file_path: The file path to the original log4j.properties file. This file
should contain configurations for the log4j logging utility.
:param new_log_dir: The base output directory where the new log file will be created.
The actual log file named 'rapids_4_spark_qualification_stderr.log'
will be placed in this directory.
:param new_log_file: The file path where the logging output is saved.

:return str: The file path to the temporary modified log4j.properties file.
This temporary file retains the modifications and can be accessed until
explicitly deleted after the java process is completed.
"""
new_log_file = f'{new_log_dir}/rapids_4_spark_qualification_stderr.log'
with open(prop_file_path, 'r', encoding='utf-8') as file:
lines = file.readlines()

Expand Down
3 changes: 2 additions & 1 deletion user_tools/src/spark_rapids_pytools/rapids/rapids_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,9 @@ def _build_jvm_args(self):
if jvm_k.startswith('D'):
if jvm_k == 'Dlog4j.configuration':
rapids_output_folder = self.exec_ctxt.get_rapids_output_folder()
log4j_file_name = self.exec_ctxt.get_log4j_properties_file()
jvm_arg = ToolLogging.modify_log4j_properties(
jvm_arg, f'{rapids_output_folder}')
jvm_arg, f'{rapids_output_folder}/{log4j_file_name}')
self.exec_ctxt.set_local('tmp_log4j', jvm_arg)
val = f'-{jvm_k}={jvm_arg}'
else:
Expand Down
3 changes: 3 additions & 0 deletions user_tools/src/spark_rapids_pytools/rapids/tool_ctxt.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ def get_rapids_output_folder(self) -> str:
return root_dir
return FSUtil.build_path(root_dir, rapids_subfolder)

def get_log4j_properties_file(self) -> str:
return self.get_value_silent('toolOutput', 'textFormat', 'log4jFileName')

def get_platform_name(self) -> str:
"""
This used to get the lower case of the platform of the runtime.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
toolOutput:
subFolder: rapids_4_spark_profile
textFormat:
log4jFileName: rapids_4_spark_profile_stderr.log
amahussein marked this conversation as resolved.
Show resolved Hide resolved
recommendations:
fileName: profile.log
headers:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ toolOutput:
textFormat:
summaryLog:
fileName: rapids_4_spark_qualification_output.log
log4jFileName: rapids_4_spark_qualification_stderr.log
amahussein marked this conversation as resolved.
Show resolved Hide resolved
csv:
unsupportedOperatorsReport:
fileName: rapids_4_spark_qualification_output_unsupportedOperators.csv
Expand Down
3 changes: 2 additions & 1 deletion user_tools/src/spark_rapids_tools/cmdli/argprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,8 @@ def build_tools_args(self) -> dict:
'remoteFolder': None,
'platformArgs': {
'jvmMaxHeapSize': self.p_args['toolArgs']['jvmMaxHeapSize'],
'jvmGC': self.p_args['toolArgs']['jvmGC']
'jvmGC': self.p_args['toolArgs']['jvmGC'],
'Dlog4j.configuration': self.p_args['toolArgs']['log4jPath']
},
'jobResources': self.p_args['toolArgs']['jobResources']
},
Expand Down