You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
prepare_for_crude_dispatch is still a low level function not intended to be used directly, except by "experts".
We need to give a few easy-to-use (yet safe) tools for higher-level users to use crude.
Here's one proposal.
fromdataclassesimportmake_dataclassfromi2importSigfromfront.crudeimportprepare_for_crude_dispatch_Crudifier=make_dataclass('_Crudifier', [(p.name, p.kind, p.default) forpinSig(prepare_for_crude_dispatch).params[1:]])
classCrudifier(_Crudifier):
def__call__(self, func):
# is there a safer way than vars to get the init fields (keys and values)?returnprepare_for_crude_dispatch(func, **vars(self))
This callable object, or something like it, can then be used in a recursive transformer such a
the front rendering process to indicate that a function should be crudified, and how.
For example:
configs = {
# of course, this is not our actual configs, but used here for simplicity.
foo: {
'preprocesses': Crudify('x y'),
'whatevs': 42
},
bar: {
'blahblah': 24
}
}
prepared_configs = dict(prepare(configs))
processed_foo = prepared_configs[foo]['func']
assert processed_foo('stored_two', 'three') == 5
The text was updated successfully, but these errors were encountered:
prepare_for_crude_dispatch
is still a low level function not intended to be used directly, except by "experts".We need to give a few easy-to-use (yet safe) tools for higher-level users to use crude.
Here's one proposal.
Here are a few examples of how to use it.
This allows you to do things like partialize, to fix the mall, and only have to specify the param_to_mall_map when you want to crudify
This callable object, or something like it, can then be used in a recursive transformer such a
the front rendering process to indicate that a function should be crudified, and how.
For example:
Example use:
The text was updated successfully, but these errors were encountered: