MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / EnvironmentVariableGuard

Class EnvironmentVariableGuard

python/paddle/utils/environments.py:142–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

140
141
142class EnvironmentVariableGuard(Generic[T]):
143 variable: EnvironmentVariable[T]
144 original_value: T
145
146 def __init__(self, variable: EnvironmentVariable[T], value: T):
147 self.variable = variable
148 self.original_value = variable.get()
149 self.variable.set(value)
150
151 def __enter__(self) -> Self:
152 return self
153
154 def __exit__(self, exc_type, exc_value, traceback) -> None:
155 self.variable.set(self.original_value)

Callers 15

sot_mode_guardFunction · 0.90
strict_mode_guardFunction · 0.90
min_graph_size_guardFunction · 0.90
with_control_flow_guardFunction · 0.90
export_guardFunction · 0.90
faster_guard_guardFunction · 0.90
guard_tree_guardFunction · 0.90
sot_step_profiler_guardFunction · 0.90
phi_implFunction · 0.90

Calls

no outgoing calls

Tested by 4

test_guardMethod · 0.72
test_bool_env_guardMethod · 0.72
test_str_env_guardMethod · 0.72
test_int_env_guardMethod · 0.72