MCPcopy Create free account
hub / github.com/apple/coremltools / __api_call

Method __api_call

mlmodel/docs/readme_session.py:31–44  ·  view source on GitHub ↗
(self, api_func, endpoint, print_info, data=None)

Source from the content-addressed store, hash-verified

29
30 # Call the readme API. api_func should be a requests-based function.
31 def __api_call(self, api_func, endpoint, print_info, data=None):
32 print(print_info + "... ", end="")
33 response = api_func(
34 _readme_api_url + endpoint,
35 headers=self.__headers,
36 auth=HTTPBasicAuth(self.auth_token, ""),
37 data=data,
38 )
39 if response.status_code not in [200, 201, 204]:
40 print("Error (code " + str(response.status_code) + "): " + response.text)
41 return None
42 else:
43 print()
44 return None if api_func == requests.delete else json.loads(response.text)
45
46 # API GET call.
47 # If paginated, gather and concat the output for each page in the endpoint.

Callers 3

__api_GETMethod · 0.95
__api_POSTMethod · 0.95
__api_DELETEMethod · 0.95

Calls 2

printFunction · 0.85
strClass · 0.50

Tested by

no test coverage detected