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

Method create

modelscope/hub/deploy.py:198–242  ·  view source on GitHub ↗

Deploy model to cloud, current we only support PAI EAS, this is an async API , and the deployment could take a while to finish remotely. Please check deploy instance status separately via checking the status. Args: model_id (str): The deployed model id

(self, model_id: str, revision: str, instance_name: str,
               resource: ServiceResourceConfig,
               provider: ServiceProviderParameters)

Source from the content-addressed store, hash-verified

196
197 # deploy_model
198 def create(self, model_id: str, revision: str, instance_name: str,
199 resource: ServiceResourceConfig,
200 provider: ServiceProviderParameters):
201 """Deploy model to cloud, current we only support PAI EAS, this is an async API ,
202 and the deployment could take a while to finish remotely. Please check deploy instance
203 status separately via checking the status.
204
205 Args:
206 model_id (str): The deployed model id
207 revision (str): The model revision
208 instance_name (str): The deployed model instance name.
209 resource (ServiceResourceConfig): The service resource information.
210 provider (ServiceProviderParameters): The service provider parameter
211
212 Raises:
213 NotSupportError: Not supported platform.
214 RequestError: The server return error.
215
216 Returns:
217 ServiceInstanceInfo: The information of the deployed service instance.
218 """
219 if provider.vendor != Vendor.EAS:
220 raise NotSupportError(
221 'Not support vendor: %s ,only support EAS current.' %
222 (provider.vendor))
223 create_params = DeployServiceParameters(
224 instance_name=instance_name,
225 model_id=model_id,
226 revision=revision,
227 resource=resource,
228 provider=provider)
229 path = f'{self.endpoint}/api/v1/deployer/endpoint'
230 body = asdict(create_params)
231 r = requests.post(
232 path, json=body, cookies=self.cookies, headers=self.headers)
233 handle_http_response(r, logger, self.cookies, 'create_service')
234 if r.status_code >= HTTPStatus.OK and r.status_code < HTTPStatus.MULTIPLE_CHOICES:
235 if is_ok(r.json()):
236 data = r.json()[API_RESPONSE_FIELD_DATA]
237 return data
238 else:
239 raise RequestError(r.json()[API_RESPONSE_FIELD_MESSAGE])
240 else:
241 raise_for_http_status(r)
242 return None
243
244 def get(self, instance_name: str, provider: ServiceProviderParameters):
245 """Query the specified instance information.

Callers 5

create_envMethod · 0.45
__init__Method · 0.45
_load_modelMethod · 0.45
__init__Method · 0.45
_load_modelMethod · 0.45

Calls 6

NotSupportErrorClass · 0.90
handle_http_responseFunction · 0.90
is_okFunction · 0.90
RequestErrorClass · 0.90
raise_for_http_statusFunction · 0.90

Tested by

no test coverage detected