https://prefect.io logo
Title
e

Ela

09/02/2022, 9:38 PM
hi (: I noticed that my flow runs twice when I import tasks or functions from files placed in the same parent directory as the file which keeps the Flow object. I also get a UserWarning that my flow conflicts with 'another flow' and that the tasks of the flow conflict with 'some other tasks', although each task and flow have a unique name (warning example: "_A task named ... and defined at ... conflicts with another task. Consider specifying a unique
name
parameter in the task definition_"). I tried to see what's happening in the prefect.tasks.py file (which sends the warning) and I made it print out all the names in the PrefectObjectRegistry.get(). I noticed how it printed out the names of the tasks I'm using multiple times All of this disappeared when I imported tasks/functions from a different directory than where the flow is; the flow runs only once and the warnings are gone - I'm using Prefect 2.3.1 (also when I used version 1 these double runs happened until I changed the location of the func/tasks I was importing) I hope this makes sense, if you have any advice on why this happens, please let me know! thanks^^
1
a

Anna Geller

09/10/2022, 12:33 AM
Hi @Ela, sorry for getting back to you late, did you solve it by now? it could be some logging issue in the sense that only logs appear twice for some reason if the issue persists, could you open an issue explaining your setup, your prefect version and give a minimal reproducible example we could use to troubleshoot? thanks
e

Ela

09/16/2022, 9:47 PM
hey @Anna Geller, thanks for replying back 🙂 I tried to recreate the issue and it happens when I package my project using setuptools. I created a CLI app via typer and setuptools and installed it in my project. (I attached a simple project structure example) I'd like to import a function from the inventory file into the utility file. Since I installed my examplecli package in the project, I can import the func in 2 ways (I'm using Python 3.10): (1) from inventory import main_func or (2) from examplecli.inventory import main_func then I import some stuff from the utility file to the examplecli.init.py file. (for reference: utility.py contains a typer.Typer() object (app) which is imported into the examplecli.init.py file so that it can be used as a subcommand) Once the steps above are done (and I imported the main_func in the utility file like in (2)), if I run the flow in the utility.py file, it runs twice and I get the UserWarning. this disappears, if I either use method (1) or don't import anything from utility.py into examplecli.init.py. I guess it's related to some circular-like importing issue? Anyway, I'm just going to use (1), so it won't be a problem in this case
👍 1
a

Anna Geller

09/16/2022, 10:38 PM
that makes sense! thanks for getting back and sharing your approach