Using a Git repo as a function hub#

You can save functions in a Git repo, and use this repo as your own function hub. This repo structure must conform with:

  • The name of the function YAML must be named function.yaml. You can use the export method to create the function yaml file.

  • The .yaml file must stored in a path like this: /function-name/function.yaml (e.g /func/function.yaml), for example:

  • If you have additional files, for example a source file or a notebook example, they can be stored in the same folder as the function.yaml.


You can use Git tags for function versioning in Git. For example, to import a function named func that has a v1 tag:

import_func_1 = mlrun.import_function('hub://func:v1')

Create and export an MLRun function from a file#

You can use the function tag to tag the function in MLRun. It is not related to the Git tag. For example, this function has a ‘version1’ tag in MLRun and a ‘v1’ tag in Git.

function = project.set_function(

Export the function to a YAML file


Import and run the function from your repo#

You can use a import function from your “Git repo function hub” by pointing to it with its full URL, for example:

Working with tags

Assume there are multiple versions in Git: v1, v2, etc. You specify which version you want by appending :tag# to the hub path. The path must be to a folder that contains the function.yaml file in the func directory.

Private repo

If working from a private repo, set:
project.set_secret({"HTTPS_AUTH_TOKEN":<Http-Token, e.g. GIT-TOKEN})

# Import the v1 tag from git:
import_func_1 = project.set_function(

# print the results

# Run the function: