Skip to content

funkatron/dts-utils

Repository files navigation

Draw Things gRPC Server Utilities

A Python package providing utilities for interacting with the Draw Things gRPC server. This package includes tools for server installation, management, and client communication.

What This Package Provides

  • Server Management Tools:

    • Installation and configuration of the Draw Things gRPC server
    • Server lifecycle management (start, stop, restart)
    • Health monitoring and status checks
    • Log file management
  • Client Utilities:

    • Python helper functions for connecting to the gRPC server
    • Error handling utilities for gRPC calls
    • Connection management tools
  • Security Features:

    • TLS configuration management
    • Authentication setup
    • Certificate management

What This Package Does Not Provide

  • Image Generation Logic: The actual image generation is handled by the Draw Things gRPC server
  • Model Management: Model loading and management is handled by the server
  • GPU Management: GPU configuration is handled by the server
  • Web Interface: This is a command-line and programmatic interface only
  • Endpoint Management: The gRPC server's endpoints are fixed and cannot be modified through this tool

Features

  • Server Management: One-command installation and configuration of the Draw Things gRPC server
  • gRPC Client Utilities: Python library for easy integration with the image generation service
  • File Management: Tools for handling server files and configurations
  • Health Monitoring: Built-in health check endpoints for server status verification
  • Security Features:
    • TLS encryption support for secure communication
    • Authentication via shared secrets
    • Certificate chain verification
    • Client certificate validation

Installation

# Clone the repository
git clone https://github.com/funkatron/draw-things-grpcservercli-installer.git
cd draw-things-grpcservercli-installer

# Create and activate a virtual environment
python -m venv venv
source venv/bin/activate  # On macOS/Linux
# or
.\venv\Scripts\activate  # On Windows

# Install the package
pip install .

Note: Always activate the virtual environment before using dts-util commands:

source venv/bin/activate  # On macOS/Linux
# or
.\venv\Scripts\activate  # On Windows

Getting Started

Quick Start Guide

If you're new to the Draw Things gRPC server, here's a simple guide to get you started:

  1. Install the Server:
# This will install the server with default settings
dts-util install
  1. Verify the Server is Running:
dts-util test
  1. Generate Your First Image:
from dts_util.grpc.utils import create_channel_and_stub, handle_grpc_error
from dts_util.grpc.proto.image_generation_pb2 import GenerateImageRequest

# Connect to the server (defaults to localhost:7859, no TLS)
channel, stub = create_channel_and_stub(port=7859)

# Generate an image
with handle_grpc_error():
    response = stub.GenerateImage(GenerateImageRequest(
        prompt="a beautiful sunset over mountains",  # Describe what you want to generate
        negative_prompt="",                          # What you don't want in the image
        width=512,                                   # Image width in pixels
        height=512                                   # Image height in pixels
    ))

Common Tasks

Custom Server Settings

# Change port and model path
dts-util install --port 7860 --model-path /path/to/model

# Enable advanced features
dts-util install --model-browser --debug

Secure Setup

# Enable TLS and set a shared secret
dts-util install --shared-secret "your-secret-here"

Server Management

# Check server status
dts-util test

# Restart the server
dts-util restart

# Uninstall the server
dts-util uninstall

Troubleshooting

Server Not Starting

  1. Check server status:
dts-util test
  1. Check server logs:
cat ~/.config/draw-things/server.log

Connection Issues

  1. Verify server is running:
dts-util test
  1. Check port availability:
dts-util test --port 7860
  1. Check TLS configuration:
# If using TLS, ensure your client is configured correctly
# You can verify server configuration in ~/.config/draw-things/server.conf

Advanced Usage

Package Structure

The package is organized into several modules:

src/
├── dts_util/
│   ├── installer/               # Server installation and management
│   ├── grpc/                    # Client communication tools
│   └── utils/                   # Shared utilities

Complete Installation Options

For advanced users, here are all available installation options:

# Basic settings
dts-util install --port 7860 --model-path /path/to/model

# Security settings
dts-util install --shared-secret "your-secret-here"

# Advanced settings
dts-util install --model-browser --debug --no-flash-attention

Python Client Examples

Basic Image Generation

from dts_util.grpc.utils import create_channel_and_stub, handle_grpc_error
from dts_util.grpc.proto.image_generation_pb2 import GenerateImageRequest

# Connect to server
channel, stub = create_channel_and_stub(port=7859)

# Generate image
with handle_grpc_error():
    response = stub.GenerateImage(GenerateImageRequest(
        prompt="a beautiful landscape",
        negative_prompt="blurry, low quality",
        width=512,
        height=512
    ))

Error Handling

from dts_util.grpc.utils import handle_grpc_error

try:
    with handle_grpc_error():
        # Your code here
        pass
except Exception as e:
    print(f"Error occurred: {e}")

Documentation

Package Documentation

Draw Things gRPC Server Documentation

Development

Requirements

  • Python 3.8+
  • gRPC tools
  • Protocol Buffers compiler

Setting Up Development

# Install development dependencies
pip install -e ".[dev]"

# Run tests
pytest tests/

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages