(
self,
endpoint: Optional[str] = None,
timeout: int = API_HTTP_CLIENT_TIMEOUT,
max_retries: int = API_HTTP_CLIENT_MAX_RETRIES,
token: Optional[str] = None,
)
| 58 | """ |
| 59 | |
| 60 | def __init__( |
| 61 | self, |
| 62 | endpoint: Optional[str] = None, |
| 63 | timeout: int = API_HTTP_CLIENT_TIMEOUT, |
| 64 | max_retries: int = API_HTTP_CLIENT_MAX_RETRIES, |
| 65 | token: Optional[str] = None, |
| 66 | ) -> None: |
| 67 | super().__init__(endpoint=endpoint, token=token) |
| 68 | # Preserved for callers that historically read these attributes. |
| 69 | self.endpoint = self._endpoint or self._api._config.endpoint |
| 70 | self.token = token |
| 71 | self.timeout = timeout |
| 72 | self.max_retries = max_retries |
| 73 | self.headers = {'user-agent': ModelScopeConfig.get_user_agent()} |
| 74 | |
| 75 | # If non-default timeout/max_retries were provided, eagerly construct |
| 76 | # the internal LegacyClient so they actually take effect on the wire. |
| 77 | if (timeout != API_HTTP_CLIENT_TIMEOUT |
| 78 | or max_retries != API_HTTP_CLIENT_MAX_RETRIES): |
| 79 | from modelscope_hub._legacy_api import LegacyClient |
| 80 | from modelscope_hub.utils import build_user_agent |
| 81 | cfg = self._api._config |
| 82 | self._api._legacy = LegacyClient( |
| 83 | token=cfg.token, |
| 84 | endpoint=cfg.endpoint, |
| 85 | timeout=timeout, |
| 86 | max_retries=max_retries, |
| 87 | user_agent=build_user_agent(cfg.get_session_id()), |
| 88 | ) |
| 89 | |
| 90 | # ------------------------------------------------------------------ |
| 91 | # Legacy method shims missing from LegacyHubApi |
nothing calls this directly
no test coverage detected