def update_model( self, name: str, description: str = None, metadata: Dict[str, str] = None, active_version_name: int = None, webhook_url: str = None, ) -> Model: """Update a model. Args: name (str): Name of model to update. description (str): Description of model. metadata (Dict[str, str]): metadata about model. active_version_name (str): Active version of model. webhook_url (str): Webhook url to send notifications to upon failing scheduled predictions. Returns: Model: Updated model """ url = "/modelhosting/models/{}/update".format(name) body = {} if description: body.update({"description": {"set": description}}) if metadata: body.update({"metadata": {"set": metadata}}) if active_version_name: body.update({"activeVersionName": {"set": active_version_name}}) if webhook_url: body.update({"webhookUrl": {"set": webhook_url}}) res = self._post(url, json=body) return Model._load(res.json())
def create_model( self, name: str, description: str = "", metadata: Dict[str, Any] = None, input_fields: List[Dict[str, str]] = None, output_fields: List[Dict[str, str]] = None, webhook_url: str = None, ) -> Model: """Creates a new model Args: name (str): Name of model description (str): Description metadata (Dict[str, Any]): Metadata about model input_fields (List[str]): List of input fields the model accepts output_fields (List[str]): List of output fields the model produces webhook_url (str): Webhook url to send notifications to upon failing scheduled predictions Returns: Model: The created model. """ url = "/modelhosting/models" model_body = { "name": name, "description": description, "metadata": metadata or {}, "inputFields": input_fields or [], "outputFields": output_fields or [], } if webhook_url is not None: model_body["webhookUrl"] = webhook_url res = self._post(url, json=model_body) return Model._load(res.json())
def get_model(self, name: str) -> Model: """Get a model by name. Args: name (str): Name of model to get. Returns: Model: The requested model """ url = "/modelhosting/models/{}".format(name) res = self._get(url) return Model._load(res.json())
def deprecate_model(self, name: str) -> Model: """Deprecate a model. Args: name (str): Name of model to deprecate. Returns: Model: Deprecated model """ url = "/modelhosting/models/{}/deprecate".format(name) res = self._post(url, json={}) return Model._load(res.json())