Is there a way to change the display name of task ...
# ask-the-community
Is there a way to change the display name of task nodes in a workflow in the console UI? E.g. I have a dynamic workflow that run different tasks with different number of epochs and I want the flyte UI to indicate what epoch each node corresponds to, say
Yes, this is how:
Copy code
train_score_evaluate(...).with_overrides(name="Your Display Name Here")
That didn’t work 😞 Here’s my sample code that I am experimenting with - overriding the name didn’t work for either a dynamic or a task
Copy code
from __future__ import annotations

import random
from typing import List, Tuple

from flytekit import dynamic, task, workflow

class Model:
    def __init__(self, name: str, epochs: int = 1): = name
        self.epochs = epochs

    def serialize(self) -> str:
        return f"{}:{self.epochs}"

    def deserialize(cls, serialized_model: str) -> "Model":
        name, epochs = serialized_model.split(":")
        return cls(name, int(epochs))

    def train(self, dataset: List[int]) -> None:
        print(f"Training {} model for {self.epochs} epochs with dataset {dataset}")

    def score(self, dataset: List[int]) -> float:
        return 0.5 + (
            random.randrange(-25, 25) / 100
        )  # For example, we're assuming the model always scores 0.9

    def evaluate(self, dataset: List[int]) -> int:
        return int(self.score(dataset) * 100)

def preprocess(dataset: List[int] = [1, 2]) -> List[int]:
    return [x * 2 for x in dataset]

def train(model_name: str = "model", dataset: List[int] = [1, 2], epochs: int = 5) -> str:
    model = Model(model_name, epochs)
    return model.serialize()

def score(serialized_model: str = "model:5", dataset: List[int] = [1, 2]) -> float:
    model = Model.deserialize(serialized_model)
    return model.score(dataset)

def evaluate(serialized_model: str = "model:5", dataset: List[int] = [1, 2]) -> int:
    model = Model.deserialize(serialized_model)
    return model.evaluate(dataset)

def compare_scores(score1: float, model_1: str, score2: float, model_2: str) -> str:
    if score1 > score2:
        return model_1
        return model_2

def train_score_evaluate(dataset: List[int] = [1, 2], epochs: int = 1) -> Tuple[float, int]:
    serialized_model = train(model_name="simple_model", dataset=dataset, epochs=epochs).with_overrides(name=f"train_epoch={epochs}")
    model_score = score(serialized_model=serialized_model, dataset=dataset)
    accuracy = evaluate(serialized_model=serialized_model, dataset=dataset)
    return model_score, accuracy

def best_model(dataset: List[int]) -> str:
    preprocessed_dataset = preprocess(dataset=dataset)
    best_model_config = ""

    for i in range(1, 5):
        model_score, accuracy = train_score_evaluate(dataset=preprocessed_dataset, epochs=i).with_overrides(name=f"train_score_evaluate_epoch={i}")

        best_model_config = compare_scores(

    return best_model_config

def get_best_model(dataset: List[int] = [1, 2]) -> str:
    return best_model(dataset=dataset)
@Archit Rathore I'm not able to repro this:
Copy code
from flytekit import dynamic, task, workflow

def say_hello() -> str:
    return "hello world"

def my_nested_dyn() -> str:
    return say_hello().with_overrides(name="foo", node_name="bar")

def my_dyn() -> str:
    return my_nested_dyn().with_overrides(name="foz", node_name="bat")

def my_dyn_wf() -> str:
    return my_dyn()
correctly displays:
Can you try with my example wf and see if you get similar results?
Do you know what version of Flyte components you're running? flytekit / flyteconsole especially.
@Brian Tang do you know the package versions?
yeah: flyte-console:
rest of the components are running flyte v1.6.1 milestone release
@Dan Rammer (hamersaw) with your example wf here’s what I get
The node are being suffixed correctly but the display name is not 🤔
so there is a difference between latest version (me) and the versions your running I think. cc @Jason Porter is this something that was updated in the UI?