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

[Bug] Variable Sourcing Not Behaving As Expected #29

Open
mxava opened this issue Apr 28, 2021 · 4 comments
Open

[Bug] Variable Sourcing Not Behaving As Expected #29

mxava opened this issue Apr 28, 2021 · 4 comments

Comments

@mxava
Copy link

mxava commented Apr 28, 2021

One of our customers wrote in a ticket:

We are having an issue with the VSCode editor that you provided for us. When declaring an environment variable in the anaconda-project.yml, the variable isn't set even though it works fine when using the JupyterLab editor for example.
See example below of how we set the variable in the anaconda-project.yml file:

variables:
TEST_ENV:
default: Hello

On the screenshots attached, you can see the same script running on the same Anaconda project, just the editor changes between JupyterLab and VSCode, the script test_env.py and the anaconda-project.yml don't change.

Could you please have a look and maybe provide us with a fix for the VSCode editor that we have so that it sources these variables from the anaconda-project.yaml?

env_var_jupyterlab
env_var_vscode

@AlbertDeFusco
Copy link
Collaborator

Yes, that specifically is a known bug and something I have thought about. I have an idea of how to provide this, but haven't started working on it yet.

@jbednar
Copy link

jbednar commented Apr 28, 2021

@AlbertDeFusco , can you clarify whether this is a bug in code we implemented, or simply a case we have not yet implemented? If the latter I wouldn't call it a bug! :-) Also, do you know a workaround, in any case?

@AlbertDeFusco
Copy link
Collaborator

I would classify as not implemented. I will investigate whether there is a work around.

@AlbertDeFusco
Copy link
Collaborator

I have a work-around. Run this in the terminal

anaconda-project run env | grep -E "`anaconda-project list-variables | sed -n '/^=.*/,$p' | tail -n +2 | awk '{print $1}' | grep -v "CONDA_PREFIX" | xargs | tr ' ' '|'`" > .env

This command creates a .env file that is used by VSCode to set environment variables when you start a shell or Jupyter Notebook. The .env file contains variables as they are set in the anaconda-project.yml file. If the variables change re-run the command and "reload the window". You can reload the window by refreshing the page or opening the command palette and search for "reload window".

I will continue to work a real implementation of this.

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

3 participants