nteract/papermill

How should we pass / control kwargs ?

Open

#354 opened on May 5, 2019

View on GitHub
 (7 comments) (0 reactions) (4 assignees)Python (402 forks)batch import
help wantedidea

Repository metrics

Stars
 (5,381 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

In https://github.com/nteract/papermill/pull/351 it was raised that the manner in which we pass kwargs hasn't been well defined. We have several places where we pass everything downstream with **kwargs. But we don't control for duplicate names, especially as we're making API improvements.

Having kwarg passing is very useful from plugins we didn't write to be able to control their execution easily, and I'd prefer we keep a mechanism for passing parameters and data to any registered handler methods to support use cases we haven't thought or which are specific to a particular use case.

Off the top of mind I can think of two simple ways to address the name overlap issue.

  • Make a function wrapper to safely map kwargs, prioritizing function def names over kwargs that overlap
  • Always convert kwargs to safe_kwargs dict we pass without the ** splat pattern

One of us will need to implement the solution we land on, likely before the next release. I assigned maintainers involved in the original discussion for now.

Contributor guide