Posts

qwen 3 (0.6B) - running in google colab

Image
Trying to run qwen 3 with 0.6 billion parameters on google colab using code straight from hugging face here. (https://huggingface.co/Qwen/Qwen3-0.6B).  The code looks like this.  from transformers import AutoModelForCausalLM, AutoTokenizer model_name = "Qwen/Qwen3-0.6B" # load the tokenizer and the model tokenizer = AutoTokenizer.from_pretrained( model_name ) model = AutoModelForCausalLM.from_pretrained(     model_name ,     torch_dtype = "auto" ,     device_map = "auto" ) # prepare the model input prompt = "Give me a short introduction to large language model." messages = [     { "role" : "user" , "content" : prompt } ] text = tokenizer .apply_chat_template(     messages ,     tokenize = False ,     add_generation_prompt = True ,     enable_thinking = True # Switches between thinking and non-thinking modes. Default is True. ) model_inputs = tokenizer ([ text ], return_tensors = "p...

aws assume role basics

Image
AWS Assume role allow a principal (an IAM user or role) to temporarily assume a different IAM role and receive temporary credentials (AccessKeyId, SecretAccessKey, SessionToken). You use this when: Accessing another AWS account (cross-account access), Escalating privileges temporarily, Following least privilege principles. So you need to create a role, define who can assume this newly create role and finally you need to specify what permission tied to it. Otherwise, there's no reason to do this. :)  In your IAM console, click on Create Role.  Then select "Custom Trust policy".       Then specify, the principal who can assume this role.  {   "Version" : "2012-10-17" ,   "Statement" : [     {       "Sid" : "Statement1" ,       "Effect" : "Allow" ,       "Principal" : {         "AWS" : "arn:aws:iam::your-aws-id:user/jeremydev"       },   ...

kong service mesh - setup and deploy to AKS manually for testing purposes

Image
To install kong service mesh via helm run the following command in your cloud shell. helm repo add kong-mesh https://kong.github.io/kong-mesh-charts helm repo update helm install --create-namespace --namespace kong-mesh-system kong-mesh kong-mesh/kong-mesh Takes abit of time to spin this up.  kubectl apply -f https://raw.githubusercontent.com/kumahq/kuma-counter-demo/refs/heads/main/k8s/000-with-kuma.yaml kubectl wait -n kuma-demo --for=condition=ready pod --selector=app=demo-app --timeout=90s And then you can see some of the pods being spined up. Also notice we have our namespace labeled (kuma.io/sidecar-injection: enabled). To turn on, mutual tls, we can use the following yaml. apiVersion : kuma.io/v1alpha1 kind : Mesh metadata :   name : default spec :   meshServices :     mode : Exclusive   mtls :     backends :       - name : ca-1         type : builtin     enabledBackend : ca-1 And the enable appl...

aks new feature - configuring different vm sku for the same node pool

Image
AKS allows us to have different VM sku in the same node pool. For example, lets say you have a single node pool, we are restricted to use the same sku 'standard_ds3_v2' and subsequent VM would require us to use the same sku.  AKS allow different vm sku now.  You can easily set it up by enabling this feature in your cluster. az extension add --name aks-preview az extension update --name aks-preview az feature registration create --namespace Microsoft.ContainerService --name VMsAgentPoolPreview az feature show --namespace "Microsoft.ContainerService" --name "VMsAgentPoolPreview" Next create your cluster with the preview VMs. az aks create --resource-group my-aks-rg --name myakscluster --vm-set-type "VirtualMachines" --node-count 1 --node-vm-size standard_a2_v2 --generate-ssh-keys   Your cluster no longer uses VMSS scale set. Instead you can see VM directly provision in your management cluster resource group.  Add a user pool in to your cluster  az ak...

az cli - The behavior of this command has been altered by the following extension: aks-preview An RSA key file or key value must be supplied to SSH Key Value. You can use --generate-ssh-keys to let CLI generate one for you

 When running az cli to create aks cluster i bump into this issue " The behavior of this command has been altered by the following extension: aks-preview" An RSA key file or key value must be supplied to SSH Key Value. You can use --generate-ssh-keys to let CLI generate one for you " To resolve this issue, all you need to do is, add the followings --generate-ssh-keys to your az cli command as shown here: az aks create --resource-group rg-aks-mixed-pools --name myakscluster --vm-set-type "VirtualMachines" --node-count 1 --generate-ssh-keys

azure synapse - your file cannot be opened because it does not exist or it is used by another process.

Image
When creating Azure Synapse I created data lake manually. Then I found that there's some issues trying to run SQL query against external csv file.  I checked I have given it Storage Blob Data Contributor access to the data lake and it matches the identity.   And provided the required permission from storage perspective. I also noticed that i can preview the data - but unable to execute query using SELECT OPENROWSET.  The solution, I didn't have my user account assigned the proper permission. I need to have Storage Blob Data Contributor for my user as well.  You have have noticed this when you're trying to create a pool - sql or spark pool.  And then, I was able to run query:

azure synapse - This endpoint does not support BlobStorageEvents or SoftDelete. Please disable these account features if you would like to use this endpoint

Image
Bump into this error while trying to setup my Synapse workspace.   'This endpoint does not support BlobStorageEvents or SoftDelete. Please disable these account features if you would like to use this endpoint' Operation returned an invalid status code 'Conflict' It turns out that in order to setup my connection to ADL Gen2, that i create manually which comes with these options enabled. So it you're creating your Azure Data Lake manually, please disable these options.  To resolve these, please disable these 2 options and then re-test your connection. 

github actions faqs

Working with different stage does not mean you have access to the previous stage that download code repository Github action different stage that runs will not have access to code downloaded or checkout from previous. Something that tripped me while trying to reuse create a reusable workflow template.  Stages that does not specified "needs" it will run one after another (sequentially) Here we have build and containerize stage. without specifying needs, build will run first and then containerize.  jobs :   build :     runs-on : ubuntu-latest     steps :       - name : Checkout code         uses : actions/checkout@v4       - name : Setup dotnet         uses : actions/setup-dotnet@v4         with :           dotnet-version : '${{ inputs.dotnet-version }}'     containerize :           permissions :   ...

Can't find 'action.yml', 'action.yaml' or 'Dockerfile' under your-repository/.github/workflows/test.yaml'. Did you forget to run actions/checkout before running your local action?

 This error simply means github actions try to retrieve and run your yaml from ./github/workflows/test.yaml folder but couldn't find it.  Make sure you place your workflow yaml into this folder.  What if you want to place it in subfolder in ,/github/workflows?  No you cannot do that - it is not supported.  But you can reuse a workflow in this manner main.yaml -> test.yaml -> child.yaml.  So main calles test which in turn call another reusable workflow.

github action - reusable workflow within the same repository

Image
To call a reusable workflow within github, the workflow must and must exist in .github/workflows folder. For example, We have 2 files here main.yaml and test.yaml.  main.yaml calls test.yaml.  main.yaml. name : Hello World Workflow on :   push :     branches :       - main   workflow_dispatch :   jobs :   build :     runs-on : ubuntu-latest     steps :       - name : Checkout self repo         uses : actions/checkout@v4       - name : Checkout gha core         uses : actions/checkout@v4         with :           repository : mitzenjeremywoo/gha-core           path : gha-core           token : ${{ secrets.GITHUB_TOKEN }}   # or PAT if private       - name : Say hello         run : ls -al -R ${{ github.workspace }...

azure aks can't create kubenet networking for a cluster

Image
Interestingly we can't seems to create AKS with kubenet networking.

k8s mutating and validation webhook

The flow for k8s mutation and validation webhook can be illustrated here: Key points of interest are :- - Mutations happen first and may change the object - Validations happen after all mutations, working on the final mutated object -All webhooks in each phase are executed in defined order 1. User/API Client sends a request (e.g., create Pod)        │        ▼ 2. API Server handles:    - Authentication    - Authorization        │        ▼ 3. Admission Phase Begins        │        ▼ 4. MUTATING Webhooks (in order)    ┌──────────────────────────────┐    │ MutatingWebhook #1           │◄─── Can modify object    └──────────────────────────────┘              │              ▼    ┌──────────────────────────────┐  ...

azure fleet manager managing multiple aks cluster version/image upgrades

Image
 You can use fleet manager to upgrade your aks cluster version and node image. First you need fleet manager and a member. Member can resides in different regions.  You can see that a new AKS cluster gets created on top of the 2 we're trying to configured. Go to Setting -> Multi-Cluster update -> Create manual run.  Then under the page, specify the following options that you wanted. Once it is created, click on the run and select "Start". This is pretty straight forward.  It gets tricky when we get to create stage. Before you can create a stage, you need to assign / create an update group - as shown here.  Once you have this defined, you can easily create a stage for your strategy. For example,  Let's say you have 2 clusters, primary and secondary and you want to create a stage upgrade - upgrade secondary and then primary cluster.  This is where you can use stages.  Create a manual run, this time use "Stage", then click on "Create stage". The...

kafka creating message producer and client consumer

  To create a message producer that publishes message to a kafka, we can do the follow:-  import os from kafka import KafkaProducer def main ():     kafka_host = os . getenv ( 'KAFKA_HOST' )     # Connect to Kafka broker     producer = KafkaProducer( bootstrap_servers = f ' { kafka_host } :9092' )     # Send a message to a topic     producer .send( 'my-topic' , b 'Hello, Kafka!' )     # Optional: wait for all messages to be sent and close the producer     producer .flush()     producer .close() if __name__ == "__main__" :     main () And if you trying to create a message producer, you can use the simple code here: import os from kafka import KafkaConsumer kafka_host = os . getenv ( 'KAFKA_HOST' ) # Connect to Kafka and subscribe to a topic consumer = KafkaConsumer(     'my-topic' ,     bootstrap_servers = f ' { kafka_host } :9092' ,     auto...

github action Error: buildx failed with: ERROR: denied: permission_denied: write_package

Encounter this error while trying to get my dockerfile build going.  To fix this ensure, you have configure write permission like this:- name : python-client-prometheus on :   push :     branches : [ "main" ]   pull_request :     branches : [ "main" ] permissions :   packages : write   And then, also ensure you are using and pushing to the right (current) repository. In my case, my current build  repository is called  prometheus-monitoring-hello     - name : Build and Push Docker image       uses : docker/build-push-action@v5       with :         context : .         push : true         tags : ghcr.io/${{ github.repository_owner }}/prometheus-monitoring-hello:latest That's it.

minimax - running minimax model on a google colab - crash out with memory issue.

To run minimax llm model on a google colab we can open google colab and change the runtime type to T4/GPU. Then use the following scripts ! pip install -U transformers Next, we specify the model. A 32  billion parameter and takes up about 4.9G of space. Unfortunately, when trying to run this on a free Google Colab it crashes out. 😀 # Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline( "text-generation" , model= "MiniMaxAI/SynLogic-32B" ) messages = [     { "role" : "user" , "content" : "Who are you?" }, ] pipe(messages) Then tried using vllm to run the same model, got crashed out as well. Seems like it does requires quite abit of memory.  # Install vLLM from pip: ! pip install vllm # Load and run the model: ! vllm serve "MiniMaxAI/SynLogic-32B"

kafka setup in k8s cluster using strimizi

Image
To setup a kafka cluster in k8s is pretty easy with Strimizi.  We can start by creating a namespace call kafka using the following command kubectl create namespace kafka Then we setup stirmizi CRDs kubectl create -f 'https://strimzi.io/install/latest?namespace=kafka' -n kafka And finally installing the cluster kubectl apply -f https://strimzi.io/examples/latest/kafka/kafka-single-node.yaml -n kafka  If everything goes well, then you should have the followings  You can run the following command to check for your kakfa instance k get KafkaNodePool -A k get Kafka -A Send and receive messages To test out the consumer, run the following command and you can keep on entering messages by pressing enter. It will continuously accept inputs until you press Ctrl+break kubectl -n kafka run kafka-producer -ti --image=quay.io/strimzi/kafka:0.46.0-kafka-4.0.0 --rm=true --restart=Never -- bin/kafka-console-producer.sh --bootstrap-server my-cluster-kafka-bootstrap:9092 --topic my-topic To ...

stirmizi kafka setting up with the docs command issue

If you're trying to setup stirmizi kafka using the default command in the documentation page using powershell windows environment, you maybe asked to run the followings:   kubectl create -f 'https://strimzi.io/install/latest?namespace=kafka' -n kafka the above will error out.  The fix - remove the quotes  kubectl create -f  https://strimzi.io/install/latest?namespace=kafka -n kafka

langchain tool - how to create a lang chain tool

There are 3 options to create lang chain tool.  The first option is using  1. @tool decorator. Let's say we are creating a simple tool and all we need to do is use tool decorator like this from langchain_core . tools import tool from pydantic import BaseModel , Field class CalculatorInput ( BaseModel ):     a : int = Field ( description = "first number" )     b : int = Field ( description = "second number" ) @ tool ( "multiplication tool", args_schema = CalculatorInput) def multiply ( a : int , b : int ) -> int :     """Multiply two numbers."""     return a * b Then you can start binding the agent to this tool: from cal import multiply tools = [ multiply ] model_with_tools = model . bind_tools ( tools ) response = model_with_tools . invoke ([ HumanMessage ( content = "multiply 2 * 2" )]) print ( f "ContentString: { response . content } " ) print ( f "ToolCalls: { response...

langchain agent hello world

We can start building LLM agents using Langchain. Similiar to MCP, you would require a LLM engine such as Gemini, Chatgpt or Claude.  Please note this is only a agent - not a tool. To get started, you can register one for Gemini for free here https://aistudio.google.com/ and lets have it tested with the code sample.  In this example, we going to use gemini as the LLM and then ask it to do some search via Tavily tool.  So you get your LLM, get your agent tool in this case it is Tavily and then you bring it together.  from langchain_community . tools . tavily_search import TavilySearchResults search = TavilySearchResults ( max_results = 2 ) search_results = search . invoke ( "what is the weather in SF" ) print ( search_results ) # If we want, we can create other tools. # Once we have all the tools we want, we can put them in a list that we will reference later. tools = [ search ] Setting up your weapon of choice - LLM import getpass import os if not os . e...