Hello,
I am a newby to both Prefect and Docker, please let me know if I got something terribly wrong.
I made a small script in Python to collect data from a website, and I arranged the operation flow and tasks with Prefect. It was running for a while on a single board computer, and everything was fine. All the flow runs were going to Prefect Cloud, and I could check if there was some issue. Scheduling was simply made via crontab.
I had to containerize the script to run into another system, and I also tried to automate the login into Prefect Cloud…but this seems not be working at all. Prefect still handles all failures and retries into the flow, but it never communicates with Prefect Cloud to “report” the flow runs and task status.
The way I tried to automate the login is including a call to subprocess into my Python script, just before running the flow.
The basic architecture of the code is this:
Flow definition (task are defined previously)
@flow(
name="My flow",
description="main flow for gathering data",
retries=4,
retry_delay_seconds=120,
task_runner=SequentialTaskRunner(),
)
def main_flow():
# Start logger
logger = get_run_logger()
logger.info(
"Data collection started at {}".format(
datetime.now().strftime(format="%Y-%m-%d %H:%M")
)
)
# Do more stuff
...
Registration on Prefect Cloud and run (PREFECT_TK and PREFECT_WS are two environment variables for my key and worskpace on Prefect Cloud)
if __name__ == "__main__":
# Register with Prefect
subprocess.run(
[
"prefect",
"cloud",
"login",
"-k",
os.getenv("PREFECT_TK"),
"-w",
os.getenv("PREFECT_WS"),
],
capture_output=True,
)
main_flow()
I get his error at the beginning of the execution when I run my container, but I fail to understand what it means or how to fix it:
/usr/local/lib/python3.11/contextlib.py:144: SAWarning: Skipped unsupported reflection of expression-based index ix_flow_run__coalesce_start_time_expected_start_time_desc
next(self.gen)
At this stage I cannot install any Prefect agent on the new host, it can only live inside the Docker container and talk to Prefect Cloud. Any suggestion would be welcome!