lazy load cron_web_scraper_task and web_scraper_task

This commit is contained in:
Daulet Amirkhanov 2025-10-21 23:11:01 +01:00
parent f02aa1abfc
commit 3f5c09eb45

View file

@ -6,9 +6,24 @@ BeautifulSoup or Tavily, defining data models, and handling scraping configurati
"""
from .utils import fetch_page_content
from .web_scraper_task import cron_web_scraper_task, web_scraper_task
from .default_url_crawler import DefaultUrlCrawler
# Lazy import for web_scraper_task to avoid requiring apscheduler
# Import these directly if needed: from cognee.tasks.web_scraper.web_scraper_task import ...
def __getattr__(name):
"""Lazy load web scraper task functions that require apscheduler."""
if name == "cron_web_scraper_task":
from .web_scraper_task import cron_web_scraper_task
return cron_web_scraper_task
elif name == "web_scraper_task":
from .web_scraper_task import web_scraper_task
return web_scraper_task
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
__all__ = [
"BeautifulSoupCrawler",