from datetime import datetime, timedelta

import pendulum
import prefect
from prefect import Flow, task
from prefect.run_configs import DockerRun
from prefect.schedules import CronSchedule
from prefect.storage import GitHub
from scrapy.crawler import CrawlerProcess
from sqlmodel import SQLModel, create_engine

from imdb_rating.dependencies.spiders import IMDBSpider


@task
def scrap_movies_from_imdb():
    """
    Scrap movies from IMDB and store them into a PostgreSQL database using SQLModel.
    Run a scrapy crawler process to launch a spider.
    """
    logger = prefect.context.get("logger")

    # engine = create_engine('postgresql://postgres:postgres@localhost:5432/imdb')
    engine = create_engine("sqlite:///imdb.db")
    