Resolve the ModelScope API endpoint with automatic scheme completion. Priority (highest to lowest): 1. ``cli_endpoint`` (explicit CLI --endpoint argument) 2. Environment variable ``MODELSCOPE_DOMAIN`` 3. Built-in default (https://www.modelscope.cn) Scheme auto-compl
(cli_endpoint: Optional[str] = None,
cn_site: bool = True)
| 211 | |
| 212 | |
| 213 | def resolve_endpoint(cli_endpoint: Optional[str] = None, |
| 214 | cn_site: bool = True) -> str: |
| 215 | """Resolve the ModelScope API endpoint with automatic scheme completion. |
| 216 | |
| 217 | Priority (highest to lowest): |
| 218 | 1. ``cli_endpoint`` (explicit CLI --endpoint argument) |
| 219 | 2. Environment variable ``MODELSCOPE_DOMAIN`` |
| 220 | 3. Built-in default (https://www.modelscope.cn) |
| 221 | |
| 222 | Scheme auto-completion: |
| 223 | If the resolved value does not start with ``http://`` or ``https://``, |
| 224 | ``https://`` is prepended automatically so that callers may pass bare |
| 225 | domain names such as ``modelscope.ai``. |
| 226 | |
| 227 | Args: |
| 228 | cli_endpoint: Value from the CLI ``--endpoint`` flag. When *None*, |
| 229 | the function falls back to :func:`get_endpoint`. |
| 230 | cn_site: Forwarded to :func:`get_endpoint` when *cli_endpoint* is |
| 231 | *None*. ``True`` selects the Chinese site, ``False`` the |
| 232 | international site. |
| 233 | |
| 234 | Returns: |
| 235 | A fully-qualified endpoint URL, e.g. ``https://www.modelscope.cn``. |
| 236 | """ |
| 237 | if cli_endpoint is None: |
| 238 | return get_endpoint(cn_site=cn_site) |
| 239 | endpoint = cli_endpoint.strip().rstrip('/') |
| 240 | if not endpoint: |
| 241 | return get_endpoint(cn_site=cn_site) |
| 242 | if not endpoint.startswith('http://') and not endpoint.startswith( |
| 243 | 'https://'): |
| 244 | endpoint = MODELSCOPE_URL_SCHEME + endpoint |
| 245 | return endpoint |
| 246 | |
| 247 | |
| 248 | def compute_hash(file_path): |
no test coverage detected
searching dependent graphs…