I made a custom decorator as follows:
from viztracer import trace_and_save as _trace_and_save
def trace_and_save(func=None):
if os.environ.get("TRACER", None) is None:
return func
project_root = rootutils.autosetup()
include_files=None
# include_files = list(map(str, project_root.glob("src/**/*.py")))
include_files =["src/"]
# BUG: stops working when using absolute path
include_files=[os.path.abspath(f) for f in include_files if not f.startswith("/")]
output_dir = os.path.join(project_root, "output/profiles", func.__module__)
if not Path(output_dir).exists():
Path(output_dir).mkdir(parents=True)
# return decorator with trace_and_save(output_dir=output_dir, include_files=include_files)
return _trace_and_save(
func,
output_dir=output_dir,
include_files=include_files,
tracer_entries=2_000_000,
)
behaviour:
- If we pass the relative path only, the viztracer recorded 56092 entries,
- If we pass the absolute path only, the viztracer recorded 2 entries, AKA nothing
expected behaviour:
If we pass the absolute path only, the viztracer records 56092 entries align with relative path calling.
debugs
In both experiments, the path was passed to
|
if include_files is None: |
|
self.include_files = include_files |
|
else: |
|
self.include_files = include_files[:] + [os.path.abspath(f) for f in include_files if not f.startswith("/")] |
As to my understanding, this line is to appending abs path to the included files. Which means it should be equal to pass only the abs path.
I could not dig in more, since I didn't find where the self.include_files was used
I made a custom decorator as follows:
behaviour:
expected behaviour:
If we pass the absolute path only, the viztracer records 56092 entries align with relative path calling.
debugs
In both experiments, the path was passed to
viztracer/src/viztracer/viztracer.py
Lines 71 to 74 in 86775df
As to my understanding, this line is to appending abs path to the included files. Which means it should be equal to pass only the abs path.
I could not dig in more, since I didn't find where the
self.include_fileswas used