kynan / nbstripout

strip output from Jupyter and IPython notebooks
Other
1.19k stars 94 forks source link

dry run seems to always print that a file would be changed #152

Open alonme opened 3 years ago

alonme commented 3 years ago

I noticed that when using dry_run, all files are always printed as if they would be changed.

Looking at the code briefly, it does seem like this is what happens.

kynan commented 3 years ago

all files are always printed as if they would be changed

Can you clarify what you mean? What are "all files" here?

alonme commented 3 years ago

Yes, sorry for being unclear.

every file that is passed to nbstripout will print. Dry run: would have stripped {file}

this happens even if a strip a file and then right after that run a dry run.

my expectation is that only files that would have been changed if a "wet run" would have been used - would be printed

kynan commented 3 years ago

OK, I see what you mean. It is a fair point, but not trivial to support unfortunately: it would mean checking if applying nbstripout would have created a diff, which we don't currently have an easy way to do.

I'll add it as a feature request to the backlog.

alonme commented 3 years ago

Thanks.

Just so i understand - what is the current value of the dry-run option?

kynan commented 3 years ago

It will tell you which files are in scope / would be touched. I agree that your definition is more useful.

joaonc commented 2 years ago

Could this be related to this other issue? https://github.com/kynan/nbstripout/issues/160

kynan commented 2 years ago

@joaonc only tangentially. This request is about turning --dry-run into an "actual" dry run and only report if any changes would have been made.

kynan commented 1 year ago

@alonme Would you be interested in implementing this?

swateek commented 1 year ago

I am facing trouble here, I'll want to give this a try at implementing this @kynan

kynan commented 1 year ago

@swateek sure! You'd need to change this line to not overwrite the notebook and then in the following if args.dry_run: block you'd need to check if any changes were applied and then only output if there is a diff. You should also do this for the Zeppelin notebook type above. Is this enough to get you started?

swateek commented 1 year ago

let me try this out!