diff --git a/geoBoundaryBuilder/images/geoBoundariesBase.Dockerfile b/geoBoundaryBuilder/images/geoBoundariesBase.Dockerfile index ff73038..c8f076d 100644 --- a/geoBoundaryBuilder/images/geoBoundariesBase.Dockerfile +++ b/geoBoundaryBuilder/images/geoBoundariesBase.Dockerfile @@ -24,8 +24,19 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ zlib1g-dev \ libcairo2-dev \ libpq-dev \ + curl \ + apt-transport-https \ + ca-certificates \ + gnupg \ && apt-get clean && rm -rf /var/lib/apt/lists/* +# Install Docker CLI +RUN curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg && \ + echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" > /etc/apt/sources.list.d/docker.list && \ + apt-get update && apt-get install -y --no-install-recommends \ + docker-ce-cli && \ + apt-get clean && rm -rf /var/lib/apt/lists/* + # Upgrade pip and install Python dependencies RUN pip install --upgrade pip && \ pip install prefect==3.1.5 kubernetes==25.3.0 diff --git a/geoBoundaryBuilder/k8s_manifests/dev.yml b/geoBoundaryBuilder/k8s_manifests/dev.yml index 677559e..25819cf 100644 --- a/geoBoundaryBuilder/k8s_manifests/dev.yml +++ b/geoBoundaryBuilder/k8s_manifests/dev.yml @@ -1,7 +1,7 @@ apiVersion: v1 kind: Pod metadata: - name: gB-dev + name: gbdev namespace: geoboundaries spec: securityContext: @@ -9,7 +9,7 @@ spec: runAsGroup: 9915 containers: - name: gb-dev-container - image: ghcr.io/your-custom-image:latest # Replace with your custom image name + image: ghcr.io/wmgeolab/gb-base:latest # Replace with your custom image name command: ["/bin/sh", "-c"] # Keep the container running args: - | diff --git a/geoBoundaryBuilder/test.py b/geoBoundaryBuilder/test.py index b8aaf55..3a4cdc9 100644 --- a/geoBoundaryBuilder/test.py +++ b/geoBoundaryBuilder/test.py @@ -1,16 +1,23 @@ +import os import subprocess -from prefect import flow, task -# Step 1: Set Prefect API URL dynamically +# Configure Prefect home directory and API URL +os.environ["PREFECT_HOME"] = "/tmp/.prefect" # Ensure this path is writable PREFECT_API_URL = "http://prefect-server-service.geoboundaries.svc.cluster.local:4200/api" +os.environ["PREFECT_API_URL"] = PREFECT_API_URL # Directly set in environment +print(f"Using PREFECT_API_URL: {PREFECT_API_URL}") subprocess.run(["prefect", "config", "set", f"PREFECT_API_URL={PREFECT_API_URL}"], check=True) -# Step 2: Define a task to process individual numbers + +from prefect import flow, task + + +# Define a task to process numbers @task def multiply_by_20(number): return number * 20 -# Step 3: Define the main flow to process a list of numbers +# Define the main flow @flow def process_numbers_flow(numbers): results = [] @@ -19,16 +26,17 @@ def process_numbers_flow(numbers): results.append(result) return [r.result() for r in results] # Gather the results -# Step 4: Main script to deploy and run the flow if __name__ == "__main__": - # Define the list of numbers - numbers = list(range(1, 11)) - - # Deploy the flow (if needed) + # Deploy the flow print("Deploying the flow...") - process_numbers_flow.deploy(name="process-numbers-deployment", work_pool_name="k8s-gB") - - # Run the flow locally + process_numbers_flow.deploy( + name="process-numbers-deployment", + work_pool_name="k8s-gB", + image="ghcr.io/wmgeolab/gb-base:latest" # Ensure this matches your Kubernetes work pool + ) + + # Run the flow locally for testing print("Running the flow locally...") + numbers = list(range(1, 11)) results = process_numbers_flow(numbers) print("Results:", results)