Repository navigation
Replies: 1 comment 3 replies
|
I think this is simply not possible now in Dynamic Task Mapping case (though I agree it would be great to have it).. I think excluding the mapped parameters from being templated was a deliberate decision which was connected with optimisations, but there should be no fundamental reasons to implement it similarly to implementing default_args #29366 - it's just "this does not work yet" case. CC: @uranusjr - I based it on your comments in #29366 and the docs, so you might correct me if I am wrong. Allowing templated fields to be mapped and remain mapped simply adds quite some complexity and likely hampers performance of dynamic task mapping. I think a good workaround will be to pre-generate the names of PVC volumes in the task that calls |
Uh oh!
There was an error while loading. Please reload this page.
Dear community,
As part of a pipelining workflow to run containers on k8s, one of the things I am trying to achieve is to dynamically name a PVC (with dynamically provisioned PV ) by generating a hashed string in task
generate_pvc_name()which I am then using in a downstream task where I am using the k8s python API to create the PVC.The idea behind this is to avoid PVC name collisions when running multiple DAGs in parallel. I am passing data between tasks using XComs. The aforementioned works well, until I introduce dynamic task mapping:
In a downstream task I am introducing a KubernetesPodOperator with dynamic task mapping . There I could traditionally pass a templated argument to
volumesto initialize the operator, i.e.but it seems that templates are not supported well within dynamic task mapping which means the template is not evaluated, as mentioned here so I was wondering if you would be aware of any workarounds to this. This link offers some pointers,but it is not quite exactly what I would like to achieve.
Another idea I had is to generate a pod template file containing the PVC and volumeMount specs, and reuse it throughout all
KubernetesPodOperator's that need it. However, if I instantiate this as a global variable in my DAG, I have no control over when and where the expression gets evaluated, and because it will contain a random string, I will end up with a different version of the pod template file at every task.I would greatly appreciate any pointers/ideas/guidance on how to achieve this. I am looking forward to your reply.
All reactions