rmlflowmlops

How to organize registerd models in R with mlflow?


Questions


Solution

  • I found a somewhat okeyish workaround: I just use the mlflow rest api (https://mlflow.org/docs/latest/rest-api.html#set-registered-model-alias) from R to set the alias...

    mlflowSetRegisteredModelAlias <- function(mlflowUri, modelName, alias, version) {
      # Define api request payload
      payload <- list(name = modelName,
                      alias = alias,
                      version = as.character(version))
      
      # Make the POST request
      mlflowApiEndpoint <- paste0(mlflowUri, "api/2.0/mlflow/registered-models/alias")
      response <- mlflowApiEndpoint %>%
        httr2::request() %>%
        httr2::req_body_json(payload) %>%
        httr2::req_perform()
    }
    

    For deleting an alias it would be with ad DELETE method:

     payload <- list(name = modelName, alias = alias)
      
      # Make the DELETE request
      response <-  mlflowApiEndpoint %>%
        httr2::request() %>%
        httr2::req_method("DELETE") %>%
        httr2::req_body_json(payload) %>%
        httr2::req_perform()