Skip to content

absolute include file not working. #574

@HernandoR

Description

@HernandoR

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:

  1. If we pass the relative path only, the viztracer recorded 56092 entries,
  2. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    need reproNeeds a reproducible example

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions