I'm having some issues with the context variables....
# ask-community
d
I'm having some issues with the context variables. I seem to be getting incorrect results, or there's something obvious that I'm missing. For example,
Copy code
with Flow('Test 1') as flow:

    print(f"""
        flow name: {context.flow_name}
        flow id: {context.flow_id}
        flow run name: {context.flow_run_name}
        flow_run_id: {context.flow_run_id}
        """)
results in :
Copy code
flow name: Test 1
    flow id: Test 1
    flow run name: bc5e286e-6268-43a8-aaaf-a5d03275917d
    flow_run_id: c867f4ea-1599-4201-a8e0-886cadbe0e1e
It looks like the context variables are not entirely correct? Flow Name and Flow ID are both pulling the same field and I would expect Flow Run Name to pull something like 'violet-marmoset'. Is there an actual issue here or am I using these incorrectly?
k
Hey @DK , are you during
flow.run()
or running with Cloud or Server? I think for flow.run, these are not set because it’s just a test so these are filled, but it should work when running with Cloud/Server
The print under the Flow is not deferred. These will resolve when the flow is actually run but this print statement is happening during the build time.
d
ya I'm using flow.run(), I'll test it again with cloud, thanks!
k
It might be the same in cloud because the print might be happening during build time. It will work if you put it in a task.
d
I never actually used the example that I had above, in my actual code it was in a task. But good to know going forward, thanks
👍 1