### Install Image Credential Helper Example Source: https://github.com/nvidia/nvcf/blob/main/src/compute-plane-services/image-credential-helper/examples/README.md Run this script to install the example. Ensure you are in the project root directory. ```shell ./examples/run.sh ``` -------------------------------- ### Local Development Setup with Make Source: https://github.com/nvidia/nvcf/blob/main/src/control-plane-services/nats-auth-callout/README.md Install dependencies and Air, then start development with hot reloading for automatic restarts on file changes. ```shell make go-install-deps go install github.com/air-verse/air@latest make dev ``` -------------------------------- ### Install Objx Source: https://github.com/nvidia/nvcf/blob/main/src/compute-plane-services/nvca/vendor/github.com/stretchr/objx/README.md Use 'go get' to install the Objx package. ```bash go get github.com/stretchr/objx ``` -------------------------------- ### Example Helm Chart Installation Source: https://github.com/nvidia/nvcf/blob/main/deploy/helm/nats/README.md An example of how to install the NATS Helm chart with a specific release name, namespace, and values file. ```bash helm install nvcf-nats . \ --namespace nats-system \ --create-namespace \ --values values.yaml ``` -------------------------------- ### Installation Example: SQLite (Default) Source: https://github.com/nvidia/nvcf/blob/main/src/control-plane-services/nats-auth-callout/deploy/README.md Install the Helm chart with default settings, which uses SQLite as the database provider. ```bash helm install my-release ./deploy ``` -------------------------------- ### Install sigs.k8s.io/yaml Source: https://github.com/nvidia/nvcf/blob/main/src/libraries/go/lib/vendor/sigs.k8s.io/yaml/README.md Install the library using the go get command. ```bash $ go get sigs.k8s.io/yaml ``` -------------------------------- ### Install Mergo Source: https://github.com/nvidia/nvcf/blob/main/src/compute-plane-services/image-credential-helper/vendor/dario.cat/mergo/README.md Install the Mergo library using the go get command. This is the first step before using it in your Go code. ```go go get dario.cat/mergo ``` -------------------------------- ### Install Afero Package Source: https://github.com/nvidia/nvcf/blob/main/src/compute-plane-services/nvca/vendor/github.com/spf13/afero/README.md Use go get to install the Afero package. This command fetches and installs the specified package and its dependencies. ```bash go get github.com/spf13/afero ``` -------------------------------- ### Install Locafero Source: https://github.com/nvidia/nvcf/blob/main/src/compute-plane-services/nvca/vendor/github.com/sagikazarmark/locafero/README.md Use this command to install the Locafero library using go get. ```shell go get github.com/sagikazarmark/locafero ``` -------------------------------- ### Install lo Library Source: https://github.com/nvidia/nvcf/blob/main/src/compute-plane-services/nvca/vendor/github.com/samber/lo/README.md Install the lo library using go get. This library is v1 and follows SemVer strictly. ```bash go get github.com/samber/lo@v1 ``` -------------------------------- ### Install Mergo Source: https://github.com/nvidia/nvcf/blob/main/src/compute-plane-services/nvca/vendor/github.com/imdario/mergo/README.md Install the Mergo library using go get. ```bash go get github.com/imdario/mergo ``` -------------------------------- ### Install Control Plane and Register Compute Planes Source: https://github.com/nvidia/nvcf/blob/main/ai-tooling/user/skills/nvcf-self-managed-cli/examples/multi-cluster.md This snippet shows the initial setup for a multi-cluster environment. First, it installs the control plane, then it iterates through a list of contexts to register and install each compute plane. ```sh # 1. Bring up the control plane (one-time, on the control-plane cluster): KUBECONFIG=cp.yaml nvcf-cli self-hosted install --control-plane | kubectl apply -f - nvcf-cli self-hosted check --control-plane --wait 5m # 2. Register + install each compute plane: for CTX in admin@gpu-east-1 admin@gpu-west-1 admin@gpu-eu-1; do NAME=$(echo "$CTX" | cut -d@ -f2) nvcf-cli self-hosted up \ --cluster-name=$NAME \ --compute-plane-context=$CTX \ --icms-url=https://icms.nvcf.example.com \ --token=$NVCF_ADMIN_JWT \ --non-interactive \ --json done # 3. Verify all compute planes registered: nvcf-cli cluster list --json | jq '.clusters[] | {name, region, lastHeartbeat}' ``` -------------------------------- ### Example Dockerfile Source: https://github.com/nvidia/nvcf/blob/main/docs/user/container-functions.md Sets up an NVIDIA-optimized base container, installs Python requirements, copies model code, and configures the run command. ```dockerfile FROM nvcr.io/nvidia/cuda:12.1.1-devel-ubuntu22.04 RUN apt-get update && apt-get install -y \ git \ python3 \ python3-pip \ python-is-python3 \ libsm6 \ libxext6 \ libxrender-dev \ curl \ && rm -rf /var/lib/apt/lists/* WORKDIR /workspace/ # Install requirements file COPY requirements.txt requirements.txt RUN pip install --no-cache-dir --upgrade pip RUN pip install --no-cache-dir -r requirements.txt ENV DEBIAN_FRONTEND=noninteractive # Copy model source code and weights COPY model_weights /models COPY model_source . COPY run.py . # Set run command to start PyTriton to serve the model CMD python3 run.py ``` -------------------------------- ### Check Prerequisites with NVCF CLI Source: https://github.com/nvidia/nvcf/blob/main/docs/user/quickstart.md Before running the quickstart installation, verify that all prerequisites are met using this command. ```bash nvcf-cli self-hosted check --pre ``` -------------------------------- ### Install Viper Source: https://github.com/nvidia/nvcf/blob/main/src/compute-plane-services/nvca/vendor/github.com/spf13/viper/README.md Install the Viper library using go get. Viper uses Go Modules for dependency management. ```shell go get github.com/spf13/viper ``` -------------------------------- ### Update Examples Source: https://github.com/nvidia/nvcf/blob/main/src/compute-plane-services/byoo-otel-collector/AGENTS.md Regenerates example configurations after modifying templates. Always verify generated examples before committing. ```bash make update-examples ``` -------------------------------- ### Setup Source: https://github.com/nvidia/nvcf/blob/main/src/compute-plane-services/nvca/vendor/github.com/urfave/cli/v2/godoc-current.txt Performs initialization to prepare the application for running or inspection. ```APIDOC ## App.Setup() ### Description The `Setup` method runs essential initialization code to ensure that all internal data structures are correctly set up and ready for the `Run` method or for inspection prior to execution. This method is called internally by `Run` and will return early if the setup has already been completed. ### Signature ```go func (a *App) Setup() ``` ``` -------------------------------- ### Install Protobuf Compiler Source: https://github.com/nvidia/nvcf/blob/main/src/libraries/go/lib/vendor/github.com/go-kit/kit/transport/grpc/README.md Installs the protobuf compiler from source using Homebrew. Ensure autoconf, automake, and libtool are installed first. ```shell brew install autoconf automake libtool git clone https://github.com/google/protobuf cd protobuf ./autogen.sh ; ./configure ; make ; make install ``` -------------------------------- ### Full Example: Basic Mux Server Source: https://github.com/nvidia/nvcf/blob/main/src/compute-plane-services/nvca/vendor/github.com/gorilla/mux/README.md A complete, runnable example of a small web server using Gorilla Mux. It demonstrates setting up a router and handling a basic route. ```Go package main import ( "net/http" "log" "github.com/gorilla/mux" ) func YourHandler(w http.ResponseWriter, r *http.Request) { w.Write([]byte("Gorilla!\n")) } func main() { r := mux.NewRouter() // Routes consist of a path and a handler function. r.HandleFunc("/", YourHandler) // Bind to a port and pass our router in log.Fatal(http.ListenAndServe(":8000", r)) } ``` -------------------------------- ### Setup Source: https://github.com/nvidia/nvcf/blob/main/src/libraries/go/lib/vendor/github.com/urfave/cli/v2/godoc-current.txt Performs initialization to prepare data structures for `Run` or inspection before `Run` is called. ```APIDOC ## Setup ### Description Runs initialization code to ensure all data structures are ready for `Run` or inspection prior to `Run`. It is internally called by `Run`, but will return early if setup has already happened. ### Signature `func (a *App) Setup()` ``` -------------------------------- ### Install go.uber.org/atomic Source: https://github.com/nvidia/nvcf/blob/main/src/libraries/go/lib/vendor/go.uber.org/atomic/README.md Install the atomic package using go get. ```shell $ go get -u go.uber.org/atomic@v1 ``` -------------------------------- ### Example Environment Variables Configuration Source: https://github.com/nvidia/nvcf/blob/main/src/control-plane-services/nats-auth-callout/docs/CONFIGURATION.md Shows how to configure the service using environment variables with the specified prefix. ```bash # Environment Variables: NVCF_NATS_AUTH_CALLOUT_SERVICE_SERVER_PORT=8080 NVCF_NATS_AUTH_CALLOUT_SERVICE_SERVICE_NAME=my-service NVCF_NATS_AUTH_CALLOUT_SERVICE_SECRETS_FILE_PATH=secrets.json ``` -------------------------------- ### Install mapstructure Source: https://github.com/nvidia/nvcf/blob/main/src/compute-plane-services/nvca/vendor/github.com/go-viper/mapstructure/v2/README.md Use go get to install the mapstructure library. This command fetches and installs the specified package. ```shell go get github.com/go-viper/mapstructure/v2 ``` -------------------------------- ### Example File Read Source: https://github.com/nvidia/nvcf/blob/main/src/compute-plane-services/ess-agent/docs/templating-language.md Demonstrates reading the content of a specific local file. ```Go {{ file "/path/to/my/file" }} ``` -------------------------------- ### Install json-iterator/go Source: https://github.com/nvidia/nvcf/blob/main/src/compute-plane-services/image-credential-helper/vendor/github.com/json-iterator/go/README.md Install the json-iterator/go library using the go get command. ```bash go get github.com/json-iterator/go ``` -------------------------------- ### Clone and Setup Repository Source: https://github.com/nvidia/nvcf/blob/main/src/libraries/go/lib/vendor/go.uber.org/automaxprocs/CONTRIBUTING.md Steps to fork, clone the repository, and set up remote upstream for contributing. ```bash mkdir -p $GOPATH/src/go.uber.org cd $GOPATH/src/go.uber.org git clone git@github.com:your_github_username/automaxprocs.git cd automaxprocs git remote add upstream https://github.com/uber-go/automaxprocs.git git fetch upstream ``` -------------------------------- ### Install automemlimit Source: https://github.com/nvidia/nvcf/blob/main/src/libraries/go/lib/vendor/github.com/KimMachineGun/automemlimit/README.md Install the latest version of the automemlimit library using go get. ```shell go get github.com/KimMachineGun/automemlimit@latest ``` -------------------------------- ### Install conc Package Source: https://github.com/nvidia/nvcf/blob/main/src/compute-plane-services/nvca/vendor/github.com/sourcegraph/conc/README.md Install the conc package using the go get command. ```sh go get github.com/sourcegraph/conc ``` -------------------------------- ### Example Configuration File Source: https://github.com/nvidia/nvcf/blob/main/examples/function-samples/helmchart-samples/multi-node-helm-function-test/README.md Example of a populated config.env file with NVCF credentials. ```bash KEY="" FUNCTION_ID="ce460ed1-6f17-4bdc-ad6b-00a569fc780d" GATEWAY_ADDR="a1b2c3d4.us-east-1.elb.amazonaws.com" ``` -------------------------------- ### Install Ray Serve Sample (CPU, ARM64) Source: https://github.com/nvidia/nvcf/blob/main/examples/function-samples/helmchart-samples/ray-serve-sample/README.md Installs the Ray Serve sample Helm chart for CPU-only testing on Apple Silicon (ARM64). Uses the aarch64 image tag and sets memory resources. ```bash helm install ray-serve-sample ./ray-serve \ --set gpu.count=0 \ --set image.tag=2.40.0-py310-aarch64 \ --set resources.requests.memory=2Gi \ --set resources.limits.memory=4Gi ``` -------------------------------- ### Example Initial Keyspace Migrations Source: https://github.com/nvidia/nvcf/blob/main/migrations/cassandra/README.md Illustrates the conventional sequence for initializing a new keyspace, including creating the keyspace, roles, and canonical schema. ```text 01_init_keyspace.up.sql - creates the keyspace with NetworkTopologyStrategy (uses {{ $replicaCount }} template variable, substituted upstream). 02_init_roles.up.sql - creates the application role and grants, with the login password supplied by ${SERVICE_ROLE_PASSWORD}. 03_init_tables.up.sql - the canonical schema (UDTs, tables, indexes) for the keyspace. ``` -------------------------------- ### Install go.yaml.in/yaml/v3 Source: https://github.com/nvidia/nvcf/blob/main/src/compute-plane-services/image-credential-helper/vendor/go.yaml.in/yaml/v3/README.md Install the YAML package for Go using the go get command. ```bash go get go.yaml.in/yaml/v3 ``` -------------------------------- ### Build and Run with Make Source: https://github.com/nvidia/nvcf/blob/main/src/control-plane-services/nats-auth-callout/README.md Build the server binary and run it using the Makefile. Also includes running directly with Go. ```shell make build ./nvcf-nats-auth-callout-service server # Or run directly with Go make run ``` -------------------------------- ### Install Ray Serve Sample (CPU, AMD64) Source: https://github.com/nvidia/nvcf/blob/main/examples/function-samples/helmchart-samples/ray-serve-sample/README.md Installs the Ray Serve sample Helm chart for CPU-only testing on AMD64 architecture. Disables GPU requests. ```bash helm install ray-serve-sample ./ray-serve \ --set gpu.count=0 \ --set image.tag=2.40.0-py310 ``` -------------------------------- ### Install go.uber.org/multierr Source: https://github.com/nvidia/nvcf/blob/main/src/compute-plane-services/nvca/vendor/go.uber.org/multierr/README.md Install the latest version of the multierr library using the go get command. ```bash go get -u go.uber.org/multierr@latest ``` -------------------------------- ### Instantiation with Options Source: https://github.com/nvidia/nvcf/blob/main/src/compute-plane-services/nvca/vendor/go.opentelemetry.io/otel/CONTRIBUTING.md Demonstrates how to instantiate a type using a variadic Option parameter. Any required parameters can precede the options. ```go func NewT(options ...Option) T {…} ``` -------------------------------- ### Install Cobra Library Source: https://github.com/nvidia/nvcf/blob/main/src/compute-plane-services/nvca/vendor/github.com/spf13/cobra/README.md Install the latest version of the Cobra library using go get. ```bash go get -u github.com/spf13/cobra@latest ``` -------------------------------- ### Example CLI Configuration Flags Source: https://github.com/nvidia/nvcf/blob/main/src/control-plane-services/nats-auth-callout/docs/CONFIGURATION.md Demonstrates how to set core service configuration options using command-line flags. ```bash # CLI Flags: --port 8080 --service-name my-service --config config.yaml --secrets-file secrets.json ``` -------------------------------- ### Install Blackfriday v2 Source: https://github.com/nvidia/nvcf/blob/main/src/libraries/go/lib/vendor/github.com/russross/blackfriday/v2/README.md Install the Blackfriday v2 package using go get in module mode. ```go go get github.com/russross/blackfriday/v2 ``` -------------------------------- ### Install and Import YAML Package Source: https://github.com/nvidia/nvcf/blob/main/src/compute-plane-services/image-credential-helper/vendor/sigs.k8s.io/yaml/README.md Install the package using go get and import it into your Go project. ```bash $ go get sigs.k8s.io/yaml ``` ```go import "sigs.k8s.io/yaml" ``` -------------------------------- ### Example requirements.txt Source: https://github.com/nvidia/nvcf/blob/main/docs/user/container-functions.md Lists Python dependencies for your model, including nvidia-pytriton. ```text --extra-index-url https://pypi.ngc.nvidia.com opencv-python-headless pycocotools matplotlib torch==2.1.0 nvidia-pytriton==0.3.0 numpy ``` -------------------------------- ### Basic Command Line Usage Source: https://github.com/nvidia/nvcf/blob/main/src/control-plane-services/nats-auth-callout/docs/CONFIGURATION.md Start the service with basic configuration, including port and service name, using command-line flags. ```bash # Basic usage ./nvcf-nats-auth-callout-service server --port 9090 --service-name my-service ``` -------------------------------- ### NVCF CLI Fresh Setup Workflow Source: https://github.com/nvidia/nvcf/blob/main/src/clis/nvcf-cli/USAGE-GUIDE.md Demonstrates the recommended setup workflow where the CLI generates and manages tokens automatically in the state file. ```bash # 1. User gets CLI and runs init # Token generated and saved to state file # DEBUG: Successfully generated admin token, expires: 2025-10-15 14:16:21 ``` ```bash # 2. User runs commands - tokens work automatically ./nvcf-cli list functions --debug # DEBUG: NVCF_TOKEN loaded from: state # Uses token from state file seamlessly ``` -------------------------------- ### Helm Validation Error Examples Source: https://github.com/nvidia/nvcf/blob/main/src/control-plane-services/nats-auth-callout/deploy/README.md Examples of common validation errors encountered during Helm chart installation for invalid configurations. ```bash Error: When database.provider is 'postgres', either postgres.existingSecret must be set OR both postgres.username and postgres.password must be provided ``` ```bash Error: Unsupported database provider 'mysql'. Supported providers are: postgres, postgresql, sqlite, sqlite3 ``` ```bash Error: When metrics.enabled is true, metrics.port must be specified ``` ```bash Error: When metrics.enabled is false, metrics.serviceMonitor.enabled cannot be true. ServiceMonitor requires metrics to be enabled. ``` ```bash Error: When metrics.enabled is false, dashboard.enabled cannot be true. Dashboard requires metrics to be enabled. ``` -------------------------------- ### Install blackfriday-tool Source: https://github.com/nvidia/nvcf/blob/main/src/libraries/go/lib/vendor/github.com/russross/blackfriday/v2/README.md Download and install the blackfriday-tool command-line utility. ```go go get github.com/russross/blackfriday-tool ``` -------------------------------- ### Install and Run Local Go Doc Site Source: https://github.com/nvidia/nvcf/blob/main/src/compute-plane-services/nvca/vendor/go.opentelemetry.io/otel/CONTRIBUTING.md Installs the pkgsite tool and runs a local Go documentation site. This is useful for previewing package documentation locally. ```sh go install golang.org/x/pkgsite/cmd/pkgsite@latest pkgsite ``` -------------------------------- ### Install Gorilla Mux Source: https://github.com/nvidia/nvcf/blob/main/src/compute-plane-services/nvca/vendor/github.com/gorilla/mux/README.md Install the gorilla/mux package using the go get command. Ensure your Go toolchain is correctly configured. ```shell go get -u github.com/gorilla/mux ``` -------------------------------- ### Complete Workflow Example Source: https://github.com/nvidia/nvcf/blob/main/src/clis/nvcf-cli/README.md A step-by-step example of a complete workflow using the NCF CLI, from initialization to cleanup. ```bash # 1. Initialize with fresh admin token nvcf-cli init # 2. Generate API key for invocations nvcf-cli api-key generate --description "Demo key" # 3. Create function (context automatically saved) nvcf-cli create --input-file examples/create-function.json # 4. Deploy function (uses saved context automatically) nvcf-cli deploy # 5. Invoke function (uses saved context and API key automatically) nvcf-cli invoke --request-body '{"message": "hello world"}' # 6. Check everything is working nvcf-cli status # 7. Clean up when done nvcf-cli undeploy # New undeploy command! nvcf-cli delete # Uses saved context ``` -------------------------------- ### Install NVCF Single-Cluster Source: https://github.com/nvidia/nvcf/blob/main/ai-tooling/user/skills/nvcf-self-managed-cli/SKILL.md Installs both the control plane and compute plane on the current Kubernetes cluster context. Use for initial setup. ```bash nvcf-cli self-hosted up --cluster-name=ncp-local ``` -------------------------------- ### Generate Documentation with Custom Configuration Source: https://github.com/nvidia/nvcf/blob/main/src/compute-plane-services/byoo-otel-collector/generator/README.md This example shows how to generate documentation with a custom configuration file and a custom output filename. It also specifies a custom source template folder. ```bash uv run -m generator \ ---document-output-dir doc \ ---template-output-dir gen \ --config ./source-config.yaml \ --document-filename METRICS.md \ --source-template-folder internal/otelconfig/templates ``` -------------------------------- ### Starting and Stopping gocron Scheduler Source: https://github.com/nvidia/nvcf/blob/main/src/libraries/go/lib/vendor/github.com/go-co-op/gocron/README.md Provides examples of how to start the gocron scheduler asynchronously or by blocking the current execution path, and how to stop the scheduler. ```golang // you can start running the scheduler in two different ways: // starts the scheduler asynchronously s.StartAsync() // starts the scheduler and blocks current execution path s.StartBlocking() // stop the running scheduler in two different ways: // stop the scheduler s.Stop() // stop the scheduler and notify the `StartBlocking()` to exit s.StopBlockingChan() ``` -------------------------------- ### Install Mock Server Dependencies Source: https://github.com/nvidia/nvcf/blob/main/src/control-plane-services/function-autoscaler/README.md Installs the necessary Python dependencies for the mock NVCF API server. This is required before manually starting the server. ```bash cd local_env/mock_server pip install -r requirements.txt ``` -------------------------------- ### Logging and Compression Handler Example Source: https://github.com/nvidia/nvcf/blob/main/src/compute-plane-services/nvca/vendor/github.com/gorilla/handlers/README.md Demonstrates how to use LoggingHandler for logging requests to stdout and CompressHandler for gzipping responses with net/http. ```go import ( "net/http" "github.com/gorilla/handlers" ) func main() { r := http.NewServeMux() // Only log requests to our admin dashboard to stdout r.Handle("/admin", handlers.LoggingHandler(os.Stdout, http.HandlerFunc(ShowAdminDashboard))) r.HandleFunc("/", ShowIndex) // Wrap our server with our gzip handler to gzip compress all responses. http.ListenAndServe(":8000", handlers.CompressHandler(r)) } ``` -------------------------------- ### Start Development Environment Source: https://github.com/nvidia/nvcf/blob/main/src/control-plane-services/nats-auth-callout/local-dev/README.md Use this command to start the local development environment. It can be run with observability profiles for tracing and metrics. ```bash # Start development environment (basic) devspace dev # Start development with observability profiles devspace dev -p tracing devspace dev -p metrics devspace dev -p obs ``` -------------------------------- ### Rendered Varnish Configuration Example Source: https://github.com/nvidia/nvcf/blob/main/src/compute-plane-services/ess-agent/examples/varnish.md An example of a Varnish configuration file rendered by Consul Template, showing backend definitions and load balancing setup. ```text import directors; backend consul_consul { .host = "104.131.109.106"; .port = "8300";" } sub vcl_init { new bar = directors.round_robin(); bar.add_backend(consul_consul); } sub vcl_recv { set req.backend_hint = bar.backend(); } ``` -------------------------------- ### Install and Use Crypt CLI for Remote Config Source: https://github.com/nvidia/nvcf/blob/main/src/libraries/go/lib/vendor/github.com/spf13/viper/README.md Steps to install the crypt CLI tool and use it to set and get configuration values from a key/value store. ```bash $ go get github.com/sagikazarmark/crypt/bin/crypt $ crypt set -plaintext /config/hugo.json /Users/hugo/settings/config.json ``` ```bash $ crypt get -plaintext /config/hugo.json ``` -------------------------------- ### Building Cloud-Agnostic Applications with Afero Source: https://github.com/nvidia/nvcf/blob/main/src/compute-plane-services/nvca/vendor/github.com/spf13/afero/README.md Demonstrates how to write applications that can work with any Afero-compatible filesystem, including local disk, cloud storage, and in-memory implementations, by abstracting filesystem interactions. ```Go type DocumentProcessor struct { fs afero.Fs } func NewDocumentProcessor(fs afero.Fs) *DocumentProcessor { return &DocumentProcessor{fs: fs} } func (p *DocumentProcessor) Process(inputPath, outputPath string) error { content, err := afero.ReadFile(p.fs, inputPath) if err != nil { return err } processed := processContent(content) return afero.WriteFile(p.fs, outputPath, processed, 0644) } // Use with local filesystem processor := NewDocumentProcessor(afero.NewOsFs()) // Use with Google Cloud Storage processor := NewDocumentProcessor(gcsFS) // Use with in-memory filesystem for testing processor := NewDocumentProcessor(afero.NewMemMapFs()) ``` -------------------------------- ### Start Consul Agent with Service Configuration Source: https://github.com/nvidia/nvcf/blob/main/src/compute-plane-services/ess-agent/examples/nginx-connect-proxy.md Starts the Consul agent in development mode with configurations for 'ingress' and 'webserver' services. Ensure Consul is installed and accessible. ```shell $ consul agent -dev -log-level=info -config-file=consul-services.json ``` -------------------------------- ### Download and Prepare golang-migrate Binaries Source: https://github.com/nvidia/nvcf/blob/main/migrations/cassandra/README.md Download the golang-migrate binary for amd64 and arm64 architectures, place them in the 'files/' directory, and make them executable. ```bash # amd64 curl -L https://github.com/golang-migrate/migrate/releases/download/v4.18.2/migrate.linux-amd64.tar.gz \ | tar xz -C files/ mv files/migrate files/migrate-amd64 chmod +x files/migrate-amd64 # arm64 (run on / for an arm64 build) curl -L https://github.com/golang-migrate/migrate/releases/download/v4.18.2/migrate.linux-arm64.tar.gz \ | tar xz -C files/ mv files/migrate files/migrate-arm64 chmod +x files/migrate-arm64 ``` -------------------------------- ### Install NVCF Helm Chart Source: https://github.com/nvidia/nvcf/blob/main/docs/user/standalone-deployment.md Example command to install or upgrade an NVCF Helm chart using `helm upgrade --install`. This command specifies the release name, namespace, chart source, version, and a values file. ```bash helm upgrade --install api -n nvcf \ oci:////helm-nvcf-api --version \ -f values.yaml ``` -------------------------------- ### Install Example Dashboards Source: https://github.com/nvidia/nvcf/blob/main/docs/user/example-dashboards.md Install the nvcf-example-dashboards Helm chart to configure Grafana with pre-built dashboards for various NVCF services. Ensure you use the latest version from NGC. ```bash helm upgrade \ --install nvcf-example-dashboards \ oci://nvcr.io/0833294136851237/nvcf-ncp-staging/nvcf-example-dashboards \ --version 1.6.0 \ --namespace observability \ --create-namespace ``` -------------------------------- ### Example: Initial Keyspace Creation Source: https://github.com/nvidia/nvcf/blob/main/migrations/cassandra/keyspaces/README.md This migration script creates the keyspace using NetworkTopologyStrategy. It utilizes a template variable for the replica count. ```sql CREATE KEYSPACE {{ $replicaCount }} WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 3}; ``` -------------------------------- ### Define a WebService and a GET Route Source: https://github.com/nvidia/nvcf/blob/main/src/compute-plane-services/image-credential-helper/vendor/github.com/emicklei/go-restful/v3/README.md Example of defining a WebService with a path, supported content types, and a GET route for retrieving a user. It includes route documentation and parameter definition. ```go ws := new(restful.WebService) ws. Path("/users"). Consumes(restful.MIME_XML, restful.MIME_JSON). Produces(restful.MIME_JSON, restful.MIME_XML) ws.Route(ws.GET("/{user-id}").To(u.findUser). Doc("get a user"). Param(ws.PathParameter("user-id", "identifier of the user").DataType("string")). Writes(User{})) ... func (u UserResource) findUser(request *restful.Request, response *restful.Response) { id := request.PathParameter("user-id") ... } ``` -------------------------------- ### Install Make Source: https://github.com/nvidia/nvcf/blob/main/src/control-plane-services/nats-auth-callout/README.md Provides commands to install Make on Ubuntu/Debian, macOS, or Windows. ```bash # Install Make: # - Ubuntu/Debian: sudo apt-get install make # - macOS: brew install make or install Xcode command line tools # - Windows: Use WSL or install Make for Windows ``` -------------------------------- ### Get and Set unsafe.Pointer Value with reflect2 Source: https://github.com/nvidia/nvcf/blob/main/src/compute-plane-services/image-credential-helper/vendor/github.com/modern-go/reflect2/README.md This example shows how to get and set a value using unsafe.Pointer with reflect2. Similar to interface{} manipulation, use the pointer to the type for setting values. ```go valType := reflect2.TypeOf(1) i := 1 j := 10 valType.UnsafeSet(unsafe.Pointer(&i), unsafe.Pointer(&j)) // i will be 10 ``` -------------------------------- ### Install NATS Go Client Source: https://github.com/nvidia/nvcf/blob/main/src/compute-plane-services/nvca/vendor/github.com/nats-io/nats.go/README.md Install the latest released or a specific version of the NATS Go client using go get. Ensure you are using a compatible NATS Server version. ```bash # To get the latest released Go client: go get github.com/nats-io/nats.go@latest # To get a specific version: go get github.com/nats-io/nats.go@v1.47.0 # Note that the latest major version for NATS Server is v2: go get github.com/nats-io/nats-server/v2@latest ``` -------------------------------- ### Install JSON-Patch v4 Source: https://github.com/nvidia/nvcf/blob/main/src/compute-plane-services/image-credential-helper/vendor/gopkg.in/evanphx/json-patch.v4/README.md Use this command to get version 4 of the jsonpatch library for Go. ```bash go get -u gopkg.in/evanphx/json-patch.v4 ``` -------------------------------- ### Setup Environment Variables and Build CLI Source: https://github.com/nvidia/nvcf/blob/main/src/clis/nvcf-cli/test/e2e/README.md Sets up necessary environment variables and builds the nvcf-cli binary for testing. Assumes execution from the monorepo root. ```bash # From the monorepo root export STACK_PATH=/path/to/nvcf-self-managed-stack export NVCF_TOKEN=$(jq -r .token ~/.nvcf-cli.state) # Build the CLI under test bazel build //src/clis/nvcf-cli:nvcf-cli cp "$(bazel cquery --output=files //src/clis/nvcf-cli:nvcf-cli)" /tmp/nvcf-cli ``` -------------------------------- ### Install Latest JSON-Patch Source: https://github.com/nvidia/nvcf/blob/main/src/compute-plane-services/image-credential-helper/vendor/gopkg.in/evanphx/json-patch.v4/README.md Use this command to get the latest version of the jsonpatch library for Go. ```bash go get -u github.com/evanphx/json-patch/v5 ``` -------------------------------- ### Example: Role Creation and Privilege Grant Source: https://github.com/nvidia/nvcf/blob/main/migrations/cassandra/keyspaces/README.md This script initializes application roles, grants necessary privileges, and sets the service login password using an environment variable. ```sql CREATE ROLE service WITH PASSWORD = '${SERVICE_ROLE_PASSWORD}' NOSUPERUSER INHERIT CREATEROLE; GRANT ALL ON KEYSPACE "api_keys_api" TO service; ``` -------------------------------- ### Example run.py for PyTriton Server Source: https://github.com/nvidia/nvcf/blob/main/docs/user/container-functions.md Defines a PyTriton model with an inference function and server setup. ```python import numpy as np from pytriton.model_config import ModelConfig, Tensor from pytriton.triton import Triton, TritonConfig import time .... class PyTritonServer: """triton server for timed_sleeper""" def __init__(self): # basically need to accept image, mask(PIL Images), prompt, negative_prompt(str), seed(int) self.model_name = "timed_sleeper" def _infer_fn(self, requests): responses = [] for req in requests: req_data = req.data sleep_duration = numpy_array_to_variable(req_data.get("sleep_duration")) # deal with header dict keys being lowerscale request_parameters_dict = uppercase_keys(req.parameters) time.sleep(sleep_duration) responses.append({"sleep_duration": np.array([sleep_duration])}) return responses def run(self): """run triton server""" with Triton( config=TritonConfig( http_header_forward_pattern="NVCF-*", # this is required http_port=8000, grpc_port=8001, metrics_port=8002, ) ) as triton: triton.bind( model_name="timed_sleeper", infer_func=self._infer_fn, inputs=[ Tensor(name="sleep_duration", dtype=np.uint32, shape=(1,)), ], outputs=[Tensor(name="sleep_duration", dtype=np.uint32, shape=(1,))], config=ModelConfig(batching=False), ) triton.serve() if __name__ == "__main__": server = PyTritonServer() server.run() ``` -------------------------------- ### Uninstall Helm Releases Source: https://github.com/nvidia/nvcf/blob/main/docs/user/example-dashboards.md Remove the installed Helm releases for both the example dashboards and the observability reference stack. ```bash helm uninstall nvcf-example-dashboards -n observability helm uninstall observability -n observability ``` -------------------------------- ### Basic Object Store Operations Source: https://github.com/nvidia/nvcf/blob/main/src/compute-plane-services/nvca/vendor/github.com/nats-io/nats.go/jetstream/README.md Demonstrates creating an object store, putting objects as strings, bytes, or files, retrieving objects, and deleting objects and the store. ```go js, _ := jetstream.New(nc) ctx := context.Background() // Create a new bucket. Bucket name is required and has to be unique within a JetStream account. os, _ := js.CreateObjectStore(ctx, jetstream.ObjectStoreConfig{Bucket: "configs"}) config1 := bytes.NewBufferString("first config") // Put an object in a bucket. Put expects an object metadata and a reader // to read the object data from. os.Put(ctx, jetstream.ObjectMeta{Name: "config-1"}, config1) // Objects can also be created using various helper methods // 1. As raw strings os.PutString(ctx, "config-2", "second config") // 2. As raw bytes os.PutBytes(ctx, "config-3", []byte("third config")) // 3. As a file os.PutFile(ctx, "config-4.txt") // Get an object // Get returns a reader and object info // Similar to Put, Get can also be used with helper methods // to retrieve object data as a string, bytes or to save it to a file object, _ := os.Get(ctx, "config-1") data, _ := io.ReadAll(object) info, _ := object.Info() // Prints `configs.config-1 -> "first config"` fmt.Printf("%s.%s -> %q\n", info.Bucket, info.Name, string(data)) // Delete an object. // Delete will remove object data from stream, but object metadata will be kept // with a delete marker. os.Delete(ctx, "config-1") // getting a deleted object will return an error _, err := os.Get(ctx, "config-1") fmt.Println(err) // prints `nats: object not found` // A bucket can be deleted once it is no longer needed js.DeleteObjectStore(ctx, "configs") ``` -------------------------------- ### Install Dependencies Source: https://github.com/nvidia/nvcf/blob/main/src/compute-plane-services/byoo-otel-collector/generator/README.md Run this command to synchronize and download project dependencies using uv. ```bash uv sync ```