Saving and transferring notebook data using Jupyter environment variables




  • Matt Bookman

    Note that the above new functionality does not currently work for getting the WORKSPACE_NAME for workspaces with that have space in the name:

    Also an alternative way to get the environment variables is through the Python `os` module:

    import os

    WORKSPACE = os.environ['WORKSPACE_NAME']
    bucket = os.environ['WORKSPACE_BUCKET']

    This removes the need to pull out the 0th element from the SList returned from the "!command".

  • Robert Title

    Issue 864 should be released this week.


    I like the python approach better than shelling out `echo` commands. Here's an R version:


    project <- Sys.getenv('WORKSPACE_NAMESPACE')
    workspace <- Sys.getenv('WORKSPACE_NAME')
    bucket <- Sys.getenv('WORKSPACE_BUCKET')


  • Adelaide Rhodes

    It looks like this will be made permanent when the issue is closed this week. 


    @Matt Bookman --  Thanks for an update to the code, I will update that in the documentation.  

  • Matt Bookman

    I recreated my cluster today and confirmed that WORKSPACE_NAME variable was set correctly for a notebook whose workspace name has a space in it.

    So is fixed.

  • Adelaide Rhodes

    Okay, a little more information was provided in your email that I am sharing here.

    If the cluster has not been "recreated" recently, meaning completely replaced, this might not work.

    Network clusters can be on "pause" and "restarted" but that is not the same as "recreated".

    "Recreating" a cluster will cause any newly installed programs and notebook outputs to be cleared out, so please back up your work to the workspace bucket.  [I am working on a blog post on some simple commands that facilitate this.]

Please sign in to leave a comment.

Powered by Zendesk