245
Makefile
Archivo normal
245
Makefile
Archivo normal
@@ -0,0 +1,245 @@
|
||||
# HDH Deployment Example - Makefile
|
||||
# Automation for building, testing, and deploying HDH examples
|
||||
# Special thanks to Maria Gragera Garces for the HDH library!
|
||||
|
||||
.PHONY: help install test clean run benchmark docker docker-build docker-run lint format docs
|
||||
|
||||
# Default target
|
||||
.DEFAULT_GOAL := help
|
||||
|
||||
# Variables
|
||||
PYTHON := python3
|
||||
PIP := pip3
|
||||
DOCKER_IMAGE := hdh-deployment
|
||||
DOCKER_TAG := latest
|
||||
OUTPUT_DIR := hdh_results
|
||||
BENCHMARK_DIR := benchmark_results
|
||||
|
||||
# Colors for output
|
||||
BLUE := \033[36m
|
||||
GREEN := \033[32m
|
||||
YELLOW := \033[33m
|
||||
RED := \033[31m
|
||||
NC := \033[0m # No Color
|
||||
|
||||
help: ## Show this help message
|
||||
@echo "$(BLUE)HDH Deployment Example - Makefile$(NC)"
|
||||
@echo "$(YELLOW)Special thanks to Maria Gragera Garces for the HDH library!$(NC)"
|
||||
@echo ""
|
||||
@echo "Available targets:"
|
||||
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " $(GREEN)%-15s$(NC) %s\n", $$1, $$2}' $(MAKEFILE_LIST)
|
||||
|
||||
install: ## Install dependencies and HDH library
|
||||
@echo "$(BLUE)Installing dependencies...$(NC)"
|
||||
$(PIP) install -r requirements.txt
|
||||
@echo "$(BLUE)Installing HDH library in development mode...$(NC)"
|
||||
$(PIP) install -e ../HDH
|
||||
@echo "$(GREEN)Installation completed!$(NC)"
|
||||
|
||||
install-dev: ## Install development dependencies
|
||||
@echo "$(BLUE)Installing development dependencies...$(NC)"
|
||||
$(PIP) install -r requirements.txt
|
||||
$(PIP) install -e ".[dev]"
|
||||
$(PIP) install -e ../HDH
|
||||
@echo "$(GREEN)Development installation completed!$(NC)"
|
||||
|
||||
test: ## Run tests
|
||||
@echo "$(BLUE)Running tests...$(NC)"
|
||||
$(PYTHON) -m pytest tests/ -v
|
||||
@echo "$(GREEN)Tests completed!$(NC)"
|
||||
|
||||
clean: ## Clean up generated files and directories
|
||||
@echo "$(BLUE)Cleaning up...$(NC)"
|
||||
rm -rf $(OUTPUT_DIR)
|
||||
rm -rf $(BENCHMARK_DIR)
|
||||
rm -rf qasm_examples
|
||||
rm -rf logs
|
||||
rm -rf __pycache__
|
||||
rm -rf .pytest_cache
|
||||
rm -rf *.egg-info
|
||||
find . -name "*.pyc" -delete
|
||||
find . -name "*.pyo" -delete
|
||||
find . -name "__pycache__" -type d -exec rm -rf {} +
|
||||
@echo "$(GREEN)Cleanup completed!$(NC)"
|
||||
|
||||
run: ## Run the main deployment example
|
||||
@echo "$(BLUE)Running HDH deployment example...$(NC)"
|
||||
$(PYTHON) main.py --demo-mode --output-dir $(OUTPUT_DIR)
|
||||
@echo "$(GREEN)Deployment example completed!$(NC)"
|
||||
|
||||
run-cli: ## Run the interactive CLI
|
||||
@echo "$(BLUE)Starting HDH CLI...$(NC)"
|
||||
$(PYTHON) cli.py
|
||||
|
||||
benchmark: ## Run performance benchmarks
|
||||
@echo "$(BLUE)Running performance benchmarks...$(NC)"
|
||||
$(PYTHON) benchmark.py --suite all --repetitions 3 --output-dir $(BENCHMARK_DIR)
|
||||
@echo "$(GREEN)Benchmarks completed!$(NC)"
|
||||
|
||||
benchmark-quick: ## Run quick benchmarks (fewer repetitions)
|
||||
@echo "$(BLUE)Running quick benchmarks...$(NC)"
|
||||
$(PYTHON) benchmark.py --suite algorithms --repetitions 1 --output-dir $(BENCHMARK_DIR)
|
||||
@echo "$(GREEN)Quick benchmarks completed!$(NC)"
|
||||
|
||||
examples: ## Generate circuit examples and QASM files
|
||||
@echo "$(BLUE)Generating circuit examples...$(NC)"
|
||||
$(PYTHON) circuit_examples.py
|
||||
@echo "$(GREEN)Examples generated!$(NC)"
|
||||
|
||||
validate: ## Validate HDH environment
|
||||
@echo "$(BLUE)Validating HDH environment...$(NC)"
|
||||
$(PYTHON) utils.py
|
||||
@echo "$(GREEN)Validation completed!$(NC)"
|
||||
|
||||
lint: ## Run code linting
|
||||
@echo "$(BLUE)Running linting...$(NC)"
|
||||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
||||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
||||
@echo "$(GREEN)Linting completed!$(NC)"
|
||||
|
||||
format: ## Format code with black and isort
|
||||
@echo "$(BLUE)Formatting code...$(NC)"
|
||||
black .
|
||||
isort .
|
||||
@echo "$(GREEN)Code formatting completed!$(NC)"
|
||||
|
||||
type-check: ## Run type checking with mypy
|
||||
@echo "$(BLUE)Running type checking...$(NC)"
|
||||
mypy . --ignore-missing-imports
|
||||
@echo "$(GREEN)Type checking completed!$(NC)"
|
||||
|
||||
# Docker targets
|
||||
docker-build: ## Build Docker image
|
||||
@echo "$(BLUE)Building Docker image...$(NC)"
|
||||
docker build -t $(DOCKER_IMAGE):$(DOCKER_TAG) .
|
||||
@echo "$(GREEN)Docker image built: $(DOCKER_IMAGE):$(DOCKER_TAG)$(NC)"
|
||||
|
||||
docker-run: ## Run Docker container
|
||||
@echo "$(BLUE)Running Docker container...$(NC)"
|
||||
docker run --rm -v $(PWD)/$(OUTPUT_DIR):/app/hdh_results $(DOCKER_IMAGE):$(DOCKER_TAG)
|
||||
@echo "$(GREEN)Docker container execution completed!$(NC)"
|
||||
|
||||
docker-cli: ## Run Docker container with CLI
|
||||
@echo "$(BLUE)Starting Docker container with CLI...$(NC)"
|
||||
docker run --rm -it -v $(PWD)/$(OUTPUT_DIR):/app/hdh_results $(DOCKER_IMAGE):$(DOCKER_TAG) python cli.py
|
||||
|
||||
docker-benchmark: ## Run benchmarks in Docker
|
||||
@echo "$(BLUE)Running benchmarks in Docker...$(NC)"
|
||||
docker run --rm -v $(PWD)/$(BENCHMARK_DIR):/app/benchmark_results $(DOCKER_IMAGE):$(DOCKER_TAG) python benchmark.py --suite all
|
||||
|
||||
docker-compose-up: ## Start Docker Compose services
|
||||
@echo "$(BLUE)Starting Docker Compose services...$(NC)"
|
||||
docker-compose up -d
|
||||
@echo "$(GREEN)Docker Compose services started!$(NC)"
|
||||
|
||||
docker-compose-down: ## Stop Docker Compose services
|
||||
@echo "$(BLUE)Stopping Docker Compose services...$(NC)"
|
||||
docker-compose down
|
||||
@echo "$(GREEN)Docker Compose services stopped!$(NC)"
|
||||
|
||||
docker-compose-benchmark: ## Run benchmark with Docker Compose
|
||||
@echo "$(BLUE)Running benchmark with Docker Compose...$(NC)"
|
||||
docker-compose --profile benchmark up hdh-benchmark
|
||||
@echo "$(GREEN)Docker Compose benchmark completed!$(NC)"
|
||||
|
||||
# Documentation targets
|
||||
docs: ## Generate documentation (placeholder)
|
||||
@echo "$(BLUE)Generating documentation...$(NC)"
|
||||
@echo "$(YELLOW)Documentation generation not yet implemented$(NC)"
|
||||
@echo "$(GREEN)Please refer to README.md for now$(NC)"
|
||||
|
||||
# Analysis targets
|
||||
analyze-results: ## Analyze existing results
|
||||
@echo "$(BLUE)Analyzing results...$(NC)"
|
||||
@if [ -d "$(OUTPUT_DIR)" ]; then \
|
||||
echo "$(GREEN)Found results in $(OUTPUT_DIR)$(NC)"; \
|
||||
find $(OUTPUT_DIR) -name "*.json" -exec echo " - {}" \; ; \
|
||||
find $(OUTPUT_DIR) -name "*.png" -exec echo " - {}" \; ; \
|
||||
else \
|
||||
echo "$(YELLOW)No results directory found. Run 'make run' first.$(NC)"; \
|
||||
fi
|
||||
|
||||
analyze-benchmarks: ## Analyze benchmark results
|
||||
@echo "$(BLUE)Analyzing benchmark results...$(NC)"
|
||||
@if [ -d "$(BENCHMARK_DIR)" ]; then \
|
||||
echo "$(GREEN)Found benchmarks in $(BENCHMARK_DIR)$(NC)"; \
|
||||
find $(BENCHMARK_DIR) -name "*.json" -exec echo " - {}" \; ; \
|
||||
find $(BENCHMARK_DIR) -name "*.png" -exec echo " - {}" \; ; \
|
||||
else \
|
||||
echo "$(YELLOW)No benchmark directory found. Run 'make benchmark' first.$(NC)"; \
|
||||
fi
|
||||
|
||||
# Complete workflow targets
|
||||
demo: ## Run complete demonstration workflow
|
||||
@echo "$(BLUE)Running complete HDH demonstration...$(NC)"
|
||||
$(MAKE) clean
|
||||
$(MAKE) examples
|
||||
$(MAKE) run
|
||||
$(MAKE) benchmark-quick
|
||||
$(MAKE) analyze-results
|
||||
@echo "$(GREEN)Complete demonstration finished!$(NC)"
|
||||
@echo "$(YELLOW)Thank you Maria Gragera Garces for the HDH library! 🎉$(NC)"
|
||||
|
||||
full-demo: ## Run full demonstration with comprehensive benchmarks
|
||||
@echo "$(BLUE)Running full HDH demonstration...$(NC)"
|
||||
$(MAKE) clean
|
||||
$(MAKE) examples
|
||||
$(MAKE) run
|
||||
$(MAKE) benchmark
|
||||
$(MAKE) analyze-results
|
||||
$(MAKE) analyze-benchmarks
|
||||
@echo "$(GREEN)Full demonstration completed!$(NC)"
|
||||
@echo "$(YELLOW)Thank you Maria Gragera Garces for the HDH library! 🎉$(NC)"
|
||||
|
||||
# Development workflow
|
||||
dev-setup: ## Set up development environment
|
||||
@echo "$(BLUE)Setting up development environment...$(NC)"
|
||||
$(MAKE) install-dev
|
||||
$(MAKE) validate
|
||||
@echo "$(GREEN)Development environment ready!$(NC)"
|
||||
|
||||
dev-test: ## Run development tests and checks
|
||||
@echo "$(BLUE)Running development tests...$(NC)"
|
||||
$(MAKE) lint
|
||||
$(MAKE) format
|
||||
$(MAKE) type-check
|
||||
$(MAKE) test
|
||||
@echo "$(GREEN)Development tests completed!$(NC)"
|
||||
|
||||
# CI/CD targets
|
||||
ci-test: ## Run CI/CD test suite
|
||||
@echo "$(BLUE)Running CI/CD tests...$(NC)"
|
||||
$(MAKE) install
|
||||
$(MAKE) validate
|
||||
$(MAKE) lint
|
||||
$(MAKE) test
|
||||
$(MAKE) run
|
||||
@echo "$(GREEN)CI/CD tests completed!$(NC)"
|
||||
|
||||
# Status and information
|
||||
status: ## Show current status
|
||||
@echo "$(BLUE)HDH Deployment Status$(NC)"
|
||||
@echo "$(YELLOW)Special thanks to Maria Gragera Garces!$(NC)"
|
||||
@echo ""
|
||||
@echo "Python version: $(shell $(PYTHON) --version)"
|
||||
@echo "HDH library: $(shell $(PYTHON) -c 'import hdh; print("Available")' 2>/dev/null || echo "Not available")"
|
||||
@echo "Output directory: $(OUTPUT_DIR) $(shell [ -d $(OUTPUT_DIR) ] && echo "(exists)" || echo "(not found)")"
|
||||
@echo "Benchmark directory: $(BENCHMARK_DIR) $(shell [ -d $(BENCHMARK_DIR) ] && echo "(exists)" || echo "(not found)")"
|
||||
@echo "Docker image: $(shell docker images -q $(DOCKER_IMAGE):$(DOCKER_TAG) >/dev/null 2>&1 && echo "Built" || echo "Not built")"
|
||||
|
||||
info: ## Show project information
|
||||
@echo "$(BLUE)HDH Deployment Example$(NC)"
|
||||
@echo "$(YELLOW)Special thanks to Maria Gragera Garces for the HDH library!$(NC)"
|
||||
@echo ""
|
||||
@echo "This example demonstrates comprehensive deployment of the HDH"
|
||||
@echo "(Hybrid Dependency Hypergraph) library for quantum computation."
|
||||
@echo ""
|
||||
@echo "Features:"
|
||||
@echo " • Quantum circuit processing and analysis"
|
||||
@echo " • Performance benchmarking suite"
|
||||
@echo " • Interactive command-line interface"
|
||||
@echo " • Docker containerization"
|
||||
@echo " • Comprehensive visualization tools"
|
||||
@echo ""
|
||||
@echo "For help: make help"
|
||||
@echo "To get started: make demo"
|
||||
Referencia en una nueva incidencia
Block a user