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

Fix output file json #860

Merged
merged 2 commits into from
Aug 26, 2024
Merged
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
27 changes: 13 additions & 14 deletions scalene/scalene_profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -888,6 +888,8 @@ def output_profile(program_args: Optional[List[str]] = None) -> bool:
if "is_child" in json_output:
return True
outfile = Scalene.__output.output_file
if Scalene.__args.outfile:
outfile = Scalene.__args.outfile
# If there was no output file specified, print to the console.
if not outfile:
if sys.platform == "win32":
Expand Down Expand Up @@ -1864,14 +1866,14 @@ def profile_code(
):
return exit_status

generate_html(
profile_fname=Scalene.__profile_filename,
output_fname=(
Scalene.__args.outfile
if Scalene.__args.outfile
else Scalene.__profiler_html
),
)
if Scalene.__args.web:
# Only generate HTML file if needed for display in the browser.
generate_html(
profile_fname=Scalene.__profile_filename,
output_fname=(
Scalene.__profiler_html
),
)
if Scalene.in_jupyter():
from scalene.scalene_jupyter import ScaleneJupyter

Expand All @@ -1891,12 +1893,9 @@ def profile_code(
# See also scalene/scalene_preload.py
old_dyld = os.environ.pop("DYLD_INSERT_LIBRARIES", "")
old_ld = os.environ.pop("LD_PRELOAD", "")
if Scalene.__args.outfile:
output_fname = Scalene.__args.outfile
else:
output_fname = (
f"{os.getcwd()}{os.sep}{Scalene.__profiler_html}"
)
output_fname = (
f"{os.getcwd()}{os.sep}{Scalene.__profiler_html}"
)
if Scalene.__pid == 0:
# Only open a browser tab for the parent.
dir = os.path.dirname(__file__)
Expand Down
Loading