mirror of
https://github.com/velocitatem/PHANTOM.git
synced 2026-05-31 08:33:36 +00:00
chore: cleaning
This commit is contained in:
62
Makefile
62
Makefile
@@ -11,56 +11,72 @@ PYTEST := $(VENV)/bin/pytest
|
|||||||
|
|
||||||
.DEFAULT_GOAL := help
|
.DEFAULT_GOAL := help
|
||||||
|
|
||||||
all: pdf
|
.PHONY: help
|
||||||
|
help:
|
||||||
run.webapp:
|
@echo "pdf.build pdf.watch pdf.clean | test.backend test.e2e test.all | web.dev | install | stats.lines"
|
||||||
@cd web && npm install && npm run dev
|
|
||||||
|
|
||||||
$(BUILDDIR):
|
$(BUILDDIR):
|
||||||
mkdir -p paper/$(BUILDDIR)
|
mkdir -p paper/$(BUILDDIR)
|
||||||
|
|
||||||
pdf: $(BUILDDIR)
|
.PHONY: pdf.build
|
||||||
@echo "Concatenating source code..."
|
pdf.build: $(BUILDDIR)
|
||||||
@bash paper/concat_code.sh
|
@bash paper/concat_code.sh
|
||||||
@cd $(SRCDIR) && \
|
@cd $(SRCDIR) && \
|
||||||
$(LATEXMK) -pdf -jobname=$(JOBNAME) \
|
$(LATEXMK) -pdf -jobname=$(JOBNAME) \
|
||||||
-interaction=nonstopmode -file-line-error \
|
-interaction=nonstopmode -file-line-error \
|
||||||
-outdir=../$(BUILDDIR) $(TEX)
|
-outdir=../$(BUILDDIR) $(TEX)
|
||||||
|
|
||||||
watch: $(BUILDDIR)
|
.PHONY: pdf.watch
|
||||||
|
pdf.watch: $(BUILDDIR)
|
||||||
@cd $(SRCDIR) && \
|
@cd $(SRCDIR) && \
|
||||||
$(LATEXMK) -pvc -pdf -jobname=$(JOBNAME) \
|
$(LATEXMK) -pvc -pdf -jobname=$(JOBNAME) \
|
||||||
-interaction=nonstopmode -file-line-error \
|
-interaction=nonstopmode -file-line-error \
|
||||||
-r ../.latexmkrc \
|
-r ../.latexmkrc \
|
||||||
-outdir=../$(BUILDDIR) $(TEX)
|
-outdir=../$(BUILDDIR) $(TEX)
|
||||||
|
|
||||||
clean:
|
.PHONY: pdf.clean
|
||||||
|
pdf.clean:
|
||||||
@cd $(SRCDIR) && \
|
@cd $(SRCDIR) && \
|
||||||
$(LATEXMK) -C -jobname=$(JOBNAME) -outdir=../$(BUILDDIR) || true
|
$(LATEXMK) -C -jobname=$(JOBNAME) -outdir=../$(BUILDDIR) || true
|
||||||
rm -rf paper/$(BUILDDIR)/*
|
rm -rf paper/$(BUILDDIR)/*
|
||||||
|
|
||||||
|
.PHONY: test.backend
|
||||||
|
test.backend: $(VENV)
|
||||||
|
$(PYTEST) -v
|
||||||
|
|
||||||
|
.PHONY: test.e2e
|
||||||
|
test.e2e:
|
||||||
|
@cd tests/e2e && npm install
|
||||||
|
@cd tests/e2e && npx playwright install chromium
|
||||||
|
@timeout 30 bash -c 'until curl -sf http://localhost:5000/health > /dev/null 2>&1; do sleep 1; done' || (echo "Backend not ready" && exit 1)
|
||||||
|
@timeout 30 bash -c 'until curl -sf http://localhost:3000 > /dev/null 2>&1; do sleep 1; done' || (echo "Web app not ready" && exit 1)
|
||||||
|
@cd tests/e2e && npm test
|
||||||
|
|
||||||
|
.PHONY: test.all
|
||||||
|
test.all: test.backend test.e2e
|
||||||
|
|
||||||
|
.PHONY: web.dev
|
||||||
|
web.dev:
|
||||||
|
@cd web && npm install && npm run dev
|
||||||
|
|
||||||
$(VENV):
|
$(VENV):
|
||||||
python3 -m venv $(VENV)
|
python3 -m venv $(VENV)
|
||||||
$(PIP) install --upgrade pip
|
$(PIP) install --upgrade pip
|
||||||
|
|
||||||
|
.PHONY: install
|
||||||
install: $(VENV)
|
install: $(VENV)
|
||||||
$(PIP) install -r requirements.txt
|
$(PIP) install -r requirements.txt
|
||||||
|
|
||||||
test: $(VENV)
|
.PHONY: stats.lines
|
||||||
$(PYTEST) -v
|
stats.lines:
|
||||||
|
|
||||||
count-lines:
|
|
||||||
@find . \( -path '*/node_modules' -o -path '*/.venv' -o -path '*/venv' \) -prune -o \
|
@find . \( -path '*/node_modules' -o -path '*/.venv' -o -path '*/venv' \) -prune -o \
|
||||||
\( -name "*.ts" -o -name "*.py" \) -type f -print0 | xargs -0 cat | wc -l
|
\( -name "*.ts" -o -name "*.py" \) -type f -print0 | xargs -0 cat | wc -l
|
||||||
|
|
||||||
test.e2e:
|
.PHONY: pdf clean watch run.webapp test count-lines all
|
||||||
@echo "Installing E2E dependencies..."
|
pdf: pdf.build
|
||||||
@cd tests/e2e && npm install
|
clean: pdf.clean
|
||||||
@cd tests/e2e && npx playwright install chromium --with-deps
|
watch: pdf.watch
|
||||||
@echo "Waiting for services..."
|
run.webapp: web.dev
|
||||||
@timeout 30 bash -c 'until curl -sf http://localhost:5000/health > /dev/null 2>&1; do sleep 1; done' || (echo "Backend not ready" && exit 1)
|
test: test.backend
|
||||||
@timeout 30 bash -c 'until curl -sf http://localhost:3000 > /dev/null 2>&1; do sleep 1; done' || (echo "Web app not ready" && exit 1)
|
count-lines: stats.lines
|
||||||
@echo "Running E2E tests..."
|
all: pdf.build
|
||||||
@cd tests/e2e && npm test
|
|
||||||
|
|
||||||
.PHONY: all pdf clean watch run.webapp install test test.e2e count-lines
|
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
"""Test configuration modules."""
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
from dataclasses import dataclass
|
|
||||||
from typing import Dict, Any
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
|
||||||
class SurgePricingConfig:
|
|
||||||
high_threshold: int
|
|
||||||
surge_multiplier: float
|
|
||||||
window_size: int # seconds
|
|
||||||
|
|
||||||
def to_dict(self) -> Dict[str, Any]:
|
|
||||||
return {
|
|
||||||
"high_threshold": self.high_threshold,
|
|
||||||
"surge_multiplier": self.surge_multiplier,
|
|
||||||
"window_size": self.window_size,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
|
||||||
class SessionAwareConfig:
|
|
||||||
velocity_threshold: float
|
|
||||||
view_depth_threshold: int
|
|
||||||
cart_ratio_threshold: float
|
|
||||||
agent_multiplier: float
|
|
||||||
|
|
||||||
def to_dict(self) -> Dict[str, Any]:
|
|
||||||
return {
|
|
||||||
"velocity_threshold": self.velocity_threshold,
|
|
||||||
"view_depth_threshold": self.view_depth_threshold,
|
|
||||||
"cart_ratio_threshold": self.cart_ratio_threshold,
|
|
||||||
"agent_multiplier": self.agent_multiplier,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# Test-optimized configurations for deterministic results
|
|
||||||
AGGRESSIVE_SURGE = SurgePricingConfig(
|
|
||||||
high_threshold=3,
|
|
||||||
surge_multiplier=1.5,
|
|
||||||
window_size=10,
|
|
||||||
)
|
|
||||||
|
|
||||||
MODERATE_SURGE = SurgePricingConfig(
|
|
||||||
high_threshold=5,
|
|
||||||
surge_multiplier=1.3,
|
|
||||||
window_size=15,
|
|
||||||
)
|
|
||||||
|
|
||||||
STRICT_SESSION_AWARE = SessionAwareConfig(
|
|
||||||
velocity_threshold=2.0, # 2 events/sec is agent-like
|
|
||||||
view_depth_threshold=5,
|
|
||||||
cart_ratio_threshold=0.8,
|
|
||||||
agent_multiplier=1.4,
|
|
||||||
)
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
import os
|
|
||||||
from dataclasses import dataclass
|
|
||||||
@dataclass(frozen=True)
|
|
||||||
class ServiceConfig:
|
|
||||||
web_url: str
|
|
||||||
backend_url: str
|
|
||||||
pricing_url: str
|
|
||||||
kafka_host: str
|
|
||||||
kafka_port: int
|
|
||||||
redis_port: int
|
|
||||||
@dataclass(frozen=True)
|
|
||||||
class TestConfig:
|
|
||||||
headless: bool
|
|
||||||
timeout: int
|
|
||||||
poll_interval: float
|
|
||||||
max_retries: int
|
|
||||||
kafka_consumer_timeout: int
|
|
||||||
|
|
||||||
|
|
||||||
def load_service_config() -> ServiceConfig:
|
|
||||||
return ServiceConfig(
|
|
||||||
web_url=os.getenv("WEB_URL", "http://localhost:3000"),
|
|
||||||
backend_url=os.getenv("BACKEND_URL", "http://localhost:5000"),
|
|
||||||
pricing_url=os.getenv("PRICING_PROVIDER_URL", "http://localhost:5001"),
|
|
||||||
kafka_host=os.getenv("KAFKA_HOST", "localhost"),
|
|
||||||
kafka_port=int(os.getenv("KAFKA_PORT", "9092")),
|
|
||||||
redis_port=int(os.getenv("REDIS_PORT", "6377")),
|
|
||||||
)
|
|
||||||
def load_test_config() -> TestConfig:
|
|
||||||
return TestConfig(
|
|
||||||
headless=os.getenv("HEADLESS", "true").lower() == "true",
|
|
||||||
timeout=int(os.getenv("TEST_TIMEOUT", "30000")),
|
|
||||||
poll_interval=float(os.getenv("POLL_INTERVAL", "0.5")),
|
|
||||||
max_retries=int(os.getenv("MAX_RETRIES", "10")),
|
|
||||||
kafka_consumer_timeout=int(os.getenv("KAFKA_TIMEOUT", "15")),
|
|
||||||
)
|
|
||||||
Reference in New Issue
Block a user