Skip to content

Refactor CompositeSpec tests #230

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

Merged
merged 8 commits into from
Jun 29, 2022
Merged

Refactor CompositeSpec tests #230

merged 8 commits into from
Jun 29, 2022

Conversation

khmigor
Copy link
Contributor

@khmigor khmigor commented Jun 28, 2022

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 28, 2022
@vmoens
Copy link
Collaborator

vmoens commented Jun 28, 2022

Thanks for this!

Let's have a look at the failed tests.
For the linting issue, please refer to CONTRIBUTING.md on the home page of the repo

@vmoens vmoens added the Tests Incomplete or broken unit tests label Jun 28, 2022
@khmigor
Copy link
Contributor Author

khmigor commented Jun 28, 2022

Yes, looking at this right now. Unfortunately, I wasn't able to make suggested pre-commit linter work, but I ran some linters separately, and that should fix most issues.
As for the tests, I have lots of failed tests (locally) even when running on the main branch, which seems weird. Probably has something to do with mac architecture, so I'm reinstalling the dependencies just to double check.

@vmoens vmoens linked an issue Jun 28, 2022 that may be closed by this pull request
9 tasks
@vmoens vmoens changed the title [ISSUE-220] Refactor CompositeSpec tests Refactor CompositeSpec tests Jun 28, 2022
@khmigor khmigor marked this pull request as ready for review June 29, 2022 11:20
Copy link
Collaborator

@vmoens vmoens left a comment

Choose a reason for hiding this comment

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

Almost good to go!
Can you add a delitem method that points to del_, I don't think it exists yet

def test_setitem_matches_device(self, is_complete, device, dtype):
ts = self._composite_spec(is_complete, device, dtype)

bad_value, good_value = Mock(), Mock()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Great idea of using Mock though I see two caveats:
At one point we might check that specs are or type TensorSpec, does mock works in that case? (Ie does isinstance(mock, type) always true for all types?)
Second we rely on pytest for our tests and I'm not sure if we want to mix unittest and pytest.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good points, I'll change this.

ts = self._composite_spec(is_complete, device, dtype)
assert "obs" in ts.keys()
assert "act" in ts.keys()
ts.del_("obs")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we try with
del ts["obs"]
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.

Sure! Though I'm curious why we need del_ then, can we simply rename it to __delitem__?

Copy link
Collaborator

@vmoens vmoens Jun 29, 2022

Choose a reason for hiding this comment

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

sure! If tests pass i'm ok with it :p

Copy link
Collaborator

@vmoens vmoens left a comment

Choose a reason for hiding this comment

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

Staggering! Thanks a lot

@khmigor khmigor closed this Jun 29, 2022
@khmigor khmigor reopened this Jun 29, 2022
@vmoens vmoens merged commit 7798294 into pytorch:main Jun 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Tests Incomplete or broken unit tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor CompositeSpec tests
3 participants