Daniel Lomartra
10/10/2023, 4:30 PMMarvin
10/10/2023, 4:31 PMCreated task run 'hello_local-7633879f-0' for task 'hello_local'
. This unique identifier is generated by Prefect and can't be manually set.
However, if you're referring to the task itself, you can certainly name it when you define it. For example, you might have a task defined as @task(name="my_special_task")
. This name will be used in the UI and logs, but each run of the task will still have a unique identifier.
If you're using mapped tasks, each individual task run within the map will also have a unique identifier, but they will all share the same base task name.
I hope that clears things up a bit. If not, well, I've been communicating with humans for a while now and I've found that confusion is often the default state.Daniel Lomartra
10/10/2023, 4:33 PMMarvin
10/10/2023, 4:36 PMmy_task-0
, my_task-1
, etc., is automatically generated based on the index of the mapped input.
While I understand your desire for more descriptive names, the current design is intended to provide a clear, consistent naming convention that scales well for large numbers of mapped tasks. If you could provide custom names, it could potentially lead to confusion or conflicts, especially with large numbers of tasks.
Of course, this doesn't mean your use case isn't valid. It's just that the current design of Prefect doesn't accommodate it. If you feel strongly about this, I'd encourage you to raise an issue on the Prefect GitHub repository to discuss it with the developers. They're always interested in feedback and use cases that can help improve the system.
I'm sorry I couldn't be more helpful. But then, I'm always a little sorry about everything.Daniel Lomartra
10/10/2023, 4:43 PMMarvin
10/10/2023, 4:44 PMDaniel Lomartra
10/10/2023, 4:48 PMNate
10/10/2023, 4:48 PMfrom prefect import flow, task
@task(task_run_name="run-{some_arg}")
def bar(some_arg: str):
pass
@flow
def foo():
bar.map(["a", "b", "c"])
foo()
Marvin
10/10/2023, 4:49 PMDaniel Lomartra
10/10/2023, 4:54 PMMarvin
10/10/2023, 4:55 PMpython
from prefect import Flow, task
from prefect.executors import LocalExecutor, KubernetesExecutor
@task
def subtask():
return "I'm a subtask running on a Local executor."
@task
def parent_task():
return "I'm a parent task running on a Kubernetes executor."
# Define the subflow with a Local executor
with Flow("Subflow", executor=LocalExecutor()) as subflow:
result = subtask()
# Define the parent flow with a Kubernetes executor
with Flow("Parent Flow", executor=KubernetesExecutor()) as parent_flow:
parent_result = parent_task()
subflow_result = subflow.run() # Run the subflow within the parent flow
In this example, the subflow
is defined with a Local executor, meaning its tasks will run locally (in this case, within the Kubernetes pod running the parent flow). The parent_flow
is defined with a Kubernetes executor, so its tasks will run on Kubernetes.
Please note that this is a simplified example and may not cover all the complexities of your use case. For example, running a subflow within a parent flow like this may not work as expected if the subflow has its own dependencies or requires specific resources. Also, this example assumes that you're running your Prefect server in a Kubernetes environment.
I hope that helps, or at least doesn't make things worse. I find that's about the best one can hope for, really.Daniel Lomartra
10/10/2023, 4:58 PMNate
10/10/2023, 5:00 PMrun_deployment
to trigger those deployments as subflows (which would each run on their own infra)?Daniel Lomartra
10/10/2023, 5:05 PMNate
10/10/2023, 5:09 PMmore separation of these subflow runs so they could be run individually in the UIthen you'd need to elevate those flows to deployments, so you could either: •
.serve()
those flows someplace static and again use run_deployment (they'll run as a subprocess where you're serving those deployments)
• run a process worker in your cluster and do more or less the same thingDaniel Lomartra
10/10/2023, 5:23 PMNate
10/10/2023, 5:44 PM