ALwrity + Wordpress + Wix + GSC integration

This commit is contained in:
ajaysi
2025-10-08 15:06:35 +05:30
parent 5e3901c1c6
commit 719ca06da0
4 changed files with 67 additions and 39 deletions

View File

@@ -91,7 +91,7 @@ class DependencyManager:
return len(missing_packages) == 0, missing_packages
def setup_spacy_model(self) -> bool:
"""Set up spaCy English model (production-optimized)."""
"""Set up spaCy English model."""
print("🧠 Setting up spaCy model...")
try:
@@ -107,30 +107,42 @@ class DependencyManager:
print(f"✅ spaCy model '{model_name}' is available")
return True
except OSError:
print(f"⚠️ spaCy model '{model_name}' not found")
print(" Skipping spaCy setup in production mode")
return True # Don't fail for missing spaCy in production
# Model not found - try to download it
print(f"⚠️ spaCy model '{model_name}' not found, downloading...")
try:
subprocess.check_call([
sys.executable, "-m", "spacy", "download", model_name
])
print(f"✅ spaCy model '{model_name}' downloaded successfully")
return True
except subprocess.CalledProcessError as e:
print(f"❌ Failed to download spaCy model: {e}")
print(" Please download manually with: python -m spacy download en_core_web_sm")
return False
except ImportError:
print("⚠️ spaCy not installed - skipping model setup")
return True # Don't fail for missing spaCy
return True # Don't fail for missing spaCy package
return True
def setup_nltk_data(self) -> bool:
"""Set up NLTK data (production-optimized)."""
"""Set up NLTK data."""
print("📚 Setting up NLTK data...")
try:
import nltk
# Only download essential data
essential_data = ['punkt', 'stopwords']
# Essential NLTK data packages
essential_data = [
('punkt_tab', 'tokenizers/punkt_tab'), # Updated tokenizer
('stopwords', 'corpora/stopwords'),
('averaged_perceptron_tagger', 'taggers/averaged_perceptron_tagger')
]
for data_package in essential_data:
for data_package, path in essential_data:
try:
nltk.data.find(f'tokenizers/{data_package}' if data_package == 'punkt'
else f'corpora/{data_package}')
nltk.data.find(path)
print(f"{data_package}")
except LookupError:
print(f" ⚠️ {data_package} - downloading...")
@@ -139,12 +151,19 @@ class DependencyManager:
print(f"{data_package} downloaded")
except Exception as e:
print(f" ⚠️ {data_package} download failed: {e}")
# Try fallback for punkt_tab -> punkt
if data_package == 'punkt_tab':
try:
nltk.download('punkt', quiet=True)
print(f" ✅ punkt (fallback) downloaded")
except:
pass
print("✅ NLTK data setup complete")
return True
except ImportError:
print("⚠️ NLTK not installed - skipping data setup")
return True # Don't fail for missing NLTK
return True # Don't fail for missing NLTK package
return True

View File

@@ -13,9 +13,9 @@ class ProductionOptimizer:
def __init__(self):
self.production_optimizations = {
'disable_spacy_download': True,
'disable_nltk_download': True,
'skip_linguistic_setup': True,
'disable_spacy_download': False, # Allow spaCy verification (required for persona generation)
'disable_nltk_download': False, # Allow NLTK verification (required for persona generation)
'skip_linguistic_setup': False, # Always verify linguistic models are available
'minimal_database_setup': True,
'skip_file_creation': True
}
@@ -39,7 +39,8 @@ class ProductionOptimizer:
def _set_production_env_vars(self) -> None:
"""Set production-specific environment variables."""
production_vars = {
'HOST': '0.0.0.0',
# Note: HOST is not set here - it's auto-detected by start_backend()
# Based on deployment environment (cloud vs local)
'PORT': '8000',
'RELOAD': 'false',
'LOG_LEVEL': 'INFO',
@@ -53,19 +54,14 @@ class ProductionOptimizer:
print(f"{key}={value}")
def _disable_heavy_operations(self) -> None:
"""Disable operations that are too heavy for production startup."""
print("Disabling heavy operations for production...")
"""Configure operations for production startup."""
print("Configuring operations for production...")
# Disable spaCy model download
os.environ.setdefault('DISABLE_SPACY_DOWNLOAD', 'true')
# Note: spaCy and NLTK verification are allowed in production
# Models should be pre-installed during build phase (via render.yaml or similar)
# The setup will verify models exist without re-downloading
# Disable NLTK data download
os.environ.setdefault('DISABLE_NLTK_DOWNLOAD', 'true')
# Skip linguistic analyzer setup
os.environ.setdefault('SKIP_LINGUISTIC_SETUP', 'true')
print(" ✅ Heavy operations disabled")
print(" ✅ Production operations configured")
def _optimize_logging(self) -> None:
"""Optimize logging for production."""