bridge.models.hf_pretrained.utils#

Module Contents#

Functions#

is_safe_repo

Decide whether remote code execution should be enabled for a Hugging Face model or dataset repository.

Data#

API#

bridge.models.hf_pretrained.utils.logger#

‘getLogger(…)’

bridge.models.hf_pretrained.utils.is_safe_repo(hf_path: str, trust_remote_code: bool | None) bool#

Decide whether remote code execution should be enabled for a Hugging Face model or dataset repository.

This function follows two rules: 1. If trust_remote_code is explicitly provided (True/False), its value takes precedence. 2. If trust_remote_code is None, remote code execution is disabled.

Parameters:
  • hf_path (str) – The Hugging Face repository identifier (e.g., “org/model_name”).

  • trust_remote_code (bool | None) – If True, always allow remote code execution. If False, always disable it. If None, disable remote code execution.

Returns:

Whether remote code execution should be enabled.

Return type:

bool