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

Make _get_tags a class/static method #3257

Merged
merged 24 commits into from
Feb 24, 2021

Conversation

dantegd
Copy link
Member

@dantegd dantegd commented Dec 4, 2020

From suggestion and talks with @mdemoret-nv we came to the conclusion that the _get_tags function is very useful as a class/static method, so this PR changes it.

If we require tags that are instance based, we can extend/modify the method in the future, but for now this seems like the best balance of simplicity and usefulness.

@dantegd dantegd added 2 - In Progress Currenty a work in progress Cython / Python Cython or Python issue improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels Dec 4, 2020
@dantegd dantegd changed the title Make _get_tags a class/static method Make _get_tags a class/static method Dec 4, 2020
@GPUtester
Copy link
Contributor

Please update the changelog in order to start CI tests.

View the gpuCI docs here.

Copy link
Contributor

@mdemoret-nv mdemoret-nv left a comment

Choose a reason for hiding this comment

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

Changes look good. Only one minor suggestion to add an assertion to the tags test to make sure new methods going forward aren't instance or class methods.

Comment on lines 84 to 99
# mod = models[model_name]
# assert hasattr('_get_tags', m)

# for tag in tags:
# assert
assert hasattr(model, '_get_tags')

print(model)
if model in (cuml.tsa.auto_arima.AutoARIMA, cuml.tsa.arima.ARIMA,
cuml.tsa.holtwinters.ExponentialSmoothing):
mod = model(cp.ones(10))
else:
mod = model()

assert hasattr(mod, '_get_tags')

model_tags = mod._get_tags()
Copy link
Contributor

Choose a reason for hiding this comment

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

Immediately you can see how much better the testing will be with static tags

python/cuml/common/base.pyx Outdated Show resolved Hide resolved
python/cuml/test/test_api.py Show resolved Hide resolved
@dantegd
Copy link
Member Author

dantegd commented Dec 9, 2020

rerun tests

@dantegd dantegd changed the title Make _get_tags a class/static method Make _get_tags a class/static method [skip-ci] Dec 9, 2020
@dantegd dantegd added the proposal Change current process or code label Dec 9, 2020
@dantegd dantegd mentioned this pull request Jan 11, 2021
@dantegd dantegd changed the title Make _get_tags a class/static method [skip-ci] Make _get_tags a class/static method Jan 20, 2021
@dantegd
Copy link
Member Author

dantegd commented Jan 20, 2021

rerun tests

@dantegd dantegd added 4 - Waiting on Reviewer Waiting for reviewer to review or respond and removed 2 - In Progress Currenty a work in progress labels Jan 20, 2021
@dantegd dantegd marked this pull request as ready for review January 20, 2021 17:21
@dantegd
Copy link
Member Author

dantegd commented Feb 3, 2021

@mdemoret-nv yeah was just busy debugging other things, will push the changes you request early tomorrow and ping you for a re-review, thanks!

@dantegd dantegd changed the base branch from branch-0.18 to branch-0.19 February 9, 2021 19:28
@dantegd dantegd changed the title Make _get_tags a class/static method Make _get_tags a class/static method [skip-ci] Feb 9, 2021
@dantegd dantegd changed the title Make _get_tags a class/static method [skip-ci] Make _get_tags a class/static method Feb 22, 2021
@dantegd dantegd changed the title Make _get_tags a class/static method Make _get_tags a class/static method [skip-ci] Feb 22, 2021
dantegd and others added 4 commits February 22, 2021 10:43
Co-authored-by: Michael Demoret <42954918+mdemoret-nv@users.noreply.github.com>
Co-authored-by: Michael Demoret <42954918+mdemoret-nv@users.noreply.github.com>
@dantegd dantegd changed the title Make _get_tags a class/static method [skip-ci] Make _get_tags a class/static method Feb 22, 2021
@dantegd dantegd added 4 - Waiting on Reviewer Waiting for reviewer to review or respond and removed 4 - Waiting on Author Waiting for author to respond to review labels Feb 22, 2021
Copy link
Contributor

@mdemoret-nv mdemoret-nv left a comment

Choose a reason for hiding this comment

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

Looks good to me. I think this will be useful to get merged. We can start reworking some of the hard-coded tests to use the mixins.

python/cuml/common/mixins.py Outdated Show resolved Hide resolved
Comment on lines +181 to +182
assert static_tags['preferred_input_order'] == 'F'
assert dynamic_tags['preferred_input_order'] == 'F'
Copy link
Contributor

Choose a reason for hiding this comment

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

In this case, wouldnt it be better to error out since this clearly would be an error? Or are you testing this for overriding purposes?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, this test to be sure that the closest thing to the class in the MRO overwrites the farthest ones, added a quick comment to separate both tests and a quick note on the estimator guide about the MRO resolution and how that can affect tags.

@codecov-io
Copy link

Codecov Report

Merging #3257 (b2c9075) into branch-0.19 (39c7262) will increase coverage by 9.05%.
The diff coverage is 82.91%.

Impacted file tree graph

@@               Coverage Diff               @@
##           branch-0.19    #3257      +/-   ##
===============================================
+ Coverage        71.77%   80.83%   +9.05%     
===============================================
  Files              212      226      +14     
  Lines            17075    17705     +630     
===============================================
+ Hits             12256    14311    +2055     
+ Misses            4819     3394    -1425     
Flag Coverage Δ
dask 45.21% <56.61%> (?)
non-dask 73.07% <81.89%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
python/cuml/experimental/explainer/common.py 88.05% <42.85%> (-4.01%) ⬇️
python/cuml/neighbors/ann.pyx 61.62% <61.62%> (ø)
python/cuml/common/import_utils.py 59.43% <66.66%> (+3.43%) ⬆️
python/cuml/experimental/explainer/base.pyx 67.06% <67.06%> (ø)
...l/_thirdparty/sklearn/preprocessing/_imputation.py 62.80% <80.00%> (+0.29%) ⬆️
python/cuml/neighbors/nearest_neighbors.pyx 92.40% <80.00%> (-0.31%) ⬇️
python/cuml/dask/common/utils.py 43.68% <83.33%> (+16.13%) ⬆️
python/cuml/common/mixins.py 95.45% <95.45%> (ø)
...on/cuml/_thirdparty/sklearn/preprocessing/_data.py 63.24% <100.00%> (-0.30%) ⬇️
python/cuml/cluster/dbscan.pyx 100.00% <100.00%> (ø)
... and 108 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8e497d0...b2c9075. Read the comment docs.

@dantegd
Copy link
Member Author

dantegd commented Feb 24, 2021

@gpucibot merge

@rapids-bot rapids-bot bot merged commit 82e58d6 into rapidsai:branch-0.19 Feb 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4 - Waiting on Reviewer Waiting for reviewer to review or respond Cython / Python Cython or Python issue improvement Improvement / enhancement to an existing function non-breaking Non-breaking change proposal Change current process or code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants