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

Make nesting conditionals supported only for Python 3.7+ #4888

Merged
merged 11 commits into from
Jun 2, 2023

Conversation

awolant
Copy link
Contributor

@awolant awolant commented Jun 1, 2023

Category:

Bug fix

Description:

dm-tree is not supported in Python 3.6. This PR makes this dependency and the feature it is required for conditional and available only for Python 3.7+.

Key points relevant for the review:

Did I run CI for Python 3.6? Did I run the CI for other Python versions?

Tests:

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

Checklist

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>
@dali-automaton
Copy link
Collaborator

CI MESSAGE: [8488829]: BUILD STARTED

@stiepan stiepan self-assigned this Jun 1, 2023
@JanuszL JanuszL self-assigned this Jun 1, 2023
@mzient mzient assigned mzient and unassigned stiepan Jun 1, 2023
@dali-automaton
Copy link
Collaborator

CI MESSAGE: [8488829]: BUILD FAILED

@@ -533,7 +533,7 @@ def if_stmt(self, cond, body, orelse, get_state, set_state, symbol_names, nouts)
" same set of keys, the values may be different.\n")

try:
tree.assert_same_structure(body_outputs, orelse_outputs, check_types=True)
nest.assert_same_structure(body_outputs, orelse_outputs, check_types=True)
Copy link
Contributor

@JanuszL JanuszL Jun 1, 2023

Choose a reason for hiding this comment

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

Suggested change
nest.assert_same_structure(body_outputs, orelse_outputs, check_types=True)
nest.assert_same_structure(body_outputs, orelse_outputs)

I think it may not be needed here as nifty_nesting doesn't support that arg in this call.

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [8496068]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [8496068]: BUILD FAILED

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 changed the title Change dm-tree to nifty-nesting to fix Python 3.6 support Make nesting conditionals supported only for Python 3.7+ Jun 2, 2023
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this file I used check_nesting_support to disable the tests if the feature is not supported.

@awolant awolant requested review from mzient and JanuszL June 2, 2023 06:44
return False


if check_nesting_support():
Copy link
Contributor

Choose a reason for hiding this comment

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

As I understand this turns off the conditional execution for python3.6 now, right?
I'm afraid we cannot do that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does not. As I stated in the comments for Python 3.6 I pasted old implementation of this.

Copy link
Contributor Author

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.

Oh. There is else branch. Hard to spot it. Maybe there should be an another module, called legacy and we should import either one or the second to avoid messing up with code?

_conditionals.py:

if check_nesting_support():
    from _conditionals_new import *
else:
    from _conditionals_legacy import *
    # print waring about lack of support for nested data strucutres

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

@JanuszL JanuszL self-requested a review June 2, 2023 07:02
Signed-off-by: Albert Wolant <awolant@nvidia.com>
Comment on lines +575 to +578
# if a_val:
# and_output = b()
# else:
# and_output = a_val

Check notice

Code scanning / CodeQL

Commented-out code

This comment appears to contain commented-out code.
Comment on lines +601 to +604
# if a_val:
# or_output = a_val
# else:
# or_output = b()

Check notice

Code scanning / CodeQL

Commented-out code

This comment appears to contain commented-out code.
Comment on lines +549 to +552
# if a_val:
# and_output = b()
# else:
# and_output = a_val

Check notice

Code scanning / CodeQL

Commented-out code

This comment appears to contain commented-out code.
Comment on lines +575 to +578
# if a_val:
# or_output = a_val
# else:
# or_output = b()

Check notice

Code scanning / CodeQL

Commented-out code

This comment appears to contain commented-out code.
Signed-off-by: Albert Wolant <awolant@nvidia.com>
Signed-off-by: Albert Wolant <awolant@nvidia.com>
@stiepan stiepan self-assigned this Jun 2, 2023
Signed-off-by: Albert Wolant <awolant@nvidia.com>
Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

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

CodeQL found more than 10 potential problems in the proposed changes. Check the Files changed tab for more details.

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [8505031]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [8505032]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [8505031]: BUILD FAILED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [8505032]: BUILD FAILED

Signed-off-by: Albert Wolant <awolant@nvidia.com>
@dali-automaton
Copy link
Collaborator

CI MESSAGE: [8505806]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [8505807]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [8505806]: BUILD PASSED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [8505807]: BUILD PASSED

@JanuszL JanuszL merged commit fbefa7d into NVIDIA:main Jun 2, 2023
JanuszL added a commit that referenced this pull request Jun 2, 2023
@awolant awolant mentioned this pull request Jun 2, 2023
18 tasks
JanuszL pushed a commit to JanuszL/DALI that referenced this pull request Oct 13, 2023
* dm-tree is not supported in Python 3.6. This PR makes this
  dependency and the feature it requires for conditional
  execution available only for Python 3.7+.

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.

5 participants