You can upload a model to a Machine Learning repository using the frogml.log_model()
function. A model can be a single file or a list of files in a directory.
This function uses checksum upload, assigning a SHA2 value to each model for retrieval from storage. If this method fails, FrogML considers regular upload.
After uploading the model, FrogML generates a file named model-manifest.json
, which contains the model name and its related files and dependencies.
To upload a model to a Machine Learning repository, use the following function:
import frogml frogml.files.log_model( repository="<REPOSITORY_KEY>", # The JFrog repository to upload the model to. namespace="<NAMESPACE_NAME>", # Optional. The namespace or organization. model_name="<MODEL_NAME>", # The uploaded model name version="<MODEL_VERSION>", # Optional. The uploaded model version source_path="<FILE_PATH>", # The file path of the model on your machine. properties={<PROPERTIES>} # Optional. These are properties you can set on the model to categorize and label it. dependencies=[<DEPENDENCY>, <DEPENDENCY>], # Optional code_path= <CODE_PATH> )
Note
Make sure to replace the placeholders in bold with your own JFrog repository key, namespace name, model name, source path, version, properties, dependencies, and code path. If you do not specify a version, the version will be saved as the timestamp in UTC format.
Parameters
Parameter | Description | Example |
---|---|---|
<REPOSITORY_KEY> | The name of the JFrog repository you want to upload the model to |
|
<NAMESPACE_NAME> | (Optional) The name of the namespace or organization: use this parameter to group models by project or group. |
|
<MODEL_NAME> | The name of the model you want to upload |
|
<MODEL_VERSION> | (Optional) The version of the model you want to upload. If you do not add a model version, Artifactory will set the version as the timestamp of the time you uploaded the model in your time zone, in UTC format: |
|
<FILE_PATH> | The file path of the model on your machine or to the directory you want to upload. |
|
<PROPERTIES> | These are properties you can set on the model to categorize and label it, in the format: “x”: “1”, “y”: “2” |
|
<DEPENDENCIES> | A list of the package types and their corresponding versions that your project is dependent on. The following dependency types are supported:
NoteWhen providing a path to a requirements file, please provide the path as a parameter in a list. | For explicit versions:
|
<CODE_PATH> | An optional path to the code directory. When provided, the code files in the provided path will be uploaded to the Machine Learning repository together with the model artifact. |
|
Example
import frogml frogml.files.log_model( repository="frog-ml-local", namespace="frog-ml-beta", # Optional model_name="my-cool-model", version="1.0.0", # Optional source_path="~/root/models/my-cool-model/", properties={"model_type": "keras", "experiment": "my-exp"} # Optional dependencies=["numpy>=1.19"], # Optional code_path= "./src" #Optional )