where can I find some examples of how to pass requ...
# prefect-community
where can I find some examples of how to pass required flow parameters for prefect v1? when i go to register a flow with required parameters, I get
AttributeError: 'Parameter' object ...
. Why is the flow trying to run when I register it? the more unclear thing is that when i declare a parameter, it returns a parameter object when i really just want the value that's passed to the flow
Here's an example of passing parameters for v1: https://docs-v1.prefect.io/core/concepts/parameters.html
when i run:
Copy code
prefect register --project platform_medallion-etl--dev -p flows/cbe/electricity_ami/extract.py
i get this exception
Copy code
Collecting flows...
[2022-10-10 11:30:40-0400] INFO - prefect | Getting credentials for provider_code: cbe client_code: <Parameter: clientCode>
Error loading 'flows/cbe/electricity_ami/extract.py':
  Traceback (most recent call last):
    File "/Users/jonyoung/Dev/workflows/.venv/lib/python3.9/site-packages/prefect/cli/build_register.py", line 133, in load_flows_from_script
    namespace = runpy.run_path(abs_path, run_name="<flow>")
    File "/Users/jonyoung/.pyenv/versions/3.9.13/lib/python3.9/runpy.py", line 288, in run_path
    return _run_module_code(code, init_globals, run_name,
    File "/Users/jonyoung/.pyenv/versions/3.9.13/lib/python3.9/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
    File "/Users/jonyoung/.pyenv/versions/3.9.13/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
    File "/Users/jonyoung/Dev/workflows/workflows/flows/cbe/electricity_ami/extract.py", line 34, in <module>
    auth_payload = provider.get_login_credentials(
    File "/Users/jonyoung/Dev/workflows/workflows/models/DataProvider.py", line 58, in get_login_credentials
    credentials_info = RuntimeParameters().get_ingest_secret(
    File "/Users/jonyoung/Dev/workflows/workflows/models/RuntimeParameters.py", line 100, in get_ingest_secret
    customer = customer_code.lower()
  AttributeError: 'Parameter' object has no attribute 'lower'
and the code looks something like this
Copy code
import prefect

from common import workflow_utils, logging
from models import TempFileModel
from flows import constants
from tasks import register_workflow
from tasks.cbe import extract

logger = logging.get_logger()

# --------------------------------------------------
# Main Flow Configuration
# --------------------------------------------------

with prefect.Flow(
) as flow:
    client_code = prefect.Parameter("clientCode", required=True)

    with extract.ExtractCBE() as provider:
        auth_payload = provider.get_login_credentials(


# --------------------------------------------------
# Main
# --------------------------------------------------
if __name__ == "__main__":
👀 1
@Kalise Richmond perhaps you can spot what i'm doing wrong here?
also, this flow is meant to be called with parameters we're passing in from an external service, how do i register it without having to pass in a valid
Hey Jon, just quickly taking a look, you'll have to pass it default parameters but when you call it from an external service you'll be able to specify the parameters you are passing with the API. The registration failing looks like something is failing in the customer_code with the "test" as the value.
thank you for hopping right in here
i figured it out
👍 1
i hadn't declared my class methods as tasks, so they didn't understand how to parse the Parameter object
i couldn't figure out how to declare class methods as tasks, but i did test wrapping the logic i had in the flow as a function + task decorator and it worked
is it possible for class methods to be tasks?
Hi Jon, yup, this is possible. You can find more information and examples here.