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

Add error message checks #3371

Merged
merged 2 commits into from
Sep 27, 2021
Merged

Conversation

banasraf
Copy link
Collaborator

Signed-off-by: Rafal Banas.Rafal97@gmail.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

Adding error message checks + some test fixes

Additional information

  • Affected modules and functionalities:
  • Key points relevant for the review:

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: Rafal <Banas.Rafal97@gmail.com>
# source provided, so we don't have valid placeholder
yield check_disallowed_es, {'name': 'a', 'source': []}, {'a': in_dataset}
# misnamed placeholder
yield check_disallowed_es, {'name': 'b'}, {'a': in_dataset}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This one is already covered on L260


pipeline = get_image_pipeline(batch_size, num_threads, 'gpu', 0)

with tf.device('/cpu:0'):
dataset = get_dali_dataset_from_pipeline(
pipeline, batch_size, num_threads, 'cpu', 0)
dataset = get_dali_dataset_from_pipeline(pipeline, 'cpu', 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

👍


@pipeline_def(batch_size=10, num_threads=4, device_id=0)
def es_pipe(kwargs):
return fn.external_source(**kwargs)


@raises(Exception)
def check_disallowed_es(kwargs, input_datasets):
# @raises(Exception)
Copy link
Contributor

Choose a reason for hiding this comment

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

?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

leftover - removed

@@ -35,7 +37,10 @@ def test_tf_dataset_cpu():
run_tf_dataset_eager_mode('cpu')

# Return differently sized images to check if DALIDataset can handle this case gracefully
@raises(tf.errors.FailedPreconditionError)
@raises(tf.errors.FailedPreconditionError, glob='*Batch output at index * from DALI pipeline is not uniform - individual '
Copy link
Contributor

Choose a reason for hiding this comment

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

You can remove leading and trailing * from glob pattern. They are not needed, as glob to regexp converted we use adds them automatically.

Copy link
Contributor

Choose a reason for hiding this comment

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

You can skip most of the message and only match relevant fragments, making some slack for future adjustment of the error messages.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I removed all the leading and trailing * and shortened the patterns to the essential parts.

def test_set_outputs():
data = [[[np.random.rand(1, 3, 2)], [np.random.rand(1, 4, 5)]]]
pipe = Pipeline(batch_size = 1, num_threads = 1, device_id = None)
pipe.set_outputs(fn.external_source(data, num_outputs = 2, cycle = 'quiet'))
assert_raises(TypeError, pipe.build)
pipe.build()
Copy link
Contributor

Choose a reason for hiding this comment

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

I would stick to checking if the build step raises that error, not any other one.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from nose.tools.nontrivial import raises
Copy link
Contributor

Choose a reason for hiding this comment

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

?

Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove. That's probably VSCode's doing - it keeps doing it to me all the time :\

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removed

@@ -150,7 +151,7 @@ def test_pad_error():
align=align, shape_arg=shape_arg, layout=layout)

pipe.build()
assert_raises(RuntimeError, pipe.run)
pipe.run()
Copy link
Contributor

Choose a reason for hiding this comment

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

I would keep this check here.

Copy link
Collaborator 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_length_sequence_videopipeline():
pipe = VideoPipe(batch_size=BATCH_SIZE, data=VIDEO_FILES, sequence_length=100000)
assert_raises(RuntimeError, pipe.build)
pipe.build()
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we keep this check here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

list_file.close()

pipe = VideoPipeList(batch_size=BATCH_SIZE, data=list_file.name)
with assert_raises(RuntimeError, glob='*No files were read'):
Copy link
Contributor

Choose a reason for hiding this comment

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

I would improve video_loader error message in this case as we discussed offline.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As we agreed, the warning about empty range, that is already there, should be enough

yield _test_file_list_invalid_range, r[0], r[1]


def test_file_list_empty():
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
def test_file_list_empty():
def test_file_list_empty_range():

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

Comment on lines 233 to 235
@raises(TypeError, glob='*`input_datasets` must be a dictionary that maps input names (the `name` specified for External '
'Source node in DALI pipeline) to input datasets objects (`tf.data.Dataset`) or '
'`nvidia.dali.plugin.tf.experimental.Input` wrapper objects*')
Copy link
Contributor

Choose a reason for hiding this comment

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

Likewise, you don't have to put the entire message here - and you can skip leading and trailing *.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I shortened the patterns to the essential part

Signed-off-by: Rafal <Banas.Rafal97@gmail.com>
@banasraf
Copy link
Collaborator Author

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [3063756]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [3063756]: BUILD FAILED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [3063756]: BUILD PASSED

@banasraf banasraf merged commit 520e3ab into NVIDIA:main Sep 27, 2021
cyyever pushed a commit to cyyever/DALI that referenced this pull request Oct 17, 2021
Add error message checks and fix some TF tests.

Signed-off-by: Rafal <Banas.Rafal97@gmail.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
Add error message checks and fix some TF tests.

Signed-off-by: Rafal <Banas.Rafal97@gmail.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
Add error message checks and fix some TF tests.

Signed-off-by: Rafal <Banas.Rafal97@gmail.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
Add error message checks and fix some TF tests.

Signed-off-by: Rafal <Banas.Rafal97@gmail.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
Add error message checks and fix some TF tests.

Signed-off-by: Rafal <Banas.Rafal97@gmail.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
Add error message checks and fix some TF tests.

Signed-off-by: Rafal <Banas.Rafal97@gmail.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
Add error message checks and fix some TF tests.

Signed-off-by: Rafal <Banas.Rafal97@gmail.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
Add error message checks and fix some TF tests.

Signed-off-by: Rafal <Banas.Rafal97@gmail.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
Add error message checks and fix some TF tests.

Signed-off-by: Rafal <Banas.Rafal97@gmail.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
Add error message checks and fix some TF tests.

Signed-off-by: Rafal <Banas.Rafal97@gmail.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
Add error message checks and fix some TF tests.

Signed-off-by: Rafal <Banas.Rafal97@gmail.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
Add error message checks and fix some TF tests.

Signed-off-by: Rafal <Banas.Rafal97@gmail.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
Add error message checks and fix some TF tests.

Signed-off-by: Rafal <Banas.Rafal97@gmail.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
Add error message checks and fix some TF tests.

Signed-off-by: Rafal <Banas.Rafal97@gmail.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Feb 21, 2022
Add error message checks and fix some TF tests.

Signed-off-by: Rafal <Banas.Rafal97@gmail.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request May 13, 2022
Add error message checks and fix some TF tests.

Signed-off-by: Rafal <Banas.Rafal97@gmail.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jun 7, 2022
Add error message checks and fix some TF tests.

Signed-off-by: Rafal <Banas.Rafal97@gmail.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.

5 participants