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

Nuke: improving readability #2903

Merged
merged 5 commits into from
Mar 24, 2022

Conversation

jakubjezek001
Copy link
Member

Brief description

Code was too complex to read

Testing notes:

  1. configure project_settings/nuke/publish/ExtractReviewDataMov/outputs to have multiple presets with use of filters
  2. open your testing nuke script
  3. publish render write node

@jakubjezek001 jakubjezek001 self-assigned this Mar 17, 2022
@jakubjezek001 jakubjezek001 added host: Nuke type: enhancement Enhancements to existing functionality labels Mar 17, 2022
@jakubjezek001 jakubjezek001 changed the title nuke: making better readability nuke: improving readability Mar 17, 2022
@BigRoy
Copy link
Collaborator

BigRoy commented Mar 17, 2022

I agree with @iLLiCiTiT this comment is likely the best format. Which makes it something like this:

# please consider example as pseudocode - untested
...

                # process only allowed families
                if f_families:
                    if set(families).intersection(f_families):
                        continue

                # process only allowed task types
                if f_task_types:
                    if task_type in f_task_types:
                        continue
                        
                # process only subsets matching patterns
                if f_subsets:
                    if any(re.search(pattern, subset) 
                           for pattern in f_subsets)):
                       continue

I believe above logic says that if it matches any of the filters then they are continued and excluded which might be the opposite of what you'd need? :D

This also means the lines below it where you check all can be removed:

                # we need all filters to be positive for this
                # preset to be activated
                test_all = all([
                    test_families,
                    test_task_types,
                    test_subsets
                ])

                # if it is not positive then skip this preset
                if not test_all:
                    continue

@jakubjezek001
Copy link
Member Author

I agree with @iLLiCiTiT this comment is likely the best format. Which makes it something like this:

# please consider example as pseudocode - untested
...

                # process only allowed families
                if f_families:
                    if set(families).intersection(f_families):
                        continue

                # process only allowed task types
                if f_task_types:
                    if task_type in f_task_types:
                        continue
                        
                # process only subsets matching patterns
                if f_subsets:
                    if any(re.search(pattern, subset) 
                           for pattern in f_subsets)):
                       continue

I believe above logic says that if it matches any of the filters then they are continued and excluded which might be the opposite of what you'd need? :D

This also means the lines below it where you check all can be removed:

                # we need all filters to be positive for this
                # preset to be activated
                test_all = all([
                    test_families,
                    test_task_types,
                    test_subsets
                ])

                # if it is not positive then skip this preset
                if not test_all:
                    continue

Brilliant! Thank you @BigRoy . Code looks and reads much better this way ;)

jakubjezek001 and others added 2 commits March 18, 2022 14:04
- adding family to testing families
- adding debug logging for filtering
@mkolar mkolar changed the title nuke: improving readability Nuke: improving readability Mar 18, 2022
@jakubjezek001 jakubjezek001 merged commit 406247a into develop Mar 24, 2022
@jakubjezek001 jakubjezek001 deleted the feature/nuke-improve-code-readebility branch March 24, 2022 13:35
@mkolar mkolar added this to the next milestone Apr 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
host: Nuke type: enhancement Enhancements to existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants