@@ -623,6 +623,7 @@ def init(
623623 timeout : int | None = 180 ,
624624 visibility : typing .Literal ["public" , "tenant" ] | list [str ] | None = None ,
625625 no_color : bool = False ,
626+ record_shell_vars : set [str ] | None = None ,
626627 ) -> bool :
627628 """Initialise a Simvue run
628629
@@ -660,6 +661,9 @@ def init(
660661 * A list of usernames with which to share this run
661662 no_color : bool, optional
662663 disable terminal colors. Default False.
664+ record_shell_vars : list[str] | None,
665+ list of environment variables to store as metadata, these can
666+ either be defined as literal strings or globular expressions
663667
664668 Returns
665669 -------
@@ -677,6 +681,7 @@ def init(
677681 folder = folder or self ._user_config .run .folder
678682 name = name or self ._user_config .run .name
679683 metadata = (metadata or {}) | (self ._user_config .run .metadata or {})
684+ record_shell_vars = record_shell_vars or self ._user_config .run .record_shell_vars
680685
681686 self ._term_color = not no_color
682687
@@ -742,7 +747,11 @@ def init(
742747 self ._sv_obj .ttl = self ._retention
743748 self ._sv_obj .status = self ._status
744749 self ._sv_obj .tags = tags
745- self ._sv_obj .metadata = (metadata or {}) | git_info (os .getcwd ()) | environment ()
750+ self ._sv_obj .metadata = (
751+ (metadata or {})
752+ | git_info (os .getcwd ())
753+ | environment (env_var_glob_exprs = record_shell_vars )
754+ )
746755 self ._sv_obj .heartbeat_timeout = timeout
747756 self ._sv_obj .alerts = []
748757 self ._sv_obj .created = time .time ()
0 commit comments