New RunLLM response generated: >>>*# Question* he...
# runllm-flyte-trial
a
New RunLLM response generated: >>>*# Question* hey guys, I want to get the start date / time of a workflow, I’ll probably have 3 tasks running, for example:
task1 >> task2 >> task3 >> print("success")
in task3, I want to get the start date / time when this dag started running, would doing
FlyteContextManager.current_context().execution_state.user_space_params.execution_date
be the correct way of getting it? I do not want the start time of the task3, but instead, i want the start of time of task1 / or when the workflow started. Many thanks~ # Answer To get the start date/time of the workflow in
task3
, you should use the
execution_date
attribute from the
ExecutionParameters
object. This attribute represents the time at which the workflow was started and is consistent across all tasks in the workflow. Here is how you can access it in `task3`:
Copy code
from flytekit import task, workflow, current_context

@task
def task1():
    pass

@task
def task2():
    pass

@task
def task3():
    execution_date = current_context().execution_state.user_space_params.execution_date
    print(f"Workflow started at: {execution_date}")

@workflow
def my_workflow():
    t1 = task1()
    t2 = task2()
    t3 = task3()

my_workflow()
According to the Flyte documentation, the
execution_date
attribute in
ExecutionParameters
provides the start time of the workflow. Would you like more detail on this? Sources: - Flyte documentation Slack Link https://flyte-org.slack.com/archives/CP2HDHKE1/p1722644242.387119 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.