How to Check in Large File(s) to Gerrit
Currently the OSC gerrit is configured to allow maximum git object size to be about 5 MB (to be exact: 5242880 bytes). This size limit makes the dev's life painful, as it might be a common scenario in OSC development while large data and/or AI/ML model files may need to reside in various repositories (for example, xApps and rApps). Luckily with the help from LF IT support, this can be done through the integration of a so-called "git-lfs" tool, and the large file(s) will be stored on an AWS S3 bucket created by the LF infra team. Below are the steps on how to set up the git-lfs tool and then how to utilize the tool for large file push request from a local repository:
- Setting up the git-lfs (instructions are given for a Ubuntu system):
Download the git-lfs to local and install the package:
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
sudo apt install git-lfs
Install the git-lfs tool to the local repo that needs to commit large file(s):
git lfs install
Make changes as usual, but make the git-lfs track on the large size file(s) based on its suffix (see more details here). For example, to track on a PyTorch model file with a suffix "pth"by `git lfs track "*.pth"`, which creates a .gitattributes file to be committed.
Also configure an lfs url for the git push to work -- with O-RAN SC gerrit, it has to be a HTTP url (this also means you have to set up a HTTP credential if you don't yet have one):
git config -f .lfsconfig lfs.url https://your-LFID@gerrit.o-ran-sc.org/r/a/{path-to-your-repo}.git/info/lfs
Replace with your own LFID and the corresponding repo url, respectively. Remember to add this .lfsconfig file as part of the commit.
- Now you should be able to commit one or more large size file(s) along with the newly created configuration files with the usual process. In the future, it only needs to update the .gitattributes file when additional suffix has to be tracked on in the same repo. There is a caveat though, as now it will ask to supply with your HTTP credential while cloning/checking out the repository in anonymous mode – the large file(s) won't be checked out without a valid HTTP credential.