Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deactivate all snooping except explicitly specified "watch"es #247

Open
wolthom opened this issue Aug 20, 2023 · 3 comments
Open

Deactivate all snooping except explicitly specified "watch"es #247

wolthom opened this issue Aug 20, 2023 · 3 comments

Comments

@wolthom
Copy link

wolthom commented Aug 20, 2023

Hey There,

First of:
Thank you a lot for this awesome package :)
It's super useful for ad-hoc debugging of algorithms and data manipulations!

It would be awesome, if I could specify only certain variables, expressions, etc. to snoop on.
E.g., consider this minimal, constructed example:

import pandas as pd
import pysnooper

df = pd.DataFrame({"Job": ["3591.", "22226.", "2873.", "3591."]})

@pysnooper.snoop(watch="sub_df.shape")
def clean_df(df):
     sub_df = df
     sub_df = df.groupby("Job").agg("first").reset_index()
     return sub_df

clean_df(df)

In this case, I'd like to see only the expression passed to watch, to see how the DataFrame shape changes throughout the manipulations of some data processing pipeline.
Potentially, this could also interoperate really nicely with .pipe or .assign chains in pandas.

My apologies in case I missed this feature in the docs somewhere.

@cool-RR
Copy link
Owner

cool-RR commented Aug 20, 2023

Nice idea. If we do this, we could add a keyword argument show_all_variables=True so people could override it to False.

@alexmojaki Do you think this is a good feature to add?

@wolthom If we decide to go forward, will you write the feature including tests and a few lines of documentation?

@wolthom
Copy link
Author

wolthom commented Aug 20, 2023

@cool-RR This would depend a lot on how large of a PR this becomes / how much guidance someone can give me. Generally speaking, I'm definitely open to contributing this feature!

@cool-RR
Copy link
Owner

cool-RR commented Aug 29, 2023

@wolthom Looks like Alex is busy. Feel free to implement, if you wish. If you have any questions, let me know.

Lo236816 added a commit to Lo236816/PySnooper that referenced this issue Jan 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants