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

Adjust usage of rasies and assert_raises in tests #3318

Merged
merged 8 commits into from
Sep 8, 2021

Conversation

klecki
Copy link
Contributor

@klecki klecki commented Sep 6, 2021

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

  • Adjust tests to utilize assert_raises and raises
    utilities with glob pattern checked against
    the error message.
  • Adjust tests to behave as expected
    (cause the expected exception).
  • Fix some typos.
  • Remove unused imports in one case.

Additional information

  • Affected modules and functionalities:
    tests

  • Key points relevant for the review:
    N/A

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: DALI-2234

Signed-off-by: Krzysztof Lecki <klecki@nvidia.com>
Signed-off-by: Krzysztof Lecki <klecki@nvidia.com>
Signed-off-by: Krzysztof Lecki <klecki@nvidia.com>
Signed-off-by: Krzysztof Lecki <klecki@nvidia.com>
Signed-off-by: Krzysztof Lecki <klecki@nvidia.com>
Signed-off-by: Krzysztof Lecki <klecki@nvidia.com>
Signed-off-by: Krzysztof Lecki <klecki@nvidia.com>
@klecki
Copy link
Contributor Author

klecki commented Sep 6, 2021

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [2924536]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [2924536]: BUILD FAILED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [2924536]: BUILD PASSED

@@ -29,7 +29,7 @@ def test_keras_single_cpu():
run_keras_single_device('cpu', 0)


@raises(Exception)
@raises(Exception, "TF device and DALI device mismatch. TF*: CPU, DALI*: GPU for output*")
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need to add trailing * at the end of glob pattern.

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

batch_size=batch_size,
output_shapes=shapes,
output_dtypes=dtypes,
num_threads=num_threads)


@raises(RuntimeError)
@raises(RuntimeError, "*some operators*cannot be used with TensorFlow Dataset API and DALIIterator")
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you need leading * in glob pattern?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really.


for shape, layout in [([6, 1], "XF"), ([8, 10, 3], "HWC")]:
with assert_raises(RuntimeError,
glob="Input layout must describe a sequence*start with 'F', got*instead"):
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not about this pattern. wildcards inside doesn't provide any flexibility from my point of view, so you can put the whole message here as well.

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

check_element_extract(shape, layout, [1, 3], "cpu")

with assert_raises(RuntimeError,
glob="Index*10*from *element_map* out of bounds for*sequence length*6*"):
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not about this pattern. wildcards inside doesn't provide any flexibility from my point of view, so you can put the whole message here as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now I'm just worried, that we will want to fix the ', ` and " around the variables.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But then we can adjust the test, it would be easily detectable.

Copy link
Contributor

Choose a reason for hiding this comment

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

It is unclear for me what we want to leave undefined and what to be strict about. * just for " or ` blurs the pattern from my point of view.

Signed-off-by: Krzysztof Lecki <klecki@nvidia.com>
@klecki
Copy link
Contributor Author

klecki commented Sep 7, 2021

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [2931550]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [2931550]: BUILD PASSED

@klecki klecki merged commit a51eba2 into NVIDIA:main Sep 8, 2021
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