plasma-umass / scalene

Scalene: a high-performance, high-precision CPU, GPU, and memory profiler for Python with AI-powered optimization proposals
Apache License 2.0
12.22k stars 399 forks source link

Environment variables from .env file are not loaded #817

Closed jkoessle closed 7 months ago

jkoessle commented 7 months ago

Describe the bug I'm using environment variables from a .env file. It seems that when using scalene, these variable are not loaded -> os.getenv("MY_VARIABLE") returns None and os.environ["MY_VARIABLE"] returns a KeyError at runtime. In normal Python execution, it loads the environment variables without any problems.

To Reproduce Steps to reproduce the behavior:

  1. Create a .env file in your project
  2. Create a key/value pair like HELLO="world"
  3. Load the env variable in your program either with os.getenv("HELLO") or os.environ["HELLO"]
  4. See error

Expected behavior I would expect scalene to load the environment variables from the .env file at runtime/profiling.

Desktop (please complete the following information):

jkoessle commented 7 months ago

Solved it by explicitly loading the environment variables using load_dotenv() from the dotenv package.