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

Test pixi support #23674

Closed
3 tasks done
karthiknadig opened this issue Jun 24, 2024 · 1 comment
Closed
3 tasks done

Test pixi support #23674

karthiknadig opened this issue Jun 24, 2024 · 1 comment
Labels
testplan-item Test plan item/assignments for upcoming release verified Verification succeeded
Milestone

Comments

@karthiknadig
Copy link
Member

karthiknadig commented Jun 24, 2024

Refs: #22978

Complexity: 5

Create Issue


Requirements:

  • Latest Python extension pre-release
  • Have a working pixi installation (>0.24.1), installation instructions can be found here: pixi.sh.

Test that Pixi environments are discovered and activated

  • Open a new empty workspace folder.

  • Open a terminal in the workspace and run the following commands to initialize a pixi project with a python interpreter:

    pixi init .
    pixi add python session-info
    
  • Add an script.py file to the root of the workspace and open it (the contents doesnt matter).

  • Add the following content to the script.py:

import session_info
session_info.show()

import os
print(os.environ["CONDA_PREFIX"])
  • Verify that a default interpreter has been selected that points to python interpreter in the .pixi\envs directory of the workspace. Its type should be Pixi.
  • Run the script using the play icon on top right:

Untitled

  • The file is successfully run and prints the session info:

Untitled

  • Open a new terminal: If you have the python.terminal.activateEnvrionment setting set to true , the environment should be activated:
    • You can check this by checking the location for python
      python -c "import sys; print(sys.prefix)”
    • You can also check for the CONDA_PREFIX variable or the PIXI_* variables

Untitled

Test multiple environment configurations

  • Add another environment and install it:
pixi project environment add test
pixi install --all
  • Selecting the interpreter selector will now show you two environments default and the newly added test

Untitled

  • Your old terminal should warn you that the Python extension want’s to relaunch your terminal:

Untitled

  • Clicking the Relaunch terminal should result in a newly activated environment.

    Print the value of the environment variable CONDA_PREFIX to the terminal (echo $CONDA_PREFIX using bash, echo %CONDA_PREFIX% when running Batch, or $Env:CONDA_PREFIX when using Powershell). Check that that the environment location has indeed changed to the test environment (.pixi/envs/tests):

Untitled

Test with pytest

Because pixi doesn’t by default install pip the pytest installation needs to be handled by pixi .

  • Add a simple test file: test_python_testing.py

    def test_true():
        assert(True)
    
    def test_false():
        assert(False)
  • Select the testing icon:

Untitled

  • Select Configure Python Tests
  • Select pytest and the . Root directory:

Untitled

  • This should install pytest for you through the terminal:

Untitled

  • You likely need to refresh the Testing tab to sync the just installed pytest with the window:

Untitled

  • Select any of the Play icons to start the tests, which should result in a failing and succeeding test:

Untitled

/cc @baszalmstra @tdejager

@bpasero
Copy link
Member

bpasero commented Jun 25, 2024

Some of my issues are likely setup issues that should have been better spelled out here in the test plan item. Otherwise the later steps in the test plan item where easy enough to execute.

@bpasero bpasero removed their assignment Jun 25, 2024
@joyceerhl joyceerhl removed their assignment Jun 25, 2024
@connor4312 connor4312 added the verified Verification succeeded label Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
testplan-item Test plan item/assignments for upcoming release verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

4 participants