Hi folks. I'm running into a problem with <StepMut...
# ask-metaflow
f
Hi folks. I'm running into a problem with StepMutator. I'm trying to modify the docker image used by the @kubernetes based on values in my flow config. I'm mirroring the code from the link. It looks rouhgly like this
Copy code
class UseImageFromFlowConfig(StepMutator):
    def mutate(self, mutable_step):
        mutable_step.add_decorator(
            kubernetes,
            deco_kwargs={
                "image": str(mutable_step.flow.flow_config.image)
            }
        )
When I try to apply this to a step and try to run the flow, I get
Copy code
File "<path>/.venv/lib/python3.11/site-packages/metaflow/plugins/kubernetes/kubernetes_decorator.py", line 382, in step_init
    if self.attributes["gpu_vendor"].lower() not in ("amd", "nvidia"):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'lower'
i.e. here . This tells me that the init method of the decorator is not executed, because otherwise it should have picked up a default value. I could of course add "gpu_vendor" to deco_kwargs to make it work, but surely that's not the desired solution, since I will probably end up adding a bunch of arguments to make this work. Can you tell me, how I can approach this?
d
Hey. There is actually a bug right now. Someone brought it up internally a few days back and I haven't fixed it yet. It has to do with ordering. Init is called between pre_mutate and mutate for this and so it is not called again. The current workaround would be to use pre_mutate. The downside is that you don't have access to anything that is passed through the command line with —with. I need to look at why we have this order and if it is just an easy fix or if there is something more.
f
Thank you @dry-beach-38304. This seems to have solved my issue.