{"id":19653687,"url":"https://github.com/brevdev/ci-nvcf","last_synced_at":"2025-02-27T01:41:48.987Z","repository":{"id":260497023,"uuid":"881466053","full_name":"brevdev/ci-nvcf","owner":"brevdev","description":"Clone of the ci-nvcf repo","archived":false,"fork":false,"pushed_at":"2024-10-31T16:19:37.000Z","size":31,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-01-10T00:18:24.260Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/brevdev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-31T16:17:37.000Z","updated_at":"2024-10-31T16:19:40.000Z","dependencies_parsed_at":"2024-10-31T17:24:50.901Z","dependency_job_id":"2c471470-1602-46ce-bf40-fa2f0963334a","html_url":"https://github.com/brevdev/ci-nvcf","commit_stats":null,"previous_names":["brevdev/ci-nvcf"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brevdev%2Fci-nvcf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brevdev%2Fci-nvcf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brevdev%2Fci-nvcf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brevdev%2Fci-nvcf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brevdev","download_url":"https://codeload.github.com/brevdev/ci-nvcf/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240962200,"owners_count":19885448,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T15:14:52.893Z","updated_at":"2025-02-27T01:41:48.970Z","avatar_url":"https://github.com/brevdev.png","language":"Python","readme":"# ci-nvcf\n\n## Overview\n\nThis repo provides a starting point for automating NVCF function deployments and updates using GitHub Actions. At a high level, we have a file named `launch-list.yml` that contains a list of functions we want to deploy. Everytime you push an update to main, the provided workflows will build and push your Docker image to NGC, update the `launch-list.yml` with the new image tag, and then deploy the function(s) to NGC using the `launch-nvcf.py` script.\n\nThis repo is designed to be modular. You can simply clone this repo and start modifying workflows to fit your needs or use this as a reference to build your own.\n\n## Getting Started\n\n1. **GitHub Secrets**:\n   Ensure the following secrets are configured in your GitHub repository. Note that any environment variables prefixed with `FN_` will be automatically consumed by the Jinja2 template:\n   - `PRD_NVCF_API_KEY`: Required to manage your functions and function lifecycles.\n   - `FN_NGC_ORG`: Your NGC organization name.\n   - `FN_NGC_TEAM`: Your NGC team name.\n   - `FN_HUGGING_FACE_HUB_TOKEN`: If using Hugging Face models (optional).\n   - Any additional `FN_*` variables required by your specific setup.\n\n2. **NGC Setup**:\n   - Push your **Container Image** to the NGC Private Registry (nvcr.io) correlated to your org and/or team.\n   - If necessary, push any referenced **Models** to the NGC Private Registry.\n   - Note: Using workflows to automatically push to NGC will differ depending on your current container CI. Take a look at `docs/container-ci-setup.md` for some inspiration.\n\n3. **Repository Configuration**:\n   - Clone this repository into your Github account\n   - Update `launch-list.yml` with your image tag and function configurations\n   - Adjust the `launch-template.yml.j2` to define baseline function configurations. You'll need to edit this if you plan to use models from NGC.\n\n## Key Components\n\n1. `launch-nvcf.py`: The main Python script that handles the deployment of NVCF functions.\n2. `launch-list.yml`: Configuration file defining the functions to be deployed.\n3. `launch-template.yml.j2`: Jinja2 template for generating function configurations.\n4. `update-launch-list.py`: Script to update the `launch-list.yml` with new image tags. We use this to signal a new version of the container image to be deployed.\n5. GitHub Action workflows:\n   - `push-to-ngc.yaml`: Builds and pushes your container image to NGC\n   - `deploy.yaml`: Handles the deployment of functions.\n\n## Workflow Pipeline\n\n#### 1. Push to NGC (`push-to-ngc.yml`)\n\nThis workflow is responsible for building and pushing your container image to NGC. It also updates the `launch-list.yml` with the new image tag.\n\n#### 2. Deploy Function (`deploy.yml`)\n\nThis workflow deploys the function(s) defined in `launch-list.yml` to NGC using the `launch-nvcf.py` script. This script is a wrapper around the NGC API that handles the creation and management of NVCF functions.\n\n## Local Execution \u0026 Testing\n\nTo test the deployment process locally:\n\n1. **Set Environment Variables**:\n\n```bash\nexport PRD_NVCF_API_KEY=\"your_ngc_org_api_key\"\nexport FN_NGC_ORG=\"your_ngc_org\"\nexport FN_NGC_TEAM=\"your_ngc_team\"\nexport FN_SAMPLE_FUNCTION_NAME=inference-l40sx1 # correlates to function list item\nexport FN_HUGGING_FACE_HUB_TOKEN=\"hf_xxxx\"\n# Optional\nexport FN_NGC_MODEL=sample-model\nexport FN_NGC_MODEL_VERSION=0.1\n```\n\n2. **Install Prerequisites**:\n\n```bash\npip install virtualenv\nvirtualenv .venv\nsource .venv/bin/activate\npip install yq pydantic PyYAML Jinja2 colorlog pytz requests\n```\n\n3. **Run the Deployment Script**:\n\n```bash\npython3 launch-nvcf.py --manifest templates/launch-template.yml.j2 --environment production --function-name ${FN_SAMPLE_FUNCTION_NAME}\n```\n\nYou can also manually trigger the `test-` workflows\n\n## Using Models\n\nIf referencing any models (i.e. for volume mounts) ensure these models exist and have been uploaded to NGC:\n\n```bash\nngc registry model --org ${FN_NGC_ORG} create --application Other --framework Other --precision Other --format Other --short-desc ${FN_NGC_MODEL} ${FN_NGC_ORG}/${FN_NGC_TEAM}/${FN_NGC_MODEL}\n\ncd your/model/dir\n\nngc registry model --org ${FN_NGC_ORG} --team ${FN_NGC_TEAM} upload-version ${FN_NGC_ORG}/${FN_NGC_TEAM}/${FN_NGC_MODEL}:${FN_NGC_MODEL_VERSION}\n```\n\n## Notes\n\n- These Github actions reference a prebuilt image with all prereqs installed: quay.io/liveaverage/ci-builder:latest (https://github.com/liveaverage/ci-builder)\n\n### Diagram\n\n```mermaid\ngraph TD\n    A[launch-list.yml] --\u003e|Provides function configurations| B[launch-template.yml.j2]\n    C[Environment Variables FN_*] --\u003e|Provides dynamic values| B\n    B --\u003e|Rendered template| D[launch-nvcf.py]\n    E[GitHub Secrets] --\u003e|Provides sensitive data| D\n    D --\u003e|Deploys functions| F[NGC API NVCF Functions]\n    G[GitHub Actions deploy.yml] --\u003e|Triggers| D\n    H[User Input function_name] --\u003e|Specifies function to deploy| G\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrevdev%2Fci-nvcf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrevdev%2Fci-nvcf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrevdev%2Fci-nvcf/lists"}