Skip to content
This repository has been archived by the owner on Nov 3, 2022. It is now read-only.

Checking that all files have owners. #441

Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,7 @@ We love pull requests. Here's a quick guide:
Both Keras-Contrib and Keras operate under the [MIT License](LICENSE). At the discretion of the maintainers of both repositories, code may be moved from Keras-Contrib to Keras and vice versa.

The maintainers will ensure that the proper chain of commits will flow in both directions, with proper attribution of code. Maintainers will also do their best to notify contributors when their work is moved between repositories.

## About the `CODEOWNERS` file

If you add a new feature to keras-contrib, you should add yourself and your file in the `CODEOWNERS` file. Doing so will, in the future, tag you whenever an issue or a pull request about your feature is opened. Be aware that it represents some work, and in addition of being tagged, you should review new pull requests related to your feature.
Copy link
Contributor

Choose a reason for hiding this comment

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

you should review new pull requests related to your feature.

Will it be possible to soften the tone a lil bit here? Something like "We would appreciate X" instead of "You should do X".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure thing, I'll change it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

78 changes: 78 additions & 0 deletions tests/tooling/test_codeowners.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,83 @@ def test_codeowners_user_exist():
assert client.get_user(user[1:])


directories_to_test = [
'examples',
'keras_contrib/activations',
'keras_contrib/applications',
'keras_contrib/callbacks',
'keras_contrib/constraints',
'keras_contrib/datasets',
'keras_contrib/initializers',
'keras_contrib/layers',
'keras_contrib/losses',
'keras_contrib/metrics',
'keras_contrib/optimizers',
'keras_contrib/preprocessing',
'keras_contrib/regularizers',
'keras_contrib/wrappers'
]
directories_to_test = [path_to_keras_contrib / x for x in directories_to_test]
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the use of pathlib instead of classic os.getcwd and os.path.join ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Less typing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test only runs on python 3 on travis btw, so it should be ok to use pathlib.


pattern_exclude = [
'.gitkeep',
'__init__.py'
]

# TODO: remove those files or find them owners.
exclude = [
'examples/cifar10_clr.py',
'examples/cifar10_densenet.py',
'examples/cifar10_nasnet.py',
'examples/cifar10_resnet.py',
'examples/cifar10_ror.py',
'examples/cifar10_wide_resnet.py',
'examples/conll2000_chunking_crf.py',
'examples/improved_wgan.py',
'examples/jaccard_loss.py',
'keras_contrib/activations/squash.py',
'keras_contrib/callbacks/cyclical_learning_rate.py',
'keras_contrib/callbacks/dead_relu_detector.py',
'keras_contrib/callbacks/snapshot.py',
'keras_contrib/applications/densenet.py',
'keras_contrib/applications/nasnet.py',
'keras_contrib/applications/resnet.py',
'keras_contrib/applications/wide_resnet.py',
'keras_contrib/constraints/clip.py',
'keras_contrib/datasets/coco.py',
'keras_contrib/datasets/conll2000.py',
'keras_contrib/datasets/pascal_voc.py',
'keras_contrib/initializers/convaware.py',
'keras_contrib/losses/crf_losses.py',
'keras_contrib/losses/dssim.py',
'keras_contrib/losses/jaccard.py',
'keras_contrib/layers/advanced_activations.py',
'keras_contrib/layers/capsule.py',
'keras_contrib/layers/convolutional.py',
'keras_contrib/layers/core.py',
'keras_contrib/layers/crf.py',
'keras_contrib/layers/normalization.py',
'keras_contrib/optimizers/ftml.py',
'keras_contrib/optimizers/lars.py',
'keras_contrib/optimizers/padam.py',
'keras_contrib/optimizers/yogi.py',
'keras_contrib/metrics/crf_accuracies.py',

Copy link
Contributor

Choose a reason for hiding this comment

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

empty line

]
exclude = [path_to_keras_contrib / x for x in exclude]


@pytest.mark.parametrize('directory', directories_to_test)
def test_all_files_have_owners(directory):
files_with_owners = [x[0] for x in parse_codeowners()]
for children in directory.iterdir():
if children.is_file():
if children.name in pattern_exclude:
Copy link
Contributor

Choose a reason for hiding this comment

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

combiner les deux en un seul if (children in exclude) or (children.name in pattern_exclude)

continue
if children in exclude:
continue
assert children in files_with_owners


if __name__ == '__main__':
pytest.main([__file__])