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

Add functionality for ignoring notebooks #13

Closed
wants to merge 13 commits into from
Closed

Add functionality for ignoring notebooks #13

wants to merge 13 commits into from

Conversation

natanlao
Copy link

@natanlao natanlao commented Aug 9, 2019

Closes #1. Allows ignoring notebooks with a .treonignore file. It mimics how .gitignore files work, except a little simpler.

@amit1rrr
Copy link
Member

amit1rrr commented Aug 9, 2019

Thanks for your contribution @natanlao

We can actually simplify this quite a bit. From requirements perspective, we don't need to support multiple .treonignore files, just one file at the base of test PATH specified to treon should suffice. What we actually need though is to be able to specify individual file paths to ignore e.g. run all tests except ignore this scratch notebook.

With these requirements in mind we can simply implement the following,

  1. read all entries in a single .treonignore file (if present at base of test PATH)
  2. From our list of notebooks to test, remove the notebooks whose path overlaps with any entry in our ignore list

Edit: Updated my own suggestions.

@natanlao
Copy link
Author

natanlao commented Aug 9, 2019

From requirements perspective, we don't need to support multiple .treonignore files, just one file at the base of test PATH specified to treon should suffice.

I'm not sure that only looking for a single .treonignore file would make this code materially simpler. I think that both approaches are similar in terms of both complexity and LOC. That said, I'm happy to change it if you still think it's a good idea.

What we actually need though is to be able to specify individual file paths to ignore e.g. run all tests except ignore this scratch notebook.

That works!

assert TEST_NOTEBOOK_PATH.joinpath('basic.ipynb').samefile(ignored[0])

@amit1rrr
Copy link
Member

@natanlao I'm sorry I haven't been able to find free time to review this properly. I want to clone your changes and try it out locally for a meaningful review. I will get to it early next week. Sorry again for the delay.

@natanlao
Copy link
Author

@amit1rrr All good! Thanks for your time.

elif path.is_dir():
LOG.info("Recursively scanning %s for notebooks...", path)
ignored = build_ignore_list(path)
notebooks = filter(lambda nb: nb not in ignored, path.glob('**/*.ipynb'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignore paths are not working recursively.

E.g. Even if I have following rule in .treonignore
site/en/r2/*

all these following files are not-ignored

/workspace/treon/tmp/docs/site/en/r2/tutorials/eager/custom_layers.ipynb
/workspace/treon/tmp/docs/site/en/r2/tutorials/load_data/images.ipynb
...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good catch. It looks like pathlib isn't working predictably...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still not working for me.

I have following rules in .treonignore -

site/en/r2/*
site/en/r2/tutorials/load_data/tf_records.ipynb

and the following files are still not ignored

'/workspace/treon/tmp/docs/site/en/r2/tutorials/eager/custom_layers.ipynb', '/workspace/treon/tmp/docs/site/en/r2/tutorials/load_data/images.ipynb', '/workspace/treon/tmp/docs/site/en/r2/tutorials/load_data/tf_records.ipynb'

@natanlao
Copy link
Author

natanlao commented Sep 7, 2019

Thanks for the review @amit1rrr! I've addressed your comments and added tests cases where appropriate.

@natanlao natanlao requested a review from amit1rrr September 7, 2019 05:37
@amit1rrr
Copy link
Member

amit1rrr commented Sep 9, 2019

I tried it again. Somehow the ignore list is still not working for me. Posted example in a separate comment.

I honestly think that this approach is getting too complicated in our quest to be identical as .gitignore (which we don't need to be). How about we simply read a single .treonignore file at base of the path. And exclude that rule list from notebooks_to_test by simply comparing whether the notebook path starts with any rule (if yes, ignore).

Some benefits over current approach,

  • Our ignore file can accept absolute paths (currently absolute paths are not supported I believe)
  • Single ignore file is easy to keep track of for a user (no unintended ignoring of notebooks)

@natanlao
Copy link
Author

Okay! Sounds good to me.

@amit1rrr
Copy link
Member

Discarding this PR now that we have --exclude command line option.

@amit1rrr amit1rrr closed this Nov 28, 2019
@natanlao
Copy link
Author

natanlao commented Dec 2, 2019

Sorry, this got stuck on my backlog! Thanks for following up.

@amit1rrr
Copy link
Member

amit1rrr commented Dec 2, 2019

No worries @natanlao

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

Successfully merging this pull request may close these issues.

Ability to ignore set of notebooks from test suite
2 participants