Log File-Based Models

JFrog Artifactory Documentation

Products
JFrog Artifactory
Content Type
User Guide

This is a universal, format-agnostic method for loading file-based models. The model must be a single file and cannot be a directory of files. For information about logging format-aware file types, see Format-Aware Models.

You can upload a single model file to a Machine Learning repository using the frogml.log_model() function. This function uses checksum-based storage. Artifactory calculates a checksum for each file and uploads it only if the file does not already exist in the repository.Checksum-Based Storage

After uploading the model, FrogML generates a file named model-manifest.json, which contains the model name and its related files and dependencies.

To log machine learning models:

Run the following command:

import frogml
frogml.files.log_model(
   source_path="<MODEL_FILE>",
   repository="<REPO_NAME>",
   model_name="<MODEL_NAME>",
   version="<MODEL_VERSION>", #optional
   properties = {"<KEY1>": "<VALUE1>"}, # optional
   dependencies = ["<MODEL_DEPENDENCIES>"], # optional
   code_dir = "<CODE_PATH>", # optional
   parameters = {"<HYPERPARAM_NAME>": "<VALUE>"}, # optional
   metrics = {"<METRIC_NAME>": "<VALUE>"}, # optional
   predict_file = "<PREDICT_PATH>", # optional
)

Important

The parameters code_dir, dependencies, and predict_file must be provided as a complete set. You must specify all of them or none at all.

Where:

  • <MODEL_FILE>: The local path to the model file you want to upload

  • <REPO_NAME>: The name of the target repository in Artifactory

  • <MODEL_NAME>: The unique name of the model

  • <MODEL_VERSION> (Optional): The version of the model you want to upload. If version is not specified, the current timestamp is used

  • <KEY1> and <VALUE1> (Optional): Properties key pair values to add searchable metadata to the model (optional). Separate multiple key pairs with a comma

  • <MODEL_DEPENDENCIES> (Optional): Dependencies required to run the model, in one of the following formats:

    • A list of specific package requirements, for example ["catboost==1.2.5", "scikit-learn==1.3.2"]

    • A path to a single requirements.txt , pyproject.toml, or conda.yml package manager file

    • A two-item list containing paths to the Poetry files pyproject.toml and poetry.lock

  • <CODE_PATH> (Optional): The path to the directory containing the source code

  • <HYPERPARAM_NAME> and <VALUE> (Optional): Hyperparameters used to train the model

  • <METRIC_NAME> and <VALUE> (Optional): Metrics key pair values to add searchable numeric metadata to the model. Separate multiple key pairs with a comma

  • <PREDICT_PATH> (Optional): The path to a script that defines how to make predictions with the model.

For example:

import frogml

frogml.files.log_model(
   source_path="./models/prod_churn_model_v1.4.rds",
   repository="ml-local",
   model_name="ranger-randomforest-classifier",
   version="1.4",
   properties={
       "framework": "R",
       "r-version": "4.4.1",
       "algorithm-package": "ranger",
       "model-type": "binary-classifier",
       "trained-by": "data-science-team"
   },
   metrics={"validation-auc": 0.89},
)

Note

You can also use JFrog Set me up to copy the snippet populated with your token and environment. For more information, see Use Artifactory Set Me Up for Configuring Package Manager Clients.