MCPcopy Create free account
hub / github.com/modelscope/modelscope / _legacy_request

Method _legacy_request

modelscope/hub/api.py:156–172  ·  view source on GitHub ↗

Send a request via the legacy client and validate the response envelope. Combines ``legacy._request`` (HTTP-level error handling) with application-level ``{"Code": 200, ...}`` envelope validation. Returns the parsed JSON body dict on success.

(
        self,
        method: str,
        path: str,
        **kwargs: Any,
    )

Source from the content-addressed store, hash-verified

154 # Internal transport helper
155 # ------------------------------------------------------------------
156 def _legacy_request(
157 self,
158 method: str,
159 path: str,
160 **kwargs: Any,
161 ) -> dict:
162 """Send a request via the legacy client and validate the response envelope.
163
164 Combines ``legacy._request`` (HTTP-level error handling) with
165 application-level ``{"Code": 200, ...}`` envelope validation.
166 Returns the parsed JSON body dict on success.
167 """
168 from modelscope.hub.errors import raise_on_error
169 resp = self._api.legacy._request(method, path, **kwargs)
170 body = resp.json()
171 raise_on_error(body)
172 return body
173
174 # ------------------------------------------------------------------
175 # OSS dataset operations

Callers 3

Calls 1

raise_on_errorFunction · 0.90

Tested by

no test coverage detected