question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[FEATURE] allow for all kwargs when using @log_step

See original GitHub issue

Hi,

When using @log_step in debugging a Pandas Pipeline, the current function must accept a single argument of df:pd.Dataframe.

However if the user sends all the parameters as kwargs there is an error .

It would be useful if the @log_step will check the first kwargs and if it is a pd.Dataframe then it will convert it into an arg - possible implementation before running the def wrapper() as follows

    _kwargs = {**kwargs}
    first_arg= next(iter(_kwargs))
    if isinstance(_kwargs[first_arg],pd.DataFrame) and len(args)==0:
        args=args+(_kwargs.pop[first_arg],)


Issue Analytics

  • State:open
  • Created 9 months ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
MBrounscommented, Dec 19, 2022

I’m not sure if changing args directly is a great way to solve this because we use it later in result = func(*args, **kwargs)

Maybe something like this?

if shape_delta:
    if len(args) > 0:
        old_shape = args[0].shape
    else: 
        for v in kwargs.values:
              if isinstance(v, pd.DataFrame):
                  old_shape = v.shape
                  break
         else:
               raise ValueError("shape_delta was set to true, but no DataFrame instance was found as either the first non-keyword argument or in the keyword arguments")
0reactions
sephibcommented, Dec 19, 2022

If you think this is a good direction I’ll be happy to submit a PR

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python args and kwargs: Demystified
In this step-by-step tutorial, you'll learn how to use args and kwargs in Python to add more flexibility to your functions. You'll also...
Read more >
How To Use *args and **kwargs in Python 3 - DigitalOcean
Let's create another short program to show how we can make use of **kwargs . Here we'll create a function to greet a...
Read more >
10 Examples to Master *args and **kwargs in Python
**kwargs allow a function to take any number of keyword arguments. By default, **kwargs is an empty dictionary. Each undefined keyword argument ...
Read more >
python - Passing more kwargs into a function than initially set
I'm using the inspect.signature() function to check if the callable supports a **kwarg catch-all (by looking for a Parameter.VAR_KEYWORD entry) ...
Read more >
What are args and kwargs and when to use them
So far, it is clear that you can use *args to accept a variable number of arguments in a function. But the other...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found