Skip to content

Commit 458e6e9

Browse files
wychimeta-codesync[bot]
authored andcommitted
Fix FileNotFoundError with absolute path templates
Summary: Fixed a bug where the tritonparse reproducer failed with `FileNotFoundError` when the template parameter was passed as an absolute file path instead of a template name. The issue was in `determine_output_paths()` which naively replaced all dots in the template string with underscores to create the output filename. When template was an absolute path like `/data/users/.../template_bento.py`, this resulted in an invalid nested path structure. The fix extracts just the filename stem (without extension) when the template parameter contains path separators, making the function work correctly with both template names and absolute paths. Reviewed By: FindHao Differential Revision: D87023078 fbshipit-source-id: aad8c7d2f869f2f5fdc479804eac6229ebff7906
1 parent fb7197b commit 458e6e9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tritonparse/reproducer/utils.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ def determine_output_paths(out_dir: str, kernel_name: str, template: str):
333333
Args:
334334
out_dir: Output directory path. If empty, uses default location.
335335
kernel_name: Name of the kernel for default directory naming.
336+
template: Template name or path. If a path, extracts the filename.
336337
337338
Returns:
338339
Tuple of (python_script_path, json_context_path) as Path objects.
@@ -341,9 +342,14 @@ def determine_output_paths(out_dir: str, kernel_name: str, template: str):
341342
output_directory = Path(out_dir) / kernel_name
342343
output_directory.mkdir(parents=True, exist_ok=True)
343344

345+
# Extract template name from path if needed
346+
template_name = (
347+
Path(template).stem if "/" in template or "\\" in template else template
348+
)
349+
344350
filename_parts = ["repro"]
345351
if template != "example":
346-
filename_parts.append(template.replace(".", "_"))
352+
filename_parts.append(template_name)
347353
filename_parts.append(timestamp)
348354
filename = "_".join(filename_parts) + ".py"
349355
out_py_path = output_directory / filename

0 commit comments

Comments
 (0)