Posts

harness - setting up connector to gcp

Image
Configuring gcp worker pool As part of this setup, we need to create pool in GCP that be able to do OIDC authentications with harness.io. Lets start by  Create the pool using the following command  gcloud iam workload-identity-pools create harness-pool \   --location=global \   --project=project-number \   --display-name="Harness Pool" \   --description="Workload identity pool for Harness OIDC" Then we need to create the providers using the following command  gcloud iam workload-identity-pools providers create-oidc harness-provider-oidc \   --workload-identity-pool=harness-pool \   --location=global \   --project=project-number \   --issuer-uri="https://app.harness.io/ng/api/oidc/account/UlEEm2GaTPaJNlYAV6NDkg" \   --attribute-mapping="google.subject=assertion.sub" \   --allowed-audiences="//iam.googleapis.com/projects/project-id/locations/global/workloadIdentityPools/harness-pool/providers/harness-provider-oidc" Create se...

harness issue: Manual codebase git task needs one of PR number, branch, commitSha or tag. Please check if you are passing codebase inputs correctly.

Ran into this error here and unable to get pass the repository cloning part.  This is because we didn't specifyt the branch to clone so it fails.  pipeline: name: dotnetdemo identifier: dotnetdemo projectIdentifier: default_project orgIdentifier: default tags: {} properties: ci: codebase: connectorRef: account.Github repoName: kepungnzai/dotnet-hello build: <+input> And the fixes is here, explicitly defining the branch to checkout  pipeline :   name : dotnetdemo   identifier : dotnetdemo   projectIdentifier : default_project   orgIdentifier : default   tags : {}   properties :     ci :       codebase :         connectorRef : account.Github         repoName : kepungnzai/dotnet-hello         build :           type : branch           spec :       ...

harness.io : setting up dotnet build app with integration to github

Image
Haness is getting popular these days and it is important to learn how to do things with it. We will build a hello world application with it.  First you need an account with harness and github repository which are integrated via token.  In the github repo - dotnet-hello, we will create a folder called .harness which contains pipeline yaml  The yaml looks something like this. At the moment the default agent supports dotnet 9 and not dotnet 10 or 11.  pipeline :   identifier : Build_kepungnzai_dotnet_hello_1796420381212   name : Build dotnet-hello   orgIdentifier : default   projectIdentifier : default_project   properties :     ci :       codebase :         build : <+input>         connectorRef : account.Github         repoName : kepungnzai/dotnet-hello   stages :     - stage :         identifier : build     ...

mcp with mcp inspector

Image
mcp inspector provide us with the necessary tool to invoke a mcp tools. Let's get back to some basic.  Here is my server.py and my client.py server.py from mcp . server . mcpserver import MCPServer mcp = MCPServer ( "hello-world" ) @ mcp . tool () def say_hello ( name : str = "world" ) -> str :     """Greet someone by name."""     return f "Hello, { name } ! 👋 (from my first MCP server)" @ mcp . tool () def add ( a : float , b : float ) -> float :     """Add two numbers."""     return a + b if __name__ == "__main__" :     # stdio transport: the client launches this script and talks over stdin/stdout     mcp . run ( transport = "stdio" ) client.py import asyncio , sys from mcp import ClientSession , StdioServerParameters from mcp . client . stdio import stdio_client async def main ():     params = StdioServerParameters ( command = sys . exec...

gcp spark quickstart 2 - fraud detector

Image
Let's create another python script that we can run with our serverless spark cluster. Some preliminary setup here :- gcloud services enable dataproc.googleapis.com bigquery.googleapis.com export BUCKET = $ (gcloud config get - value project) - fraud - demo gcloud storage buckets create gs : // $ BUCKET -- location = us - central1 bq mk -- location = US fraud And next we will create the requires tables in bigquery - all these command are ran from the command line  bq query -- use_legacy_sql = false << 'SQL' CREATE OR REPLACE TABLE fraud.transactions AS WITH normal AS (   SELECT     GENERATE_UUID() AS txn_id,     CONCAT( 'card_' , CAST( 1 + CAST(FLOOR(RAND() * 5000 ) AS INT64 ) AS STRING )) AS card_id,     ROUND( 5 + 100 * POW(RAND(), 3 ), 2 ) AS amount,     TIMESTAMP_ADD(TIMESTAMP( '2026-11-01' ),                   INTERVAL CAST(FLOOR(RAND() * 30 * 24 * 3600 ) AS ...

gcp apache spark deployment quickstart

Image
We can deploy a spark job without creating any cluster in GCP and this is a quickstart that we will be doing today with the followings commands:-  # enabling services gcloud services enable dataproc.googleapis.com bigquery.googleapis.com # Creating the bucket export BUCKET = $ (gcloud config get - value project) - spark - demo gcloud storage buckets create gs: // $ BUCKET -- location = us - central1 bq mk -- location = US wordcount_dataset And this is the code that we will be using  import sys from pyspark.sql import SparkSession, functions as F bucket = sys . argv [ 1 ] spark = SparkSession.builder.appName( "shakespeare-wordcount" ).getOrCreate() spark .conf.set( "temporaryGcsBucket" , bucket )   # staging area for the BigQuery write # 1. READ from BigQuery words = ( spark .read.format( "bigquery" )          .option( "table" , "bigquery-public-data:samples.shakespeare" )          .load()       ...

google adk - memory bank we can use to store our agentic application

Image
 With memorybank we can store user conversation and these conversations are stored based on app_name and user_id.  Another important point to note is we need both ImMorySessionService and VertexAiMemoryBankService.  import asyncio import os from google import adk from google . adk . agents . callback_context import CallbackContext from google . adk . memory import VertexAiMemoryBankService from google . adk . sessions import InMemorySessionService from google . adk . tools . preload_memory_tool import PreloadMemoryTool from google . genai import types os . environ [ "GOOGLE_GENAI_USE_ENTERPRISE" ] = "TRUE" os . environ [ "GOOGLE_CLOUD_PROJECT" ] = "project-xxxxxxxx" os . environ [ "GOOGLE_CLOUD_LOCATION" ] = "australia-southeast1" APP_NAME = "APP_NAME" # Memories are scoped per (app_name, user_id), so keep user_id stable # across sessions or the agent won't find earlier memories. USER_ID ...

google adk - compactiing conversation

We can easily compact our conversation by using the following code. Notice we are using App and EventsCompactionConfig (it is experimental) that can help to optimized latency and reduces cost. How we choose to compact our conversation is defined here Threshold approach # 3. Compaction config compaction_config = EventsCompactionConfig (     # Token-based (primary): compact when the prompt exceeds this many tokens     token_threshold = 1000 ,     event_retention_size = 3 ,       # keep the last 3 events raw     # Sliding window (supplementary): compact every N invocations     compaction_interval = 3 ,     overlap_size = 1 ,     summarizer = summarizer , ) If you opt for sliding window compact approach Sliding window approach   compaction_config = EventsCompactionConfig (     compaction_interval = 10 ,   # Number of new invocations between standard compactions     overlap_...