Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- name: Build and push production RPC image
uses: docker/build-push-action@v5
with:
file: images/rpc/Dockerfile_prod
file: resources/images/rpc/Dockerfile_prod
platforms: linux/amd64,linux/arm64
context: .
push: true
Expand All @@ -50,7 +50,7 @@ jobs:
if: github.ref == 'refs/heads/main'
uses: docker/build-push-action@v5
with:
file: images/rpc/Dockerfile_dev
file: resources/images/rpc/Dockerfile_dev
platforms: linux/amd64,linux/arm64
context: .
push: true
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Build and export
uses: docker/build-push-action@v5
with:
file: images/rpc/Dockerfile_prod
file: resources/images/rpc/Dockerfile_prod
context: .
tags: warnet/dev
cache-from: type=gha
Expand Down Expand Up @@ -74,13 +74,13 @@ jobs:
uv pip install -e .

echo "Contents of warnet-rpc-statefulset-dev.yaml being used:"
cat manifests/warnet-rpc-statefulset-dev.yaml
cat resources/manifests/warnet-rpc-statefulset-dev.yaml

echo Setting up k8s
kubectl apply -f manifests/namespace.yaml
kubectl apply -f manifests/rbac-config.yaml
kubectl apply -f manifests/warnet-rpc-service.yaml
kubectl apply -f manifests/warnet-rpc-statefulset-dev.yaml
kubectl apply -f resources/manifests/namespace.yaml
kubectl apply -f resources/manifests/rbac-config.yaml
kubectl apply -f resources/manifests/warnet-rpc-service.yaml
kubectl apply -f resources/manifests/warnet-rpc-statefulset-dev.yaml
kubectl config set-context --current --namespace=warnet

echo sleeping for 30s to give k8s time to boot
Expand Down
4 changes: 1 addition & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
include src/warnet/*.json
graft images
graft manifests
graft scripts
graft resources
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ build-backend = "setuptools.build_meta"
[tool.setuptools.dynamic]
dependencies = {file = ["requirements.txt"]}

[tool.setuptools]
include-package-data = true

[tool.setuptools.packages.find]
where = ["src"]
where = ["src", "resources"]

[tool.ruff]
extend-exclude = [
Expand Down
Empty file added resources/__init__.py
Empty file.
Empty file added resources/graphs/__init__.py
Empty file.
File renamed without changes.
Empty file added resources/images/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file added resources/manifests/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file added resources/scripts/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/warnet/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from pathlib import Path
from importlib.resources import files

SRC_DIR = Path(__file__).parent
SRC_DIR = files("warnet")
27 changes: 13 additions & 14 deletions src/warnet/cli/cluster.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import os
import subprocess
import sys
from pathlib import Path
from importlib.resources import files

import click

MANIFEST_PATH = files("manifests")
RPC_PATH = files("images").joinpath("rpc")


@click.group(name="cluster", chain=True)
def cluster():
Expand Down Expand Up @@ -52,24 +55,20 @@ def run_command(command, stream_output=False):
@cluster.command()
def minikube_setup():
"""Setup minikube for use with Warnet"""
template_path = (
Path(os.path.dirname(os.path.abspath(__file__))) / ".." / ".." / ".." / "manifests" / "rpc"
)

script_content = f"""
#!/usr/bin/env bash
set -euxo pipefail
# Function to check if minikube is running
check_minikube() {{
minikube status | grep -q "Running" && echo "Minikube is already running" || minikube start --memory=max --cpus=max --mount --mount-string="$PWD:/mnt/src"
minikube status | grep -q "Running" && echo "Minikube is already running" || minikube start --memory=4000mb --cpus=4 --mount --mount-string="$PWD:/mnt/src"
}}
# Check minikube status
check_minikube
# Build image in local registry and load into minikube
docker build -t warnet/dev -f {template_path}/Dockerfile_dev {template_path} --load
docker build -t warnet/dev -f {RPC_PATH}/Dockerfile_dev {RPC_PATH} --load
minikube image load warnet/dev
"""

Expand All @@ -79,23 +78,23 @@ def minikube_setup():
@cluster.command()
def deploy():
"""Setup Warnet using the current kubectl-configured cluster"""
script_content = """
script_content = f"""
#!/usr/bin/env bash
set -euxo pipefail
# Function to check if warnet-rpc container is already running
check_warnet_rpc() {
check_warnet_rpc() {{
if kubectl get pods --all-namespaces | grep -q "bitcoindevproject/warnet-rpc"; then
echo "warnet-rpc already running in minikube"
exit 1
fi
}
}}
# Setup K8s
kubectl apply -f manifests/namespace.yaml
kubectl apply -f manifests/rbac-config.yaml
kubectl apply -f manifests/warnet-rpc-service.yaml
kubectl apply -f manifests/warnet-rpc-statefulset-dev.yaml
kubectl apply -f {MANIFEST_PATH}/namespace.yaml
kubectl apply -f {MANIFEST_PATH}/rbac-config.yaml
kubectl apply -f {MANIFEST_PATH}/warnet-rpc-service.yaml
kubectl apply -f {MANIFEST_PATH}/warnet-rpc-statefulset-dev.yaml
kubectl config set-context --current --namespace=warnet
# Check for warnet-rpc container
Expand Down
13 changes: 2 additions & 11 deletions src/warnet/cli/image_build.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
import os
import subprocess
from pathlib import Path
from importlib.resources import files

ARCHES = ["amd64", "arm64", "armhf"]

dockerfile_path = (
Path(os.path.dirname(os.path.abspath(__file__)))
/ ".."
/ ".."
/ ".."
/ "images"
/ "bitcoin"
/ "Dockerfile"
)
dockerfile_path = files("images.bitcoin").joinpath("Dockerfile")


def run_command(command):
Expand Down
12 changes: 3 additions & 9 deletions src/warnet/cli/network.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import base64 # noqa: I001
import json
import os
from pathlib import Path
from importlib.resources import files

import click
from rich import print
Expand All @@ -10,14 +10,8 @@

from .rpc import rpc_call # noqa: I001

DEFAULT_GRAPH_FILE = (
Path(os.path.dirname(os.path.abspath(__file__)))
/ ".."
/ ".."
/ ".."
/ "graphs"
/ "default.graphml"
)

DEFAULT_GRAPH_FILE = files("graphs").joinpath("default.graphml")


def print_repr(wn: dict) -> None:
Expand Down
2 changes: 1 addition & 1 deletion src/warnet/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def __init__(self):

def setup_global_exception_handler(self):
"""
Use flask to log traceback of unhandled excpetions
Use flask to log traceback of unhandled exceptions
"""

@self.app.errorhandler(Exception)
Expand Down