-
Notifications
You must be signed in to change notification settings - Fork 615
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
Update asserts in python tests #3336
Conversation
Signed-off-by: Albert Wolant <awolant@nvidia.com>
@raises(RuntimeError) | ||
@raises( | ||
RuntimeError, | ||
glob="Assert on \"HasArgument(name)\" failed: Argument \"preprocessed_annotations_dir\" is not supported by operator \"readers__COCO\".") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Don't include assertion condition in the message.
- I remember that on one meeting there was a conclusion that putting entire error messages verbatim is excessive. Here, I'd suggest putting a wildcard in place of
__
, which we hope to replace with proper module name at some point. - Nitpick: use single quotes, so you don't have to escape the double quotes - it keeps the pattern more readable.
- Nitpick: glob can be specified with a positional argument - keeps the line shorter
glob="Assert on \"HasArgument(name)\" failed: Argument \"preprocessed_annotations_dir\" is not supported by operator \"readers__COCO\".") | |
'Argument "preprocessed_annotations_dir" is not supported by operator *readers*COCO') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -170,4 +172,4 @@ def test_coco_reader_alias(): | |||
for polygon_masks, pixelwise_masks in [(None, None), (True, None), (None, True)]: | |||
new_pipe = coco_pipe(fn.readers.coco, file_root, train_annotations, polygon_masks, pixelwise_masks) | |||
legacy_pipe = coco_pipe(fn.coco_reader, file_root, train_annotations, polygon_masks, pixelwise_masks) | |||
compare_pipelines(new_pipe, legacy_pipe, batch_size_alias_test, 50) | |||
compare_pipelines(new_pipe, legacy_pipe, batch_size_alias_test, 5) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Signed-off-by: Albert Wolant <awolant@nvidia.com>
Signed-off-by: Albert Wolant <awolant@nvidia.com>
!build |
CI MESSAGE: [2978636]: BUILD STARTED |
CI MESSAGE: [2978636]: BUILD PASSED |
([np.int32([0]), np.int32([])], True), ([np.int32([6, 7]), np.int32([0])], True), | ||
([np.int32([-1]), np.int32([0])], True), ([np.int32([[1], [2]]), np.int32([[1], [2]])], True)]: | ||
yield check_fail_sequence_rearrange, 2, shape, new_order, per_sample, dev | ||
for args, error_msg in zip(orders, error_msgs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That might be overdoing things but I thought about adding assert on equal lengths of both lists before looping over zip(orders, error_msgs)
just in case somebody adds a case to orders
in the future and misses the fact that the change should be reflected in error_msgs
as zip just happily ignores rest of the longer list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
assert_raises( | ||
RuntimeError, | ||
pipe.build, | ||
glob="Cannot make a gpu output for __ExternalSource_0 operator, device_id should not be equal CPU_ONLY_DEVICE_ID.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This message doesn't sport the most beautiful English. Indeed, I don't even know what it means and what could be understood by the user.
There are other problems with this message - for once, the name used in the message is not the name of the operator/producer, but the name of the output (a DataNode).
Here's a possible alternative, but I'm not very attached to it (I think it's better, but it probably could be improved further).
glob="Cannot make a gpu output for __ExternalSource_0 operator, device_id should not be equal CPU_ONLY_DEVICE_ID.") | |
glob='Cannot move the data node \"__ExternalSource_0\" to the GPU in a CPU-only pipeline.' | |
'The `device_id` parameter is set tot `CPU_ONLY_DEVICE_ID`. Set `device_id` to a valid GPU identifier to enable GPU features in the pipeline. ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
def test_wrong_layouts_sequence_rearrange(): | ||
shape = [5, 1] | ||
new_order = [0, 2, 1, 3, 4] | ||
per_sample = False | ||
for dev in ["cpu", "gpu"]: | ||
for layout in ["HF", "HW"]: | ||
yield check_fail_sequence_rearrange, 5, shape, new_order, per_sample, dev, layout | ||
yield raises(RuntimeError, glob="Expected sequence as the input, where outermost dimension represents frames dimension `F`")(check_fail_sequence_rearrange), 5, shape, new_order, per_sample, dev, layout |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's also a bit cryptic to an outsider (maybe mentioning layout would help?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Signed-off-by: Albert Wolant <awolant@nvidia.com>
!build |
CI MESSAGE: [2992705]: BUILD STARTED |
CI MESSAGE: [2992705]: BUILD PASSED |
* Update asserts in python tests Signed-off-by: Albert Wolant <awolant@nvidia.com>
* Update asserts in python tests Signed-off-by: Albert Wolant <awolant@nvidia.com>
* Update asserts in python tests Signed-off-by: Albert Wolant <awolant@nvidia.com>
* Update asserts in python tests Signed-off-by: Albert Wolant <awolant@nvidia.com>
* Update asserts in python tests Signed-off-by: Albert Wolant <awolant@nvidia.com>
* Update asserts in python tests Signed-off-by: Albert Wolant <awolant@nvidia.com>
* Update asserts in python tests Signed-off-by: Albert Wolant <awolant@nvidia.com>
* Update asserts in python tests Signed-off-by: Albert Wolant <awolant@nvidia.com>
* Update asserts in python tests Signed-off-by: Albert Wolant <awolant@nvidia.com>
* Update asserts in python tests Signed-off-by: Albert Wolant <awolant@nvidia.com>
* Update asserts in python tests Signed-off-by: Albert Wolant <awolant@nvidia.com>
* Update asserts in python tests Signed-off-by: Albert Wolant <awolant@nvidia.com>
* Update asserts in python tests Signed-off-by: Albert Wolant <awolant@nvidia.com>
* Update asserts in python tests Signed-off-by: Albert Wolant <awolant@nvidia.com>
* Update asserts in python tests Signed-off-by: Albert Wolant <awolant@nvidia.com>
* Update asserts in python tests Signed-off-by: Albert Wolant <awolant@nvidia.com>
* Update asserts in python tests Signed-off-by: Albert Wolant <awolant@nvidia.com>
Signed-off-by: Albert Wolant awolant@nvidia.com
Description
What happened in this PR
Additional information
Affected modules and functionalities:
Python tests
Key points relevant for the review:
Are the assertions correct
Checklist
Tests
Documentation
DALI team only
Requirements
REQ IDs: N/A
JIRA TASK: N/A