https://prefect.io logo
#prefect-community
Title
# prefect-community
c

Chu

08/02/2022, 6:36 PM
Which syntax I can use to get current flow run's parameters value
1
a

Anna Geller

08/02/2022, 6:44 PM
in 2.0, those are just your function's arguments in 1.0:
Copy code
prefect.context.parameters.get("parameter_name")
c

Chu

08/02/2022, 6:48 PM
It said:
Copy code
params_during_flow_run = prefect.context.parameters.get("param_settings_by_org_id")
AttributeError: 'Context' object has no attribute 'parameters'
let me elborate more, how can I do that:
Copy code
param_by_orgs = Parameter(
        "some_params", 
        default = [
                    {
                        'organization_id': 'a', 
                        'period_value': 1
                        }, 
                    {
                        'organization_id': 'b', 
                        'period_value': 1
                        }, 
                    {
                        'organization_id': 'c', 
                        'period_value': 1
                        } 
                ]
        )

## here I want to get the list of dictionary "some_params" in the run time, especially in the future, I may need to send parameters in Prefect UI, where it overwrites the default, thus I can't simply use param_by_orgs.default to retrieve the run time params
a

Anna Geller

08/02/2022, 8:49 PM
again I encourage you to check this post, it explains parametrized workflows in depth for 1.0 https://www.prefect.io/guide/blog/how-to-make-your-data-pipelines-more-dynamic-using-parameters-in-prefect/
c

Chu

08/02/2022, 8:59 PM
I have read this many times, I dont think you fully understand my question, the syntax you suggest throw an error, how does it be solved by reading the article. how could I get the flow run parameters? since I may overwrite default in Prefect UI
a

Anna Geller

08/02/2022, 10:22 PM
the Prefect context allows you to access parameter values by name in things like state handlers - you should use some_params in your example:
prefect.context.parameters.get("some_params")
not sure if anyone can help you solve a problem unless you describe it
you asked a question:
Copy code
Which syntax I can use to get current flow run's parameters value
and I answered it + pointed you to more resources
13 Views