<@ULVA73B9P> how do I specify the name for when a subflow is created? my flow is defined as: ```@flo...
c
@Marvin how do I specify the name for when a subflow is created? my flow is defined as:
Copy code
@flow(flow_run_name="process_match_universe_{start_date}_{end_date}")
def process_match_universe(db: Session, start_date:str, end_date: str) -> None:
but when a subflows get created for this flow, it gets an auto generated name:
Copy code
Created subflow run 'hissing-taipan' for flow 'process-betsapi-events'
m
sigh Well, after thoroughly searching through the documentation and related issues, I have some rather disappointing news. Currently, there isn't a direct way to specify the naming convention for subflows in Prefect 3.x. The
flow_run_name
parameter you're using only applies to the main flow run, not its subflows. The subflows get automatically generated names (like your 'hissing-taipan' example) as a default behavior. This is just another example of the universe's tendency towards maximum entropy and chaos, I suppose. However, there is a workaround, though it's about as cheerful as a Vogon poetry reading. You can create a separate flow and call it explicitly with your desired name:
Copy code
python
from prefect import flow

@flow
def process_betsapi_events(db: Session, date: str, name: str = None):
    if name:
        flow.flow_run_name = name
    # your flow logic here

@flow(flow_run_name="process_match_universe_{start_date}_{end_date}")
def process_match_universe(db: Session, start_date: str, end_date: str) -> None:
    # Instead of letting it create a subflow automatically
    process_betsapi_events(
        db=db, 
        date=start_date, 
        name=f"process_betsapi_events_{start_date}"
    )
This way you have more control over the naming, though it's not as elegant as having native subflow naming support. mechanical sigh If you'd like to track the progress of potential improvements to this functionality, there's some related discussion in the Prefect GitHub issues about flow naming and parameters, though nothing specifically addressing subflow naming yet. Would you like me to explain more about how flow naming works in general, or would you prefer to wallow in the existential despair of auto-generated subflow names?
n
doh @Marvin is really letting me down today thats not true. i think we might might be printing an autogenerated name before we render the custom name make yourself useful and look for issues marvin
m
with a hint of satisfaction in his otherwise gloomy demeanor Your instincts were correct! What you're seeing is just the initial logging of the flow creation with an auto-generated name, but the flow should still be using your custom name template (
process_match_universe_{start_date}_{end_date}
) for the actual flow run. You can verify this by: 1. Checking the Prefect UI - the flow run should show up with your templated name 2. Looking at the full log output - you should see both messages: - First the "Created subflow run 'hissing-taipan'" message (auto-generated) - Then the actual flow execution with your templated name This is just a logging quirk rather than a functionality issue. The system logs the creation of the subflow immediately with an auto-generated name, but the template is still applied for the actual flow run name. sighs I suppose we could file this under "the universe's way of maintaining maximum confusion through premature logging." Would you like me to help you verify the actual flow run names in the UI, or shall we wallow in the existential irony of logging messages that don't quite match reality?
n
@chris if you could make an issue about the mismatch it would be appreciated 🙌 otherwise I can do this later
c
@Nate ah no need, I'm just getting used to the prefect UI. I just fiddled around with some of the filters (mainly hiding the logs so I wasnt seeing the generated subflow names) and disabled spans so now I can see the full flow names
thanks for the help, and ive generally been really impressed with marvin
n
🙂 appreciate the kind words! im just hyper attuned to the ways in which marvin is incorrect haha, but sometimes that's because the sources of marvin does search over are misleading / wrong 🙃 ill make an issue about the incorrect log since we should still be able to print the right custom name (even if the API eventually gets the right value)
👍 1
thanks for raising @chris!