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

Update asserts in python tests #3336

Merged
merged 6 commits into from
Sep 16, 2021
Merged

Update asserts in python tests #3336

merged 6 commits into from
Sep 16, 2021

Conversation

awolant
Copy link
Contributor

@awolant awolant commented Sep 13, 2021

Signed-off-by: Albert Wolant awolant@nvidia.com

Description

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactoring (Redesign of existing code that doesn't affect functionality)
  • Other (e.g. Documentation, Tests, Configuration)

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

  • Existing tests apply
  • New tests added
    • Python tests
    • GTests
    • Benchmark
    • Other
  • N/A

Documentation

  • Existing documentation applies
  • Documentation updated
    • Docstring
    • Doxygen
    • RST
    • Jupyter
    • Other
  • N/A

DALI team only

Requirements

  • Implements new requirements
  • Affects existing requirements
  • N/A

REQ IDs: N/A

JIRA TASK: N/A

Signed-off-by: Albert Wolant <awolant@nvidia.com>
@awolant awolant changed the title Update readers.coco tests Update asserts in python tests Sep 13, 2021
@raises(RuntimeError)
@raises(
RuntimeError,
glob="Assert on \"HasArgument(name)\" failed: Argument \"preprocessed_annotations_dir\" is not supported by operator \"readers__COCO\".")
Copy link
Contributor

@mzient mzient Sep 14, 2021

Choose a reason for hiding this comment

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

  1. Don't include assertion condition in the message.
  2. 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.
  3. Nitpick: use single quotes, so you don't have to escape the double quotes - it keeps the pattern more readable.
  4. Nitpick: glob can be specified with a positional argument - keeps the line shorter
Suggested change
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')

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

@@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

mzient
mzient previously approved these changes Sep 14, 2021
@mzient mzient self-requested a review September 14, 2021 09:14
@mzient mzient marked this pull request as ready for review September 14, 2021 09:15
@mzient mzient marked this pull request as draft September 14, 2021 09:16
Signed-off-by: Albert Wolant <awolant@nvidia.com>
Signed-off-by: Albert Wolant <awolant@nvidia.com>
Signed-off-by: Albert Wolant <awolant@nvidia.com>
@awolant awolant marked this pull request as ready for review September 14, 2021 14:14
@awolant
Copy link
Contributor Author

awolant commented Sep 14, 2021

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [2978636]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

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):
Copy link
Member

@stiepan stiepan Sep 15, 2021

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.

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

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.")
Copy link
Contributor

@mzient mzient Sep 15, 2021

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).

Suggested change
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. ")

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


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
Copy link
Contributor

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?).

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

Signed-off-by: Albert Wolant <awolant@nvidia.com>
@awolant
Copy link
Contributor Author

awolant commented Sep 16, 2021

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [2992705]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [2992705]: BUILD PASSED

@awolant awolant merged commit 4814867 into NVIDIA:main Sep 16, 2021
cyyever pushed a commit to cyyever/DALI that referenced this pull request Oct 17, 2021
* Update asserts in python tests

Signed-off-by: Albert Wolant <awolant@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
* Update asserts in python tests

Signed-off-by: Albert Wolant <awolant@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
* Update asserts in python tests

Signed-off-by: Albert Wolant <awolant@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
* Update asserts in python tests

Signed-off-by: Albert Wolant <awolant@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
* Update asserts in python tests

Signed-off-by: Albert Wolant <awolant@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
* Update asserts in python tests

Signed-off-by: Albert Wolant <awolant@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
* Update asserts in python tests

Signed-off-by: Albert Wolant <awolant@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
* Update asserts in python tests

Signed-off-by: Albert Wolant <awolant@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
* Update asserts in python tests

Signed-off-by: Albert Wolant <awolant@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
* Update asserts in python tests

Signed-off-by: Albert Wolant <awolant@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
* Update asserts in python tests

Signed-off-by: Albert Wolant <awolant@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
* Update asserts in python tests

Signed-off-by: Albert Wolant <awolant@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
* Update asserts in python tests

Signed-off-by: Albert Wolant <awolant@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
* Update asserts in python tests

Signed-off-by: Albert Wolant <awolant@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Feb 21, 2022
* Update asserts in python tests

Signed-off-by: Albert Wolant <awolant@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request May 13, 2022
* Update asserts in python tests

Signed-off-by: Albert Wolant <awolant@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jun 7, 2022
* Update asserts in python tests

Signed-off-by: Albert Wolant <awolant@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants