### Setup Development Environment Source: https://github.com/bacalhau-project/bacalhau/blob/main/integration/flyte/README.md Initialize a virtual environment and install dependencies for plugin development. ```bash virtualenv ~/.virtualenvs/flytekit-bacalhau source ~/.virtualenvs/flytekit-bacalhau/bin/activate make setup ``` -------------------------------- ### All Available HTTP Methods Source: https://github.com/bacalhau-project/bacalhau/blob/main/pkg/executor/wasm/funcs/http/client/README.md Provides examples for making various HTTP requests including GET, POST, PUT, DELETE, HEAD, OPTIONS, PATCH, and a generic Request method. ```go client := NewClient() // GET request resp, err := client.Get(url, headers) // POST request resp, err := client.Post(url, headers, body) // PUT request resp, err := client.Put(url, headers, body) // DELETE request resp, err := client.Delete(url, headers) // HEAD request resp, err := client.Head(url, headers) // OPTIONS request resp, err := client.Options(url, headers) // PATCH request resp, err := client.Patch(url, headers, body) // Generic request (if needed) resp, err := client.Request(method, url, headers, body) ``` -------------------------------- ### Full Usage Example: Create, Serialize, and Deserialize Message Source: https://github.com/bacalhau-project/bacalhau/blob/main/pkg/lib/envelope/README.md A comprehensive example demonstrating the setup of a registry, message creation, serialization for transmission, and deserialization of a received message, including type-safe payload access. ```go // 1. Set up registry registry := envelope.NewRegistry() registry.Register("MyPayload", MyPayload{}) // 2. Create message msg := envelope.NewMessage(MyPayload{ Field: "value", }) msg.WithMetadataValue("version", "1.0") // 3. Serialize for transmission encoded, err := registry.Serialize(msg) if err != nil { // Handle error } // 4. Deserialize received message decoded, err := registry.Deserialize(encoded) if err != nil { // Handle error } // 5. Type-safe payload access payload, ok := decoded.GetPayload(MyPayload{}) ``` -------------------------------- ### Example HTTP API Call Source: https://github.com/bacalhau-project/bacalhau/blob/main/integration/flyte/DEPLOYMENT.md Example of an HTTP GET request to retrieve active launch plans. Ensure `` is a fully qualified domain name. ```shell $ curl -GET \ ':80/api/v1/active_launch_plans/flytebacalhau/development?limit=32&token=32' \ -H 'accept: application/json' ``` -------------------------------- ### Install Bacalhau Client via Setuptools Source: https://github.com/bacalhau-project/bacalhau/blob/main/clients/python/README.md Install the package using the setup.py script. ```sh python setup.py install --user ``` -------------------------------- ### Initialize Cluster Setup Source: https://github.com/bacalhau-project/bacalhau/blob/main/scripts/testing-setup/README.md Execute the cluster setup script after configuring variables. ```bash ./setup_cluster.sh ``` -------------------------------- ### Bacalhau Configuration Examples Source: https://github.com/bacalhau-project/bacalhau/blob/main/cmd/util/flags/cliflags/Config.md Practical examples of using the --config flag for files and overrides. ```bash bacalhau serve --config my-config.yaml ``` ```bash bacalhau serve -c base-config.yaml -c override-config.yaml ``` ```bash bacalhau serve -c config.yaml -c WebUI.Port=9090 -c Node.Name=custom-node ``` ```bash bacalhau serve -c config.yaml -c WebUI.Enabled -c Node.ClientAPI.Host=192.168.1.5 ``` -------------------------------- ### Create and Start Watcher Source: https://github.com/bacalhau-project/bacalhau/blob/main/pkg/lib/watcher/README.md Configure and start a watcher using either two-step or one-step initialization. ```go // Create watcher w, _ := manager.Create(ctx, "my-watcher", watcher.WithFilter(watcher.EventFilter{ ObjectTypes: []string{"Job", "Execution"}, Operations: []watcher.Operation{watcher.OperationCreate, watcher.OperationUpdate}, }), ) // Set handler err = w.SetHandler(&MyHandler{}) // Start watching err = w.Start(ctx) ``` ```go w, _ := manager.Create(ctx, "my-watcher", watcher.WithHandler(&MyHandler{}), watcher.WithAutoStart(), watcher.WithFilter(watcher.EventFilter{ ObjectTypes: []string{"Job", "Execution"}, Operations: []watcher.Operation{watcher.OperationCreate, watcher.OperationUpdate}, }), ) ``` -------------------------------- ### Run Docker Compose Setup Source: https://github.com/bacalhau-project/bacalhau/blob/main/docker-compose-deployment/README.md Starts all the Bacalhau services defined in the Docker Compose file, including requester, compute, client, registry, and Minio nodes. ```shell docker-compose up ``` -------------------------------- ### Install and Initialize Airflow Locally Source: https://github.com/bacalhau-project/bacalhau/blob/main/integration/airflow/README.md Install Apache Airflow, set the AIRFLOW_HOME environment variable, and initialize the Airflow database. ```shell $ pip install apache-airflow export AIRFLOW_HOME=~/airflow $ airflow db init ``` -------------------------------- ### Install bacalhau-airflow from Source Source: https://github.com/bacalhau-project/bacalhau/blob/main/integration/airflow/README.md Navigate to the integration directory and install the package using pip after cloning the repository. ```shell cd integration/airflow/ pip install . ``` -------------------------------- ### Install Flytekit Bacalhau Plugin Source: https://github.com/bacalhau-project/bacalhau/blob/main/integration/flyte/plugins/flytekit-bacalhau/README.md Use this command to install the plugin. Ensure you have pip installed. ```bash pip install flytekitplugins-bacalhau ``` -------------------------------- ### Install bacalhau-airflow from source Source: https://github.com/bacalhau-project/bacalhau/blob/main/integration/airflow/docs/readme.md Navigate to the integration/airflow directory and install the package using pip. ```shell cd integration/airflow/ pip install . ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/bacalhau-project/bacalhau/blob/main/webui/README.md Run this command in the project root to install all necessary Node.js dependencies. ```bash yarn install ``` -------------------------------- ### Install Terraform Source: https://github.com/bacalhau-project/bacalhau/blob/main/scripts/testing-setup/README.md Command to install the Terraform binary on the host system. ```bash sudo apt install terraform ``` -------------------------------- ### Install and Initialize Airflow Source: https://github.com/bacalhau-project/bacalhau/blob/main/integration/airflow/docs/readme.md Install Apache Airflow and initialize its database. Set the AIRFLOW_HOME environment variable to specify the Airflow configuration directory. ```shell $ pip install apache-airflow export AIRFLOW_HOME=~/airflow $ airflow db init ``` -------------------------------- ### Install Bacalhau CLI Source: https://context7.com/bacalhau-project/bacalhau/llms.txt Installs the Bacalhau CLI using a script. Verify the installation with the `bacalhau version` command. ```bash curl -sL https://get.bacalhau.org/install.sh | bash ``` ```bash bacalhau version ``` -------------------------------- ### Example Usage Source: https://github.com/bacalhau-project/bacalhau/blob/main/pkg/lib/ncl/README.md Demonstrates how to instantiate and use the Publisher, Responder, and Subscriber components. ```APIDOC ## Example Usage ### Description Illustrates the instantiation and basic usage of Publisher, Responder, and Subscriber components within an application. ### Code Example ```go // Create a publisher for both publishing and requests publisher, _ := NewPublisher(nc, PublisherConfig{ Name: "compute-node", MessageRegistry: registry, }) // Publish a message err := publisher.Publish(ctx, NewPublishRequest(message)) // Make a request response, err := publisher.Request(ctx, NewPublishRequest(request)) // Create a responder for handling requests responder, _ := NewResponder(nc, ResponderConfig{ Name: "orchestrator", Subject: "requests", }) // Register request handlers err = responder.Listen(ctx, "JobRequest", handler) // Create a subscriber for message consumption subscriber, _ := NewSubscriber(nc, SubscriberConfig{ Name: "worker", MessageHandler: handler, }) // Subscribe to subjects err = subscriber.Subscribe(ctx, "updates.>") ``` ``` -------------------------------- ### Install Pre-commit Hooks Source: https://github.com/bacalhau-project/bacalhau/blob/main/python/README.md Installs the pre-commit framework and its associated hooks to automate code quality checks before committing changes. ```shell $ make install-pre-commit ``` -------------------------------- ### Install Flyte via Helm Source: https://github.com/bacalhau-project/bacalhau/blob/main/integration/flyte/DEPLOYMENT.md Command to install the Flyte core chart using a custom values file. ```shell $ helm install -n flyte -f values-gcp.yaml --create-namespace flyte flyteorg/flyte-core ``` -------------------------------- ### Install Bacalhau Client via Pip Source: https://github.com/bacalhau-project/bacalhau/blob/main/clients/python/README.md Install the package directly from a Git repository using pip. ```sh pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git ``` -------------------------------- ### Start Bacalhau Containers Source: https://github.com/bacalhau-project/bacalhau/blob/main/ops/metrics/README.md Initializes the required infrastructure using Docker Compose. ```shell docker-compose up ``` -------------------------------- ### Install bacalhau-airflow from PyPI Source: https://github.com/bacalhau-project/bacalhau/blob/main/integration/airflow/README.md Use this command to install the package directly from the Python Package Index. ```console pip install bacalhau-airflow ``` -------------------------------- ### Install Plugin in Editable Mode Source: https://github.com/bacalhau-project/bacalhau/blob/main/integration/flyte/README.md Install the plugin in editable mode within the virtual environment for local development. ```bash source ~/.virtualenvs/flytekit-bacalhau/bin/activate cd plugins pip install -e . ``` -------------------------------- ### Run Bacalhau Devstack Source: https://github.com/bacalhau-project/bacalhau/blob/main/benchmark/README.md Starts a local development stack with 3 Bacalhau nodes. Use PREDICTABLE_API_PORT=1 to force nodes to start with port 20000. ```bash export PREDICTABLE_API_PORT=1 # to force nodes start with port 20000 make devstack # runs 3 nodes by default ``` -------------------------------- ### Install Project Dependencies with Poetry Source: https://github.com/bacalhau-project/bacalhau/blob/main/python/README.md Use this command to install the root package and its development dependencies in an isolated Poetry virtual environment. The `--with test,dev` flag includes optional dependencies for testing and development. The `-vvv` flag increases verbosity. ```shell $ poetry install --no-interaction --with test,dev -vvv Creating virtualenv bacalhau-sdk-9mIcLX8U-py3.9 in /Users/enricorotundo/Library/Caches/pypoetry/virtualenvs Using virtualenv: /Users/enricorotundo/Library/Caches/pypoetry/virtualenvs/bacalhau-sdk-9mIcLX8U-py3.9 Installing dependencies from lock file ... ``` -------------------------------- ### Configure Flyte Client Source: https://github.com/bacalhau-project/bacalhau/blob/main/integration/flyte/README.md Example configuration for ~/.flyte/config.yaml to connect to the Flyte admin endpoint. ```yaml admin: endpoint: localhost:8089 authType: Pkce insecure: true logger: show-source: true level: 6 ``` -------------------------------- ### Create and Use New Client Source: https://github.com/bacalhau-project/bacalhau/blob/main/pkg/executor/wasm/funcs/http/client/README.md Demonstrates creating a new client instance and performing a basic GET request. Handles potential errors and prints the response status and body. ```go client := NewClient() // Simple GET request resp, err := client.Get("https://api.example.com", nil) if err != nil { // Handle error } fmt.Printf("Status: %d\nBody: %s\n", resp.StatusCode, resp.Body) ``` -------------------------------- ### Get Minio Admin Info Source: https://github.com/bacalhau-project/bacalhau/blob/main/docker-compose-deployment/README.md Retrieves administrative information from the Minio server to verify the connection and setup. ```shell mc admin info bacalhau-minio ``` -------------------------------- ### Get Job Results - Python Source: https://github.com/bacalhau-project/bacalhau/blob/main/clients/python/docs/OrchestratorApi.md Use this snippet to retrieve the results of a specific job using its ID. Ensure the `bacalhau_apiclient` is installed and imported. ```python from __future__ import print_function import time import bacalhau_apiclient from bacalhau_apiclient.rest import ApiException from pprint import pprint # create an instance of the API class api_instance = bacalhau_apiclient.OrchestratorApi() id = 'id_example' # str | ID to get the job results for try: # Returns the results of a job. api_response = api_instance.orchestratorjob_results(id) pprint(api_response) except ApiException as e: print("Exception when calling OrchestratorApi->orchestratorjob_results: %s\n" % e) ``` -------------------------------- ### Create a Watcher with Configuration Options Source: https://github.com/bacalhau-project/bacalhau/blob/main/pkg/lib/watcher/README.md Demonstrates initializing a watcher using functional options to define behavior, filtering, and retry strategies. ```go w, err := manager.Create(ctx, "my-watcher", watcher.WithInitialEventIterator(watcher.TrimHorizonIterator()), watcher.WithHandler(&MyHandler{}), watcher.WithAutoStart(), watcher.WithFilter(watcher.EventFilter{ ObjectTypes: []string{"Job", "Execution"}, Operations: []watcher.Operation{watcher.OperationCreate, watcher.OperationUpdate}, }), watcher.WithBufferSize(1000), watcher.WithBatchSize(100), watcher.WithMaxRetries(3), watcher.WithRetryStrategy(watcher.RetryStrategyBlock), ) ``` -------------------------------- ### Run Development Server Source: https://github.com/bacalhau-project/bacalhau/blob/main/webui/README.md Starts the development server for the project. Access the application via the specified local URL. ```bash yarn dev ``` -------------------------------- ### Install Bacalhau CLI Source: https://github.com/bacalhau-project/bacalhau/blob/main/README.md Installs the Bacalhau CLI on Linux and macOS systems. Ensure your system has curl installed. ```bash curl -sL https://get.bacalhau.org/install.sh | bash ``` -------------------------------- ### Start Bacalhau Node Source: https://context7.com/bacalhau-project/bacalhau/llms.txt Starts a Bacalhau node. By default, it starts an orchestrator. Enable compute capabilities for a hybrid node. The WebUI can be enabled on a custom port. ```bash bacalhau serve ``` ```bash bacalhau serve --config Orchestrator.Enabled --config Compute.Enabled ``` ```bash bacalhau serve --config WebUI.Enabled --config WebUI.Listen=0.0.0.0:3000 ``` ```bash bacalhau serve --config Compute.Enabled --config Compute.Orchestrators=nats://orchestrator1:4222 ``` -------------------------------- ### Initialize Terraform and List Workspaces Source: https://github.com/bacalhau-project/bacalhau/blob/main/ops/README.md Navigate to the Terraform directory, authenticate with Google Cloud, initialize Terraform, and list available workspaces. This sets up the Terraform environment for managing infrastructure. ```bash cd ops/terraform gcloud auth application-default login terraform init terraform workspace list ``` -------------------------------- ### Install Development Dependencies Source: https://github.com/bacalhau-project/bacalhau/blob/main/integration/airflow/README.md Installs the necessary Python packages for development using pip. ```bash pip install -r dev-requirements.txt ``` -------------------------------- ### Serve Bacalhau with a Configuration File Source: https://context7.com/bacalhau-project/bacalhau/llms.txt Start the Bacalhau server using a specified YAML configuration file. This is the recommended method for production deployments to manage complex settings. ```bash # Use config file bacalhau serve --config-file /etc/bacalhau/config.yaml ``` -------------------------------- ### Start Bacalhau Development Environment Source: https://github.com/bacalhau-project/bacalhau/blob/main/docker/bacalhau-dind/README.md Launches a local development stack using the DinD container image. ```bash docker run --privileged \ ghcr.io/bacalhau-project/bacalhau:latest-dind devstack ``` -------------------------------- ### Verify Bacalhau Installation Source: https://github.com/bacalhau-project/bacalhau/blob/main/README.md Checks if the Bacalhau CLI has been installed successfully by displaying its version. ```bash bacalhau version ``` -------------------------------- ### Run Hello World workflow with Docker Source: https://github.com/bacalhau-project/bacalhau/blob/main/integration/flyte/plugins/flytekit-bacalhau/examples/README.md Executes a basic Bacalhau task using the provided container image. ```shell $ docker run --rm -v $(pwd):/examples \ -w /examples \ -a stdout -a stderr \ winderresearch/flytekit-bacalhau-examples:latest \ pyflyte run ./hello-world.py wf ``` -------------------------------- ### Build and Test WebUI with Bacalhau Nodes Source: https://github.com/bacalhau-project/bacalhau/blob/main/webui/README.md Commands to build the WebUI and development components, then start a Bacalhau server with the WebUI enabled for testing. Ensure Bacalhau nodes are active. ```bash # Run from project root make build-webui make build-dev bacalhau serve --compute --orchestrator -c WebUI.Enabled ``` -------------------------------- ### Basic MetricRecorder Usage Source: https://github.com/bacalhau-project/bacalhau/blob/main/pkg/telemetry/metric_recorder.md Initialize a recorder with base attributes and ensure metrics are published upon completion using defer. ```go // Create a new recorder with base attributes recorder := NewMetricRecorder(attribute.String("operation", "process")) // Ensure metrics are published when done defer recorder.Done(ctx, totalDurationHistogram) // Record latency for specific operations recorder.Latency(ctx, dequeueHistogram, "dequeue") // Count operation recorder.Count(ctx, operationCounter) // Record gauge values recorder.Gauge(ctx, queueSizeGauge, float64(queueSize)) ``` -------------------------------- ### Initialize EventStore Source: https://github.com/bacalhau-project/bacalhau/blob/main/pkg/lib/watcher/README.md Create a new BoltDB-backed event store instance. ```go db, _ := bbolt.Open("events.db", 0600, nil) store, _ := boltdb.NewEventStore(db) ``` -------------------------------- ### Build AMI with Packer Source: https://github.com/bacalhau-project/bacalhau/blob/main/scripts/testing-setup/README.md Commands to navigate to the build directory, install Packer, and execute the build process. ```bash cd build-ami sudo apt install packer packer build package.json.pkr.hcl ``` -------------------------------- ### List and Monitor Jobs with Go SDK Source: https://context7.com/bacalhau-project/bacalhau/llms.txt Demonstrates listing jobs, retrieving detailed job history and executions, and polling for job completion status. ```go package main import ( "context" "fmt" "log" "time" "github.com/bacalhau-project/bacalhau/pkg/models" "github.com/bacalhau-project/bacalhau/pkg/publicapi/apimodels" "github.com/bacalhau-project/bacalhau/pkg/publicapi/client/v2" ) func main() { httpClient := client.NewHTTPClient("http://localhost:1234") api := client.NewAPI(httpClient) ctx := context.Background() // List all jobs listResp, err := api.Jobs().List(ctx, &apimodels.ListJobsRequest{ BaseListRequest: apimodels.BaseListRequest{ Limit: 10, OrderBy: "created_at", Reverse: true, }, }) if err != nil { log.Fatal(err) } fmt.Printf("Found %d jobs:\n", len(listResp.Items)) for _, job := range listResp.Items { fmt.Printf(" - %s (%s): %s\n", job.Name, job.ID, job.State.StateType) } // Get specific job with details if len(listResp.Items) > 0 { jobID := listResp.Items[0].ID // Get job with history and executions getResp, err := api.Jobs().Get(ctx, &apimodels.GetJobRequest{ JobIDOrName: jobID, Include: "history,executions", }) if err != nil { log.Fatal(err) } fmt.Printf("\nJob Details: %s\n", getResp.Job.Name) fmt.Printf("State: %s\n", getResp.Job.State.StateType) fmt.Printf("Created: %s\n", getResp.Job.GetCreateTime()) if getResp.Executions != nil { fmt.Printf("Executions: %d\n", len(getResp.Executions.Items)) for _, exec := range getResp.Executions.Items { fmt.Printf(" - %s on %s: %s\n", exec.ID, exec.NodeID, exec.ComputeState.StateType) } } } // Poll for job completion jobID := "j-abc123" for { resp, err := api.Jobs().Get(ctx, &apimodels.GetJobRequest{ JobIDOrName: jobID, }) if err != nil { log.Fatal(err) } if resp.Job.State.StateType.IsTerminal() { fmt.Printf("Job %s finished with state: %s\n", jobID, resp.Job.State.StateType) break } fmt.Printf("Job state: %s, waiting...\n", resp.Job.State.StateType) time.Sleep(5 * time.Second) } } ``` -------------------------------- ### Install Cert-Manager via Helm Source: https://github.com/bacalhau-project/bacalhau/blob/main/integration/flyte/DEPLOYMENT.md Commands to add the Jetstack repository and install cert-manager with CRDs enabled, followed by applying the issuer configuration. ```shell $ helm repo add jetstack https://charts.jetstack.io $ helm repo update $ helm install cert-manager --namespace flyte --create-namespace --version v1.12.3 jetstack/cert-manager --set installCRDs=true $ kubectl apply --namespace=flyte -f cert-issuer.yaml ``` -------------------------------- ### Initialize Manager Source: https://github.com/bacalhau-project/bacalhau/blob/main/pkg/lib/watcher/README.md Create a manager instance to oversee watchers. ```go manager := watcher.NewManager(store) ``` -------------------------------- ### Configure Client Buffer Sizes Source: https://github.com/bacalhau-project/bacalhau/blob/main/pkg/executor/wasm/funcs/http/client/README.md Shows how to customize the buffer sizes for headers and request/response bodies when initializing the HTTP client. ```go client := &Client{ HeadersBufferSize: 16 * 1024, // 16KB for headers BodyBufferSize: 512 * 1024, // 512KB for body } ``` -------------------------------- ### GET / Source: https://github.com/bacalhau-project/bacalhau/blob/main/clients/python/docs/UtilsApi.md Retrieves the home endpoint information. ```APIDOC ## GET / ### Description Retrieves the home endpoint information. ### Method GET ### Endpoint / ### Response #### Success Response (200) - **string** - The home response. ``` -------------------------------- ### Example Bacalhau Configuration File Source: https://context7.com/bacalhau-project/bacalhau/llms.txt A sample YAML configuration file demonstrating various Bacalhau settings, including API, Orchestrator, Compute, WebUI, and Logging parameters. This file can be used with the 'bacalhau serve --config-file' command. ```yaml cat > config.yaml << 'EOF' API: Host: 0.0.0.0 Port: 1234 Orchestrator: Enabled: true Host: 0.0.0.0 Port: 4222 Compute: Enabled: true Orchestrators: - nats://orchestrator:4222 AllowListedLocalPaths: - /data WebUI: Enabled: true Listen: 0.0.0.0:8483 Logging: Mode: default Level: info EOF bacalhau serve --config-file config.yaml ``` -------------------------------- ### GET /api/v1/agent/node Source: https://github.com/bacalhau-project/bacalhau/blob/main/clients/python/docs/OpsApi.md Returns the info of the node. ```APIDOC ## GET /api/v1/agent/node ### Description Returns the info of the node. ### Method GET ### Endpoint /api/v1/agent/node ### Parameters This endpoint does not need any parameters. ### Request Example ```python # No request body for this endpoint ``` ### Response #### Success Response (200) - **response** (NodeInfo) - Information about the node. #### Response Example ```json { "example": "NodeInfo object" } ``` ``` -------------------------------- ### GET /api/v1/agent/alive Source: https://github.com/bacalhau-project/bacalhau/blob/main/clients/python/docs/OpsApi.md Checks if the agent is alive. ```APIDOC ## GET /api/v1/agent/alive ### Description Checks if the agent is alive. ### Method GET ### Endpoint /api/v1/agent/alive ### Parameters This endpoint does not need any parameters. ### Request Example ```python # No request body for this endpoint ``` ### Response #### Success Response (200) - **response** (str) - A string indicating the agent is alive. #### Response Example ```json "alive" ``` ``` -------------------------------- ### Manage Nodes with Go SDK Source: https://context7.com/bacalhau-project/bacalhau/llms.txt Shows how to list connected nodes, retrieve specific node details, and perform administrative actions like approving pending nodes. ```go package main import ( "context" "fmt" "log" "github.com/bacalhau-project/bacalhau/pkg/publicapi/apimodels" "github.com/bacalhau-project/bacalhau/pkg/publicapi/client/v2" ) func main() { httpClient := client.NewHTTPClient("http://localhost:1234") api := client.NewAPI(httpClient) ctx := context.Background() // List all nodes nodesResp, err := api.Nodes().List(ctx, &apimodels.ListNodesRequest{ BaseListRequest: apimodels.BaseListRequest{ Limit: 100, }, FilterByStatus: "CONNECTED", FilterByApproval: "APPROVED", }) if err != nil { log.Fatal(err) } fmt.Printf("Found %d connected nodes:\n", len(nodesResp.Nodes)) for _, node := range nodesResp.Nodes { info := node.Info capacity := info.ComputeNodeInfo.AvailableCapacity fmt.Printf(" Node: %s\n", info.ID()) fmt.Printf(" Type: %s\n", info.NodeType) fmt.Printf(" Status: %s\n", node.ConnectionState.Status) fmt.Printf(" Available: CPU=%.1f, Memory=%dGB, GPU=%d\n", capacity.CPU, capacity.Memory/1024/1024/1024, capacity.GPU, ) fmt.Printf(" Labels: %v\n", info.Labels) } // Get specific node nodeResp, err := api.Nodes().Get(ctx, &apimodels.GetNodeRequest{ NodeID: "node-abc123", }) if err != nil { log.Fatal(err) } fmt.Printf("\nNode details: %+v\n", nodeResp.Node) // Approve a pending node approveResp, err := api.Nodes().Put(ctx, &apimodels.PutNodeRequest{ NodeID: "node-pending-xyz", Action: string(apimodels.NodeActionApprove), }) if err != nil { log.Fatal(err) } fmt.Printf("Node approved: %v\n", approveResp.Success) } ``` -------------------------------- ### GET /orchestrator/job/results Source: https://github.com/bacalhau-project/bacalhau/blob/main/clients/python/docs/OrchestratorApi.md Retrieves the results of a specific job. ```APIDOC ## GET /orchestrator/job/results ### Description Returns the results of a job. ### Method GET ### Parameters #### Query Parameters - **id** (str) - Required - ID to get the job results for ### Response #### Success Response (200) - **ApiListJobResultsResponse** (object) - The results of the job. ``` -------------------------------- ### GET /api/v1/orchestrator/nodes Source: https://github.com/bacalhau-project/bacalhau/blob/main/clients/python/docs/OrchestratorApi.md Retrieves a list of all orchestrator nodes. ```APIDOC ## GET /api/v1/orchestrator/nodes ### Description Returns a list of orchestrator nodes. ### Method GET ### Endpoint /api/v1/orchestrator/nodes ### Parameters #### Query Parameters - **limit** (int) - Optional - The maximum number of nodes to return. - **state** (str) - Optional - Filter nodes by their current state. ### Response #### Success Response (200) - **[Response Type]** - Description of the response object containing a list of nodes. ### Request Example ```json { "limit": 20, "state": "online" } ``` ### Response Example ```json { "example": "List of nodes" } ``` ``` -------------------------------- ### Run Hello World Docker Job Source: https://github.com/bacalhau-project/bacalhau/blob/main/docker-compose-deployment/README.md Executes a simple 'hello-world' Docker job on the Bacalhau network to verify basic job execution. ```shell bacalhau docker run hello-world ``` -------------------------------- ### GET /api/v1/node_info Source: https://github.com/bacalhau-project/bacalhau/blob/main/clients/python/docs/UtilsApi.md Returns detailed information about the node. ```APIDOC ## GET /api/v1/node_info ### Description Returns detailed information about the node. ### Method GET ### Endpoint /api/v1/node_info ### Response #### Success Response (200) - **NodeInfo** (object) - Detailed information about the node. ``` -------------------------------- ### GET /api/v1/livez Source: https://github.com/bacalhau-project/bacalhau/blob/main/clients/python/docs/UtilsApi.md Checks the liveness status of the node. ```APIDOC ## GET /api/v1/livez ### Description Checks the liveness status of the node. ### Method GET ### Endpoint /api/v1/livez ### Response #### Success Response (200) - **string** - The liveness status. ``` -------------------------------- ### Set Up Requester Node and CLI Source: https://github.com/bacalhau-project/bacalhau/blob/main/benchmark/README.md Sets the API port for the requester node and defines the path to the Bacalhau CLI binary. ```bash export API_PORT=20000 # requester node's port export BACALHAU_BIN=$(which bacalhau) # cli used to send requests ``` -------------------------------- ### Implement NCL Communication Patterns Source: https://github.com/bacalhau-project/bacalhau/blob/main/pkg/lib/ncl/README.md Example usage of Publisher, Responder, and Subscriber components for inter-node messaging. ```go // Create a publisher for both publishing and requests publisher, _ := NewPublisher(nc, PublisherConfig{ Name: "compute-node", MessageRegistry: registry, }) // Publish a message err := publisher.Publish(ctx, NewPublishRequest(message)) // Make a request response, err := publisher.Request(ctx, NewPublishRequest(request)) // Create a responder for handling requests responder, _ := NewResponder(nc, ResponderConfig{ Name: "orchestrator", Subject: "requests", }) // Register request handlers err = responder.Listen(ctx, "JobRequest", handler) // Create a subscriber for message consumption subscriber, _ := NewSubscriber(nc, SubscriberConfig{ Name: "worker", MessageHandler: handler, }) // Subscribe to subjects err = subscriber.Subscribe(ctx, "updates.>") ``` -------------------------------- ### GET /api/v1/healthz Source: https://github.com/bacalhau-project/bacalhau/blob/main/clients/python/docs/UtilsApi.md Checks the health status of the node. ```APIDOC ## GET /api/v1/healthz ### Description Checks the health status of the node. ### Method GET ### Endpoint /api/v1/healthz ### Response #### Success Response (200) - **HealthInfo** (object) - The health status information of the node. ``` -------------------------------- ### Debug Node Startup Issues Source: https://github.com/bacalhau-project/bacalhau/blob/main/ops/README.md View logs from a node's startup script using `journalctl` after connecting to the workspace. ```bash export WORKSPACE=apples bash scripts/connect_workspace.sh $WORKSPACE gcloud compute ssh bacalhau-vm-$WORKSPACE-0 -- sudo journalctl -u google-startup-scripts.service ``` -------------------------------- ### GET /api/v1/id Source: https://github.com/bacalhau-project/bacalhau/blob/main/clients/python/README.md Returns the identifier of the host node. ```APIDOC ## GET /api/v1/id ### Description Returns the id of the host node. ### Method GET ### Endpoint /api/v1/id ``` -------------------------------- ### Implement Profile List Command Source: https://github.com/bacalhau-project/bacalhau/blob/main/docs/plans/2026-01-13-cli-profiles-implementation.md Handles the logic for listing configured CLI profiles, including table and JSON output formatting. ```go package profile import ( "fmt" "path/filepath" "github.com/jedib0t/go-pretty/v6/table" "github.com/spf13/cobra" "github.com/bacalhau-project/bacalhau/cmd/util" "github.com/bacalhau-project/bacalhau/cmd/util/flags/cliflags" "github.com/bacalhau-project/bacalhau/cmd/util/hook" "github.com/bacalhau-project/bacalhau/cmd/util/output" "github.com/bacalhau-project/bacalhau/pkg/config/profile" ) type profileListEntry struct { Name string `json:"name"` Current bool `json:"current"` Endpoint string `json:"endpoint"` Auth string `json:"auth"` } func newListCmd() *cobra.Command { o := output.OutputOptions{ Format: output.TableFormat, Pretty: true, HideHeader: false, NoStyle: false, } cmd := &cobra.Command{ Use: "list", Short: "List all profiles", Long: "List all configured CLI profiles.", Args: cobra.NoArgs, PreRunE: hook.ClientPreRunHooks, PostRunE: hook.ClientPostRunHooks, SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { cfg, err := util.SetupConfigType(cmd) if err != nil { return err } dataDir := cfg.Get("DataDir").(string) profilesDir := filepath.Join(dataDir, "profiles") store := profile.NewStore(profilesDir) return runList(cmd, store, o) }, } cmd.Flags().AddFlagSet(cliflags.OutputFormatFlags(&o)) return cmd } func runList(cmd *cobra.Command, store *profile.Store, o output.OutputOptions) error { names, err := store.List() if err != nil { return err } if len(names) == 0 { cmd.Println("No profiles found. Create one with: bacalhau profile save --endpoint ") return nil } current, _ := store.GetCurrent() var entries []profileListEntry for _, name := range names { p, err := store.Load(name) if err != nil { continue } auth := "none" if p.GetToken() != "" { auth = "token" } entries = append(entries, profileListEntry{ Name: name, Current: name == current, Endpoint: p.Endpoint, Auth: auth, }) } return output.Output(cmd, listColumns, o, entries) } var listColumns = []output.TableColumn[profileListEntry]{ { ``` -------------------------------- ### Register v4 to v5 Migration in Setup Source: https://github.com/bacalhau-project/bacalhau/blob/main/docs/plans/2026-01-13-cli-profiles-implementation.md This Go code snippet registers the v4 to v5 migration in the Bacalhau setup process. It creates a new migration manager and adds the V4ToV5 migration function to it. This ensures the migration is executed when Bacalhau is set up. ```go import ( "github.com/bacalhau-project/bacalhau/pkg/repo/migrations" ) func SetupMigrationManager() (*repo.MigrationManager, error) { return repo.NewMigrationManager( repo.NewMigration(repo.Version4, repo.Version5, migrations.V4ToV5), ) } ``` -------------------------------- ### GET /api/v1/orchestrator/jobs Source: https://github.com/bacalhau-project/bacalhau/blob/main/clients/python/docs/OrchestratorApi.md Retrieves a list of all jobs managed by the orchestrator. ```APIDOC ## GET /api/v1/orchestrator/jobs ### Description Returns a list of jobs. ### Method GET ### Endpoint /api/v1/orchestrator/jobs ### Parameters #### Query Parameters - **limit** (int) - Optional - The maximum number of jobs to return. - **owner** (str) - Optional - Filter jobs by owner. - **state** (str) - Optional - Filter jobs by their current state. ### Response #### Success Response (200) - **[Response Type]** - Description of the response object containing a list of jobs. ### Request Example ```json { "limit": 10, "owner": "user_id", "state": "completed" } ``` ### Response Example ```json { "example": "List of jobs" } ``` ```