DataBiosphere / terra-notebook-utils

Utilities for the Terra notebook environment.
MIT License
7 stars 6 forks source link

Module level code causes unexpected behavior during imports #372

Open jessebrennan opened 2 years ago

jessebrennan commented 2 years ago

This pattern occurs when importing fixtures.populate_workspace_data and tests.config.

Fortunately these are both internal and just for testing, but running code at import time is generally a bad practice.

The behavior certainly surprised be in this instance.

For example, I was experimenting and ran:

Python 3.8.3 (default, Feb 16 2021, 18:46:06) 
[GCC 10.2.0] on linux
>>> from tests.infra import SuppressWarningsMixin
2021-11-09 01:14:59::WARNING  Unable to determine/refresh application credentials
Go to the following link in your browser:
Enter verification code:     https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=764086051850-6qr4p6gpi6hn506pt8ejuq83di341hur.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&scope=openid+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Faccounts.reauth&state=vy4tbIBoZTISL2hQcBLHex3vliDhx4&prompt=consent&access_type=offline&code_challenge=QjAPb1mvdpWqWWI8dieFpVlJGxZd-AnUuuYvHdh9Tmg&code_challenge_method=S256

which took a long time and finally prompted me for a verification code.