Skip to content

Conversation

piyush01123
Copy link
Contributor

Contains commits from @abhi-glitchhg and me on #5228

@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented Jan 25, 2022

💊 CI failures summary and remediations

As of commit d79b512 (more details on the Dr. CI page):


💚 💚 Looks good so far! There are no failures yet. 💚 💚


This comment was automatically generated by Dr. CI (expand for details).

Please report bugs/suggestions to the (internal) Dr. CI Users group.

Click here to manually regenerate this comment.

Copy link
Contributor

@oke-aditya oke-aditya left a comment

Choose a reason for hiding this comment

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

Minor nit. Apart from that looks fine 😄

y = resnet_fpn_backbone(backbone_name=backbone_name, pretrained=False)(x)
assert list(y.keys()) == ["0", "1", "2", "3", "pool"]

with pytest.raises(ValueError):
Copy link
Contributor

Choose a reason for hiding this comment

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

As a convention, Please append the error message

Suggested change
with pytest.raises(ValueError):
with pytest.raises(ValueError, "Whatever error message it will raise"):

Copy link
Contributor

Choose a reason for hiding this comment

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

yes you left that comment on previous PR,

Copy link
Contributor Author

@piyush01123 piyush01123 Jan 25, 2022

Choose a reason for hiding this comment

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

This seems to be failing. Should we add match argument as per https://docs.pytest.org/en/6.2.x/reference.html?highlight=raises#pytest.raises

Here is a simpler test I wrote that fails too with the same error TypeError: 'Sth' object (type: <class 'str'>) must be callable:

import pytest

def checkme(p):
    raise ValueError("Sth")

@pytest.mark.parametrize("mypar", (1,2,3))
def testMethod(mypar):
    with pytest.raises(ValueError, "Sth"):
        checkme(mypar)

Copy link
Contributor Author

@piyush01123 piyush01123 Jan 25, 2022

Choose a reason for hiding this comment

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

Resolved. It is happy with the match argument

assert ret == 3
# can't go beyond 5
with pytest.raises(AssertionError):
with pytest.raises(ValueError):
Copy link
Contributor

Choose a reason for hiding this comment

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

here too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolved

@abhi-glitchhg
Copy link
Contributor

@piyush01123 I have added error messages in tests; could you merge that pr(#5264 ) in this pr?

@abhi-glitchhg
Copy link
Contributor

Okay; you have added those messages; then I will close my PR! Thanks.

@abhi-glitchhg
Copy link
Contributor

abhi-glitchhg commented Jan 25, 2022

ig there are some lint issues;
maybe try running

pre-commit run ufmt
pre-commit run flake8

@piyush01123
Copy link
Contributor Author

hey I am sorry I am so much slow at this. I am not very fast with linting and testing. I am trying to resolve everything you guys have raises though.

@abhi-glitchhg
Copy link
Contributor

hey I am sorry I am so much slow at this. I am not very fast with linting and testing. I am trying to resolve everything you guys have raises though.

i guess there are no lint issues after the recent PR.

@datumbox datumbox changed the title Backbon edit Replace asserts with ValueErrors Jan 25, 2022
assert ret == 3
# can't go beyond 5
with pytest.raises(AssertionError):
with pytest.raises(ValueError):
Copy link
Contributor

Choose a reason for hiding this comment

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

Final one @piyush01123

Copy link
Contributor Author

@piyush01123 piyush01123 Jan 25, 2022

Choose a reason for hiding this comment

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

This is resolved now I think

Copy link
Contributor

@datumbox datumbox left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@oke-aditya
Copy link
Contributor

oke-aditya commented Jan 25, 2022

Nice work! Thanks a lot to @abhi-glitchhg and @piyush01123 for great collaboration. And congratulation to @piyush01123 for first contribution 🎉

@datumbox datumbox merged commit 729178c into pytorch:main Jan 25, 2022
facebook-github-bot pushed a commit that referenced this pull request Feb 3, 2022
Summary:
* replace assert with valueerror

* pytest should raise ValueError not AssertionError

* minor edit

* raise assert changed to raise valueerror in test

* Update torchvision/models/detection/backbone_utils.py

* Update torchvision/models/detection/backbone_utils.py

* minor edits

* minor edits

* added one test

* added another test

* added another test

* test for mobilenet

* ufmt formatting

* cant have unused variables

* suggested changes

* minor edit

* corrected bug pointed out by datumbox

* corrected bug pointed out by datumbox

* bug correction and shorten msg

* ufmt stuff

* resolved last comment

Reviewed By: kazhang

Differential Revision: D33927485

fbshipit-source-id: 152522dca213ea1b16ca5fb8f12fc21f803233dd

Co-authored-by: Aditya Oke <47158509+oke-aditya@users.noreply.github.com>
Co-authored-by: Aditya Oke <47158509+oke-aditya@users.noreply.github.com>
Co-authored-by: Abhijit Deo <72816663+abhi-glitchhg@users.noreply.github.com>
Co-authored-by: Aditya Oke <47158509+oke-aditya@users.noreply.github.com>
Co-authored-by: Vasilis Vryniotis <datumbox@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace plain asserts with ValueErrors in bacbone utils
5 participants