Environmental variable for notebook
Hi! I followed this post (https://broadinstitute.zendesk.com/hc/en-us/articles/360026639112-New-Environmental-Variables-for-Jupyter-Notebooks), but found out neither $WORKSPACE_NAME nor $WORKSPACE_BUCKET is defined - they returned just an empty string. Is this feature available yet? If so, any one know how to make this work? Fyi, I'm using R. Thanks!
Comments
11 comments
Hi Sehyun - This is a new feature, so if you have not restarted your cluster recently, it may not show up. When restarting the cluster, make a note of any R and Python packages that you previously installed, as this will need to be redone.
I see that this issue is being tracked and should be resolved soon: https://github.com/DataBiosphere/leonardo/issues/864
Also, Matt Bookman provided some better code for pulling in the environmental variables, so I am updating the knowledge base article to reflect that.
Hello Sehyun -
The cluster needs to be recreated to reset the environmental variables.
When you say that you 'started a new notebook cluster with R', did you change any of the options in your existing cluster so that it regenerated? Opening a new notebook by itself will not regenerate the runtime.
Second, it is possible to see what environmental variables are loaded when you regenerate the runtime by opening the terminal option and typing 'env'.
You should see your variables in the list if they were loaded with the cluster correctly.
Or your command should show them: names(Sys.getenv())
Try this and let us know.
Humm... I tried both restarting my cluster and starting a new cluster, but neither of them worked. I also made a new workspace and tried in a new cluster in that, but still returned with empty string. Any thought?
Can you share a quick screenshot of what your notebook code looks like? It might be easier to help troubleshoot :)
Here it is - the new notebook from the new workspace. Doesn't seem that informative...
Hello,
Hm, I tested your code as is within a notebook of my own using an R kernel and it seems to be working.
I will look into it further and perhaps Adelaide may also have additional insight!
That is interesting, this is not a behavior I can explain. I can look into it tomorrow. Thanks for keeping us on our toes!
I checked the GitHub issue which was closed with a resolution for others, but this is still not working for me.
$WORKSPACE_NAME and $WORKSPACE_BUCKET, both came with blanks - exactly same as above. When I checked the environmental variables, it seems like they are not defined. I just created a new workspace and started a new notebook cluster with R.
Any idea why I'm still having this problem?
Hi Sehyun -
If you enter in the following commands:
are you able to see the proper outputs? This is from an R kernel.
The document that you listed at the top of this post has been updated recently with syntax that you can use:
https://support.terra.bio/hc/en-us/articles/360026639112-New-Environmental-Variables-for-Jupyter-Notebooks
Please let us know if you have further questions.
Hi Adelaide,
Changing runtime environment makes everything work! Thanks!
- Sehyun
Please sign in to leave a comment.