def update_model_version(self, model_name, model_version, model_path=None, model_metric=None, model_flavor=None,
                             version_desc=None, current_stage=None) -> Optional[ModelVersionDetail]:
        """
        Update metadata for ModelVersion entity and metadata associated with a model version in backend.
        Either ``model_path`` or ``model_metric`` or ``model_flavor`` or ``version_desc`` should be non-None.
        Backend raises exception if a registered model with given name does not exist.

        :param model_name: Name of registered model. This is expected to be unique in the backend store.
        :param model_version: User-defined version of registered model.
        :param model_path: (Optional) Source path where the AIFlow model is stored.
        :param model_metric: (Optional) Metric address from AIFlow metric server of registered model.
        :param model_flavor: (Optional) Flavor feature of AIFlow registered model option.
        :param version_desc: (Optional) Description of registered model version.
        :param current_stage: (Optional) Current stage of registered model version.

        :return: A single updated :py:class:`ai_flow.model_center.entity.ModelVersionDetail` object.
        """
        request = UpdateModelVersionRequest(
            model_meta=ModelMetaParam(model_name=stringValue(model_name), model_version=stringValue(model_version)),
            model_version=ModelVersionParam(model_path=stringValue(model_path),
                                            model_metric=stringValue(model_metric),
                                            model_flavor=stringValue(model_flavor),
                                            version_desc=stringValue(version_desc),
                                            current_stage=current_stage))
        response = self.model_center_stub.updateModelVersion(request)
        return ModelVersionDetail.from_proto(_parse_response(response, ModelVersionMeta()))
Exemple #2
0
    def create_model_version(
        self,
        model_name,
        model_path,
        model_type=None,
        version_desc=None,
        current_stage=ModelVersionStage.GENERATED
    ) -> Optional[ModelVersionDetail]:
        """
        Create a new model version from given source and metric in Model Center.

        :param model_name: Name of registered model. This is expected to be unique in the backend store.
        :param model_path: Source path where the AIFlow model is stored.
        :param model_type: (Optional) Type of AIFlow registered model option.
        :param version_desc: (Optional) Description of registered model version.
        :param current_stage: (Optional) Stage of registered model version.

        :return: A single object of :py:class:`ai_flow.model_center.entity.ModelVersionDetail` created in
        model repository.
        """
        request = CreateModelVersionRequest(
            model_meta=ModelMetaParam(model_name=stringValue(model_name)),
            model_version=ModelVersionParam(
                model_path=stringValue(model_path),
                model_type=stringValue(model_type),
                version_desc=stringValue(version_desc),
                current_stage=current_stage))
        response = self.model_center_stub.createModelVersion(request)
        return ModelVersionDetail.from_proto(
            _parse_response(response, ModelVersionMeta()))
Exemple #3
0
 def to_meta_entity(self):
     return ModelVersionDetail(self.model_name,
                               self.model_version,
                               self.model_path,
                               self.model_type,
                               self.version_desc,
                               self.version_status,
                               self.current_stage)
 def from_detail_proto(cls, proto):
     if proto is None:
         return None
     else:
         registered_model = proto.registered_model
         latest_model_version = proto.latest_model_version
         return cls(
             registered_model.model_name, registered_model.model_desc.value
             if registered_model.HasField("model_desc") else None,
             ModelVersionDetail.from_proto(latest_model_version))
    def get_model_version_detail(self, model_name, model_version) -> Optional[ModelVersionDetail]:
        """
        Get model version detail filter by model name and model version for Model Center.

        :param model_name: Name of registered model. This is expected to be unique in the backend store.
        :param model_version: User-defined version of registered model.

        :return: A single :py:class:`ai_flow.entities.model_registry.ModelVersionDetail` object.
        """
        request = GetModelVersionDetailRequest(model_meta=ModelMetaParam(model_name=stringValue(model_name),
                                                                         model_version=stringValue(model_version)))
        response = self.model_center_stub.getModelVersionDetail(request)
        return ModelVersionDetail.from_proto(_parse_response(response, ModelVersionMeta()))