Skip to content

Commit 208addd

Browse files
committed
Refactor linting and formatting tools in Makefile and scripts
1 parent ddb8b3b commit 208addd

File tree

3 files changed

+11
-18
lines changed

3 files changed

+11
-18
lines changed

tritonparse/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,9 @@ def print_parsed_files_summary(parsed_log_dir: str) -> None:
173173
if size_bytes < 1024:
174174
file_size = f"{size_bytes}B"
175175
elif size_bytes < 1024 * 1024:
176-
file_size = f"{size_bytes/1024:.1f}KB"
176+
file_size = f"{size_bytes / 1024:.1f}KB"
177177
else:
178-
file_size = f"{size_bytes/(1024*1024):.1f}MB"
178+
file_size = f"{size_bytes / (1024 * 1024):.1f}MB"
179179
except OSError:
180180
pass
181181

tritonparse/structured_logging.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,6 @@ def convert(obj):
142142
Returns:
143143
A serializable version of the input object where dataclasses are converted to dictionaries
144144
"""
145-
from triton.language.core import dtype
146-
147145
# 1. primitives that JSON already supports -------------------------------
148146
if obj is None or isinstance(obj, (bool, int, str)):
149147
return obj
@@ -178,11 +176,6 @@ def convert(obj):
178176
return convert(
179177
asdict(obj)
180178
) # Convert dataclass to dict and then process that dict
181-
182-
# 4. Common Triton constexpr objects
183-
if isinstance(obj, dtype):
184-
return f"triton.language.core.dtype('{str(obj)}')"
185-
186179
log.warning(f"Unknown type: {type(obj)}")
187180
return str(obj) # Return primitive types as-is
188181

@@ -378,18 +371,18 @@ def extract_file_content(trace_data: Dict[str, Any], metadata_group: Dict[str, s
378371
# Check file size before reading to avoid memory issues
379372
file_size = os.path.getsize(file_path)
380373
if file_size > MAX_FILE_SIZE:
381-
trace_data["file_content"][ir_filename] = (
382-
f"<file too large: {file_size} bytes>"
383-
)
374+
trace_data["file_content"][
375+
ir_filename
376+
] = f"<file too large: {file_size} bytes>"
384377
continue
385378

386379
with open(file_path, "r") as f:
387380
trace_data["file_content"][ir_filename] = f.read()
388381
except (UnicodeDecodeError, OSError) as e:
389382
# add more specific error type
390-
trace_data["file_content"][ir_filename] = (
391-
f"<error reading file: {str(e)}>"
392-
)
383+
trace_data["file_content"][
384+
ir_filename
385+
] = f"<error reading file: {str(e)}>"
393386
log.debug(f"Error reading file {file_path}: {e}")
394387

395388

tritonparse/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
from pathlib import Path
77
from typing import Optional
88

9-
# argument parser for OSS
10-
parser = None
11-
129
from .common import (
1310
copy_local_to_tmpdir,
1411
is_fbcode,
@@ -19,6 +16,9 @@
1916
)
2017
from .source_type import Source, SourceType
2118

19+
# argument parser for OSS
20+
parser = None
21+
2222

2323
def init_parser():
2424
global parser

0 commit comments

Comments
 (0)