Uploading Model Repositories in an air-gapped environment

Upload the downloaded Hugging Face and NVIDIA NGC (NIM) Model files to the remote object storage location of Cloudera AI Registry. Cloudera AI Registry imports the Model from this location.

This procedure supports uploading files to Amazon S3 or S3 protocol–compatible object storage. Mistral models are supported only in an air-gapped environments; to upload Mistral models, see Uploading a Mistral Model.

The script uploads a Model to a folder in the remote object storage location. The name of the folder depends on the source of the Model:

Table 1.
Source -rt -ri Folder in the remote object storage location
Hugging Face hf The Hugging Face Model ID hf/<repository ID>
NVIDIA NGC (NIM) ngc The optimization profile ID ngc/<repository ID after the last />
Mistral mistral The repository ID mistral/<repository ID>
  1. Get the remote object storage path of Cloudera AI Registry.
    curl --header "Cookie: hadoop-jwt=$HADOOP_JWT" https://<registry-host>/api/v3/config

    The response contains the path:{"remote_object_storage_path":"s3://<bucket>/<path>"}If the path starts with s3a://, use s3:// instead in the upload and verification commands. In the registration request, use the path exactly as returned.

  2. Set the credentials that have write access to this location. For Amazon S3, use environment variables:
    export AWS_ACCESS_KEY_ID=<access key>
    export AWS_SECRET_ACCESS_KEY=<secret key>
    export AWS_DEFAULT_REGION=<region>

    S3 protocol–compatible storage: Configure the credentials or AWS CLI profile required by your S3-compatible endpoint.

  3. Upload the files of the Model.
    python3 import_to_airgap.py --src ./models \
      --dst <remote_object_storage_path> \
      --cloud aws --repo-type <hf or ngc> --repo-id <repository ID>

    For --src, use the directory that you specified with -p when you downloaded the Model. For --repo-type and --repo-id, use the same values as for the download. To upload several Models, run the script once for each Model.

    For S3-compatible storage with its own endpoint, use --cloud pvc and add --endpoint <endpoint URL>. If a custom certificate authority issued the endpoint certificate, also add --ca-bundle <path to CA bundle file>.

    Check the output of the script. The script reports the source and the destination of the upload, and ends with the message

  4. Check the output of the script. The script reports the source and the destination of the upload, and ends with the message Upload completed.
    Start uploading  hf repository: hf-tiny-model-private/tiny-random-YosoModel
    ...
    Uploaded: ./models/hf/hf-tiny-model-private/tiny-random-YosoModel -> s3://<bucket>/<path>/hf/hf-tiny-model-private/tiny-random-YosoModel
    Finish uploading  hf repository: hf-tiny-model-private/tiny-random-YosoModel to aws
    Upload completed.
    
  5. Verify the upload.
    aws s3 ls <remote_object_storage_path>/<repository type>/<repository ID>/ --recursive
    

    For S3-compatible storage, add --endpoint-url <endpoint URL>. The list must contain the files in the artifacts folder and in the metadata folder. If files are missing, repeat the upload.

Changing the remote object storage location

The remote object storage location is configured when Cloudera AI Registry is installed. An administrator can change it with an API request:

curl -X PUT https://<registry-host>/api/v3/config \
  --header "Cookie: hadoop-jwt=$HADOOP_JWT" \
  -H "Content-Type: application/json" \
  -d '{"remote_object_storage_path": "s3://<bucket>/<path>"}'

The response contains the new path. Cloudera AI Registry must have read access to the new location. After you change the location, use the new path for --dst and in the registration requests.