Reputation: 5036
I'm running this code for ALBERT, one of Google's machine learning models on Google Colab. At the end of the code, they do everything by running a script using !
(the shell) to run the script. However, I'd like to do some stuff to the resulting model after the code has run.
Is there any way to either access or get the script to output particular variables in a way that my code in Colab could access afterwards?
Here's another way of phrasing my question. Putting $HELLO_WORLD
into the shell command accesses the HELLO_WORLD
variable in my Colab code. Is there any way to get the script to set the HELLO_WORLD
variable in my Colab code?
Upvotes: 0
Views: 587
Reputation: 6567
You can use os.environ
like this.
import os
os.environ['HELLO_WORLD']='hello world from Python'
Then later
!echo $HELLO_WORLD
# hello world from Python
Upvotes: 1