'how to use environment variable in Colab tensorboard magic function

I tried to pass environment variable in logdir argument of %tensorboard magic function. But it fail to interpret it.

os.environ['TENSORBOARD_FOLDER'] = 'tmp'
%load_ext tensorboard
%tensorboard --logdir ./tensorboard/$(TENSORBOARD_FOLDER)

The variables created successfully

!echo $TENSORBOARD_FOLDER
tmp

But still gave me the following error

No dashboards are active for the current data set.
Probable causes:

You haven’t written any data to your event files.
TensorBoard can’t find your event files.
If you’re new to using TensorBoard, and want to find out how to add data and set up your event files, check out the README and perhaps the TensorBoard tutorial.
If you think TensorBoard is configured properly, please see the section of the README devoted to missing data problems and consider filing an issue on GitHub.

Last reload: Mar 7, 2022, 3:22:38 PM
Log directory: ./tensorboard/$(TENSORBOARD_FOLDER)

The data is in the folder as I could call the following successfully
%tensorboard --logdir ./tensorboard/tmp



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source