Skip to content

Commit

Permalink
store env vars as constant
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasdiener committed Apr 10, 2024
1 parent f0097f6 commit a4ccb45
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions logpyle/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1701,6 +1701,12 @@ def add_simulation_quantities(mgr: LogManager) -> None:
mgr.add_quantity(Timestep())


def _get_env_vars() -> str:
"""Return a string containing all environment variables."""
from os import environ
return "\n".join(f"{key}={value}" for key, value in environ.items())


def add_run_info(mgr: LogManager) -> None:
"""Add generic run metadata, such as command line, host, and time."""

Expand All @@ -1717,6 +1723,7 @@ def add_run_info(mgr: LogManager) -> None:
from time import localtime, strftime, time
mgr.set_constant("date", strftime("%a, %d %b %Y %H:%M:%S %Z", localtime()))
mgr.set_constant("unixtime", time())
mgr.set_constant("env", _get_env_vars())


class MemoryHwm(PostLogQuantity):
Expand Down

0 comments on commit a4ccb45

Please sign in to comment.