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

Trying to run pytest using Austin in VS code. #24

Closed
hrshdhgd opened this issue Feb 11, 2022 · 11 comments
Closed

Trying to run pytest using Austin in VS code. #24

hrshdhgd opened this issue Feb 11, 2022 · 11 comments

Comments

@hrshdhgd
Copy link

hrshdhgd commented Feb 11, 2022

This may be similar to #21 but I'm not sure. I read the documentation at the VS code marketplace here

Here's my situation:
I have python project that I'm trying to profile using Austin within VS code. I'm using a MacBook (macOS Big Sur). Here's my tasks.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "austin",
            "label": "Profile tests",
            "args": [
                "python",
                "-m",
                "pytest",
            ],
            "problemMatcher": []
        }
    ]
}

I'm just trying to run pytest over the project. I'm also running this within a conda virtual environment. I get the following error:

> Executing task: Profile tests <

Starting Profiler in xxx/yyy/zzz/project-name.
Running 'austin' with args '-i 100 --pipe  python -m pytest'.
austin process exited with code 127
The terminal process failed to launch (exit code: 127).

Terminal will be reused by tasks, press any key to close it.

Any guidance/suggestion would be great appreciated.

@hrshdhgd hrshdhgd changed the title Trying to run purest using Austin in VS code. Trying to run pytest using Austin in VS code. Feb 11, 2022
@P403n1x87
Copy link
Owner

P403n1x87 commented Feb 11, 2022

I think this might be due to the fact that austin is running without sudo. On MacOS the use of sudo is unfortunately mandatory (unless you have SIP disabled). One possible solution is to allow austin to run without password, by adding a rule in the sudoers file, and then actually running sudo, e.g.

        {
            "type": "austin",
            "label": "Profile tests",
            "command": ["sudo"],
            "args": [
                "python",
                "-m",
                "pytest",
            ]
        },

@hrshdhgd
Copy link
Author

hrshdhgd commented Feb 11, 2022

Hey @P403n1x87 , thank you so much for the suggestion. I sudo vi sudo and added the line:

myUsername ALL=(ALL) NOPASSWD: ALL

and ran the task again after changing the task to what you suggested above. I get a different error (exit code 1) instead of the previous exit code 127..

Running 'sudo' with args 'austin -i 100 --pipe  python -m pytest'.
austin process exited with code 1
The terminal process failed to launch (exit code: 1).

Terminal will be reused by tasks, press any key to close it.

@P403n1x87
Copy link
Owner

@hrshdhgd thanks for trying that. I think this is now the same as #23, which I haven't been able to figure out yet 🙁 .

@P403n1x87
Copy link
Owner

I sudo vi sudo and added the line:

myUsername ALL=(ALL) NOPASSWD: ALL

Just as an aside, I'd use something like

myUsername ALL = (root) NOPASSWD: /usr/local/bin/austin

instead.

@hrshdhgd
Copy link
Author

Not a problem , please let me know when you figure it out. In the meanwhile, would you know which Austin VSCode extension version and Austin version combination has proven to work in unison in the past?

@hrshdhgd
Copy link
Author

I sudo vi sudo and added the line:
myUsername ALL=(ALL) NOPASSWD: ALL

Just as an aside, I'd use something like

myUsername ALL = (root) NOPASSWD: /usr/local/bin/austin

instead.

Aah ... I'll try that.

@hrshdhgd
Copy link
Author

same error.

@P403n1x87
Copy link
Owner

Not a problem , please let me know when you figure it out. In the meanwhile, would you know which Austin VSCode extension version and Austin version combination has proven to work in unison in the past?

I'm afraid Austin latest and Austin VS Code latest have the best chances 🙁 . What I would recommend in the meantime is to invoke austin manually from the command line and open the collected samples with the extension afterwards. I think I can safely say this proves to be the most reliable way of using the extension when everything else fails.

@hrshdhgd
Copy link
Author

Could you direct me to an example please?

@P403n1x87
Copy link
Owner

P403n1x87 commented Feb 13, 2022

Could you direct me to an example please?

You can run the same command that VS Code is trying to run from a terminal, e.g.

sudo austin -i 100 -o /path/to/austin/output.austin python -m pytest

and then open the /path/to/austin/output.austin from VS Code by clicking the OPEN button in the Flame Graph panel (or using the Cmd + Shift + A shortcut). This is equivalent to running the task.

@hrshdhgd
Copy link
Author

Thank you so much @P403n1x87 ! That works as expected!

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