Hey guys, I'm running into an issue with registeri...
# ask-community
c
Hey guys, I'm running into an issue with registering a flow that uses CronClock with parameter default inputs. On v. 0.15.5
ValueError: Flow could not be deserialized successfully. Error was: ValidationError({'schedule': {'clocks': {0: {'parameter_defaults': defaultdict(<class 'dict'>, {'accnt': {'value': ['Field may not be null.']}, ....
Copy code
std_inputs = { 'report':False,
               'accnt':               None,  # string - delimited list
               'strategy':            None,  # string - delimited list
               'institutionalAdvisor':None,  # string - delimited list
               'endDate':             None,  # string - 'YYYY-MM-DD'
               'shadow':              None,  # SPY, treasury
               'benchmark':           None,  # SPY, PUT, BXM
               'fees':                False,  # Bool
               'output':              'daily'  # monthly, daily
               }

with Flow('Update Performance tables',
        schedule = Schedule(
                clocks = [
                      CronClock("7 6 * * 1-5",
                                start_date=pendulum.now("America/Chicago"),
                                parameter_defaults = std_inputs)]...
Any help would be greatly appreciated!
k
How did you define the
Parameter
? Is it required and what is the default? Looking for
accnt
specifically
n
Hi @chicago-joe - it looks like you have a required parameter on your flow
accnt
that you’re setting to
None
in your parameter defaults. For any required parameters you’ll need to set a default there
c
@Kevin Kho parameter defined as:
accnt = Parameter('accnt', default = None)
@nicholas is correct, but this is intentional, as this script is a performance reporting module that takes a variety of inputs, where you can view the report for an account, for multiple accounts, or even entire strategies as whole. This input = None by default is by design on our side
so what I'm thinking is maybe have a default = "All" or some other type of string, which within the task logic it will take "All" and convert it to the null input necessary to run the report..thoughts?
k
Wouldnt that effectively be
required=False
if you can bypass it?
c
tbh, I wasn't quite clear on what happens when you set required=False. Prefect Github:
Args:
- name (str): the Parameter name.
- default (any, optional): A default value for the parameter. Must be a JSON-Serializable type.
- required (bool, optional): If True, the Parameter is required and the
default value is ignored. Defaults to
False
if a
default
is
provided, otherwise
True
.
Maybe I just was over-thinking it lol, but it didn't explain what happens. However, the DateTimeParameter class does explain that setting required=
False
will return
None
..
class DateTimeParameter(Parameter):
Args:
- name (str): the Parameter name.
- required (bool, optional): If True, the Parameter is required. Otherwise, it is optional and will return
None
if no value is provided.
@Kevin Kho ooo I hope you see what I mean, cause I really want to PR and contribute officially (however insignificant this update to the docs truly is lmao)!
k
You can go for it. Doc changes are certainly welcome
upvote 1
c
sweeet I'll be on that later this week!