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

Load environment variables from .env file and global variables #10928

Closed
2 tasks done
DonJayamanne opened this issue Jul 26, 2022 · 7 comments
Closed
2 tasks done

Load environment variables from .env file and global variables #10928

DonJayamanne opened this issue Jul 26, 2022 · 7 comments

Comments

@DonJayamanne
Copy link
Contributor

DonJayamanne commented Jul 26, 2022

Refs: #10359

Complexity: 3

Authors: @DonJayamanne

Create Issue

Create Issue


Requirements

  • Install prerelease jupyter extension into VS Code Insiders (desktop)
  • Have a python environment that you can run jupyter from. (https://jupyter.org/install)
  • Be familiar with jupyter notebooks
  • Use Python 3.6 or later (please ensure you aren't using Python 2, use python --version to check the version)

Test loading variables from .env file

  1. Open a folder in VS Code
  2. Add a file named .env
  3. Add an environment variable to the file
  4. Create an ipynb file in the root directory
  5. Run a cell in the ipynb file to print the value of the above env variable
import os
print(os.getenv(<env variable>))
  1. Verify the right value is printed
  2. Updated the value in the .env file
  3. Restart the kernel and verify the new value is printed.

Test loading variables from global env variables

  1. Exit VS Code completely
  2. Create a global environment variable (on windows use env varaibles editor and unix update ~/.bashrc or the like)
  3. Open a folder in VS Code
  4. Create an ipynb file in the root directory
  5. Run a cell in the ipynb file to print the value of the above env variable
import os
print(os.getenv(<env variable>))
  1. Verify the right value is printed
  2. Updated the environment variable
  3. Exit vscode completely and reload VS Code
  4. verify the new value is printed when running a cell again
@DonJayamanne DonJayamanne added the bug Issue identified by VS Code Team member as probable bug label Jul 26, 2022
@github-actions github-actions bot added the triage-needed Issue needs to be triaged label Jul 26, 2022
@DonJayamanne DonJayamanne changed the title Load environment variables from .env file Load environment variables from .env file and global variables Jul 26, 2022
@DonJayamanne DonJayamanne added testplan-item and removed bug Issue identified by VS Code Team member as probable bug triage-needed Issue needs to be triaged labels Jul 26, 2022
@DonJayamanne DonJayamanne added this to the July 2022 milestone Jul 26, 2022
@IanMatthewHuff
Copy link
Member

Looks good. All the scenarios work for me. I think Rich is on Windows, which is good since I'm pretty sure at least all of the .env file stuff already worked for me on Mac.

@IanMatthewHuff IanMatthewHuff removed their assignment Jul 26, 2022
@rchiodo
Copy link
Contributor

rchiodo commented Jul 26, 2022

I'm having trouble with ZMQ disabled. I can't run the IW at the moment.

@rchiodo
Copy link
Contributor

rchiodo commented Jul 26, 2022

I'm blocked on testing this because non ZMQ doesn't work for me.

Something submitted on this day broke non ZMQ for me:
https://dev.azure.com/monacotools/Monaco/_traceability/runview/changes?currentRunId=178730

@rchiodo
Copy link
Contributor

rchiodo commented Jul 26, 2022

Entered #10940

@rchiodo rchiodo removed their assignment Jul 27, 2022
@rchiodo
Copy link
Contributor

rchiodo commented Jul 27, 2022

Works now after the ZMQ fix

@rchiodo rchiodo closed this as completed Jul 27, 2022
@jtele2
Copy link

jtele2 commented Sep 27, 2022

I am trying to get this to work. Does the file have to be the .ipynb extenstion? Does it have to be in the root folder?

I'm using the Python Interactive with regular .py files and the workflow proposed by @DonJayamanne is not working - although it is exactly what I am looking to do.

@DonJayamanne
Copy link
Contributor Author

@jtele2
please file a separate issue with the results and steps required to repro the issue

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants