MCPcopy Create free account
hub / github.com/PaddlePaddle/FastDeploy / read_from_env

Method read_from_env

fastdeploy/config.py:367–385  ·  view source on GitHub ↗

Read configuration information from environment variables and update the object's attributes. If an attribute is not present or is an empty string in the environment variables, use the default value.

(self)

Source from the content-addressed store, hash-verified

365 self.moe_num_shared_experts = self.n_shared_experts
366
367 def read_from_env(self):
368 """
369 Read configuration information from environment variables and update the object's attributes.
370 If an attribute is not present or is an empty string in the environment variables, use the default value.
371 """
372 self.max_stop_seqs_num = envs.FD_MAX_STOP_SEQS_NUM
373 self.stop_seqs_max_len = envs.FD_STOP_SEQS_MAX_LEN
374
375 def reset_config_value(key, value):
376 if not hasattr(self, key.lower()):
377 if os.getenv(key, None):
378 value = eval(os.getenv(key))
379 logger.info(f"Get parameter `{key}` = {value} from environment.")
380 else:
381 logger.info(f"Parameter `{key}` will use default value {value}.")
382 setattr(self, key.lower(), value)
383
384 reset_config_value("COMPRESSION_RATIO", 1.0)
385 reset_config_value("ROPE_THETA", 10000)
386
387 def read_model_config(self):
388 config_path = os.path.join(self.model, "config.json")

Callers 1

_post_initMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected