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

pprofile executing wrong Python file #43

Open
MatthijsdeJ opened this issue Feb 1, 2022 · 1 comment
Open

pprofile executing wrong Python file #43

MatthijsdeJ opened this issue Feb 1, 2022 · 1 comment

Comments

@MatthijsdeJ
Copy link

My aim with pprofile was to perform statistic profiling of the execution of generate_imitation_data.py, excluding all files but two: imitation_generation/generation.py and imitation_generation/tutor.py. I ran the command:

pprofile -o profile_out.txt --statistic 0.01 --exclude *.py --include imitation_generation/generation.py --include imitation_generation/tutor.py generate_imitation_data.py

However, executing this command executes a different python file in my directory: preprocess_data.py.

@vpelletier
Copy link
Owner

vpelletier commented Feb 2, 2022

The reason is the *.py pattern: this gets expanded by your shell before the call, which likely results in something like --exclude some.py preprocess_data.py some_other.py (etc), which, as of the current code, ends the named argument list (some.py being the only value applied to --exclude). Which means that from preprocess_data.py on, these arguments get assigned to the SCRIPT positional arguments, everything after it becoming the sys.argv value of preprocess_data.py.

A solution is to convert the glob syntax into an all-matching regex, and the shell should leave it alone:

pprofile -o profile_out.txt --statistic 0.01 --exclude '' --include imitation_generation/generation.py --include imitation_generation/tutor.py generate_imitation_data.py

But this is already what pprofile does internally if you only provide the --include argument, so it should be possible to leave --exclude out entirely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants