So I’m getting some interesting “warnings” … I don...
# ask-community
j
So I’m getting some interesting “warnings” … I don’t know why. I don’t have any flows with conflicting names. So I don’t know why this is popping up. At least I don’t think I do… maybe this is left over from flows that were in testing on my local box versus on the production Prefect server.
Copy code
$ python -m performance.flows.deployments.one_offs
/home/ec2-user/.local/share/virtualenvs/ppower-spzYstDT/lib/python3.10/site-packages/prefect/flows.py:205: UserWarning: A flow named 'alert-upcoming-hire-date-reviews' and defined at '/home/ec2-user/tenzinga/ppower/performance/flows/alert_hire_date_reviews.py:22' conflicts with another flow. Consider specifying a unique `name` parameter in the flow definition:

 `@flow(name='my_unique_name', ...)`
  warnings.warn(
/home/ec2-user/.local/share/virtualenvs/ppower-spzYstDT/lib/python3.10/site-packages/prefect/tasks.py:206: UserWarning: A task named 'get_potential_users_from_logs' and defined at '/home/ec2-user/tenzinga/ppower/performance/flows/alert_ky_early_intervention.py:29' conflicts with another task. Consider specifying a unique `name` parameter in the task definition:

 `@task(name='my_unique_name', ...)`
  warnings.warn(
/home/ec2-user/.local/share/virtualenvs/ppower-spzYstDT/lib/python3.10/site-packages/prefect/tasks.py:206: UserWarning: A task named 'get_tasks_for_org_ids' and defined at '/home/ec2-user/tenzinga/ppower/performance/flows/alert_ky_early_intervention.py:37' conflicts with another task. Consider specifying a unique `name` parameter in the task definition:

 `@task(name='my_unique_name', ...)`
  warnings.warn(
/home/ec2-user/.local/share/virtualenvs/ppower-spzYstDT/lib/python3.10/site-packages/prefect/tasks.py:206: UserWarning: A task named 'get_logs_from_tasks' and defined at '/home/ec2-user/tenzinga/ppower/performance/flows/alert_ky_early_intervention.py:42' conflicts with another task. Consider specifying a unique `name` parameter in the task definition:

 `@task(name='my_unique_name', ...)`
  warnings.warn(
/home/ec2-user/.local/share/virtualenvs/ppower-spzYstDT/lib/python3.10/site-packages/prefect/tasks.py:206: UserWarning: A task named 'get_view_logs_url' and defined at '/home/ec2-user/tenzinga/ppower/performance/flows/alert_ky_early_intervention.py:47' conflicts with another task. Consider specifying a unique `name` parameter in the task definition:

 `@task(name='my_unique_name', ...)`
  warnings.warn(
/home/ec2-user/.local/share/virtualenvs/ppower-spzYstDT/lib/python3.10/site-packages/prefect/tasks.py:206: UserWarning: A task named 'get_email_context' and defined at '/home/ec2-user/tenzinga/ppower/performance/flows/alert_ky_early_intervention.py:55' conflicts with another task. Consider specifying a unique `name` parameter in the task definition:

 `@task(name='my_unique_name', ...)`
  warnings.warn(
/home/ec2-user/.local/share/virtualenvs/ppower-spzYstDT/lib/python3.10/site-packages/prefect/tasks.py:206: UserWarning: A task named 'get_merge_data_for_leaders' and defined at '/home/ec2-user/tenzinga/ppower/performance/flows/alert_ky_early_intervention.py:66' conflicts with another task. Consider specifying a unique `name` parameter in the task definition:

 `@task(name='my_unique_name', ...)`
  warnings.warn(
/home/ec2-user/.local/share/virtualenvs/ppower-spzYstDT/lib/python3.10/site-packages/prefect/flows.py:205: UserWarning: A flow named 'alert-ky-early-intervention' and defined at '/home/ec2-user/tenzinga/ppower/performance/flows/alert_ky_early_intervention.py:75' conflicts with another flow. Consider specifying a unique `name` parameter in the flow definition:

 `@flow(name='my_unique_name', ...)`
  warnings.warn(
/home/ec2-user/.local/share/virtualenvs/ppower-spzYstDT/lib/python3.10/site-packages/prefect/flows.py:205: UserWarning: A flow named 'update-and-alert-about-users-who-need-logs' and defined at '/home/ec2-user/tenzinga/ppower/performance/flows/alert_logs_needed.py:14' conflicts with another flow. Consider specifying a unique `name` parameter in the flow definition:

 `@flow(name='my_unique_name', ...)`
  warnings.warn(
/home/ec2-user/.local/share/virtualenvs/ppower-spzYstDT/lib/python3.10/site-packages/prefect/flows.py:205: UserWarning: A flow named 'reset-annual-report-dates-for' and defined at '/home/ec2-user/tenzinga/ppower/performance/flows/one_offs.py:14' conflicts with another flow. Consider specifying a unique `name` parameter in the flow definition:

 `@flow(name='my_unique_name', ...)`
  warnings.warn(
/home/ec2-user/.local/share/virtualenvs/ppower-spzYstDT/lib/python3.10/site-packages/prefect/flows.py:205: UserWarning: A flow named 'remove-all-alerts-for' and defined at '/home/ec2-user/tenzinga/ppower/performance/flows/one_offs.py:36' conflicts with another flow. Consider specifying a unique `name` parameter in the flow definition:

 `@flow(name='my_unique_name', ...)`
  warnings.warn(
a
Can you share your prefect version and perhaps also a minimal flow example to reproduce?
j
@Anna Geller only the last two flows mentioned in those warnings did I just add… now it is claiming that all of them are not unique? Really odd. I’ve not named a single flow the same as another flow.
Not sure how to reproduce when it would appear to me that it showed up out of nowhere for no reqson.
reason*
k
So after adding two new flows, you got the not unique error?
j
Correct.
Here’s the deployment I used…
Copy code
# -*- coding: utf-8
from __future__ import unicode_literals
from prefect.deployments import Deployment

from tenzinga_django_setup import prepare_django_and_paths
prepare_django_and_paths()


from ppower.performance.flows import (
    remove_all_alerts_for,
    reset_annual_report_dates_for
)

flow_defs = [{
    "flow": reset_annual_report_dates_for,
    "name": "reset_annual_report_dates",
    "description": "Reset annual report dates for an organization.",
    "tags": ["annual_report", "reset_date"],
}, {
    "flow": remove_all_alerts_for,
    "name": "remove_all_alerts",
    "description": "Remove all alerts for all users in an organization.",
    "tags": ["alerts", "reset_alerts"],
}]

for flow_def in flow_defs:
    deployment = Deployment.build_from_flow(
        flow=flow_def["flow"],
        name=flow_def["name"],
        description=flow_def["description"],
        tags=flow_def["tags"],
        work_queue_name="tenzinga_django_prod",
    )
    deployment.apply()
Here are the flows…
Copy code
# -*- coding: utf-8
from __future__ import unicode_literals
import datetime
from prefect import flow, task, get_run_logger

from tenzinga_django_setup import prepare_django_and_paths
prepare_django_and_paths()

from ppower.base.models import Organization
from ppower.notification.models import Notice


@flow
def reset_annual_report_dates_for(org_id, *, year: int, month: int = None, day: int = None):
    today = datetime.date.today()
    if year is None:
        year = today.year

    org = Organization.objects.get(pk=org_id)

    users = org.hreuser_set.all()
    for user in users:
        initial_date = user.next_annual_report
        if month is None:
            month = initial_date.month
        if day is None:
            day = initial_date.day
        user.next_annual_report = datetime.date(year=year, month=month, day=day)
        user.save()

    logger = get_run_logger()
    <http://logger.info|logger.info>(f"Reset annual report dates for {len(users)} users.")


@flow
def remove_all_alerts_for(org_id: int):
    org = Organization.objects.get(pk=org_id)
    users = org.hreuser_set.all()

    for user in users:
        # Set the last_log_alert to today so they don't receive any alerts
        user.last_log_alert_time = datetime.date.today()
        user.save()

    notices = Notice.objects.filter(user__in=users)
    notices.delete()

    logger = get_run_logger()
    <http://logger.info|logger.info>(f"Removed {len(notices)} alerts for {len(users)} users.")
k
Thanks for the code. Yeah, I don’t see any duplication in the name of the flows here. Do you get the not unique warning when running the flow in the console (not from a deployment)? Also, which version of Prefect are you in?
j
That’s a good question…
On the agent server (where code is run) 2.7.0
Let me check locally…
Well actually the above is all that matters… I run deployments from the agent server because it has the environment variables necessary to get proper pathing to my flows.
I only received the error when deploying.
warning*
I have run one of those flows that I deployed and I don’t believe I had any warning output.
k
Hmm. This sounds like an issue to me. Do you mind opening an issue on Prefect?
j
Can do! I’ll link here when done.
gratitude thank you 1
Okay, so I never created an issue because by the time I got around to it, I couldn’t recall the details. However, here I am again simply trying to “deploy” from my local box so I can then setup a local agent to test my new flow. I’m getting an error on deployment and it is prefaced by duplicate name stuff… Here’s the link to the new thread… https://prefect-community.slack.com/archives/CL09KU1K7/p1679940793826709