Possible to avoid translating tuple
parameter values as strings, or else allow a user-supplied Translator
? #86
Description
Parametrizing a notebook on parameters={"list_param": [0,1], "tuple_param": (0,1)}
will result in list_param
value being injected as a list, but the tuple_param
value being injected as the stringified representation of a tuple
, e.g. "(0, 1)"
(literally with the quotes). I understand that ploomber-engine
strives to match the papermill
API, so maybe this is intentional to maintain that compatibility, but is there a chance for the parameter translator to faithfully inject tuples?
Maybe a more sensible request would be to allow the user to pass a custom Translator
to PloomberClient
, which could pass the custom Translator
subclass to parametrize_notebook
(below), allowing the user to customize behavior, in the case that it is desired to mimic the papermill
API surface by default?
Contents of translate
Here we see that tuple
falls through to the "last resort" translator which stringifies it.
ploomber-engine/src/ploomber_engine/_translator.py
Lines 76 to 95 in e00bdc2
Abbreviated contents of parametrize_notebook
ploomber-engine/src/ploomber_engine/_util.py
Lines 72 to 73 in e00bdc2
ploomber-engine/src/ploomber_engine/_util.py
Lines 92 to 94 in e00bdc2