Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Chore: Create plugin does not expect system settings #5553

Merged
merged 15 commits into from
Sep 5, 2023

Conversation

iLLiCiTiT
Copy link
Member

@iLLiCiTiT iLLiCiTiT commented Sep 1, 2023

Changelog Description

System settings are not passed to initialization of create plugin initialization (and apply_settings).

Additional info

Reasons: The system settings are not used anywhere, and since AYON there won't be 2 types of settings.

We need validation of all Create plugins: They should not use system_settings in apply_settings method and they should not override __init__ method.

To make this PR safer the system settings can still be passed to creator initialization, but eventually it will be removed in future PR anyway, so it would be just temporary backwards compatibility.

This PR must be updated with latest develop and revalidated changes before merge.

Testing notes:

  1. Technically run all available creators in Publisher
  • Traypublisher
  • Maya
  • Nuke
  • AfterEffects
  • Photoshop
  • 3dsMax
  • Houdini
  • TVPaint

@ynbot ynbot added type: enhancement Enhancements to existing functionality size/XS Denotes a PR changes 0-99 lines, ignoring general files labels Sep 1, 2023
Copy link

@hound hound bot left a comment

Choose a reason for hiding this comment

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

Some files could not be reviewed due to errors:

Traceback (most recent call last):
Traceback (most recent call last):
  File "/usr/local/bin/flake8", line 8, in 
    sys.exit(main())
  File "/usr/local/lib/python3.8/dist-packages/flake8/main/cli.py", line 18, in main
    app.run(argv)
  File "/usr/local/lib/python3.8/dist-packages/flake8/main/application.py", line 393, in run
    self._run(argv)
  File "/usr/local/lib/python3.8/dist-packages/flake8/main/application.py", line 381, in _run
    self.run_checks()
  File "/usr/local/lib/python3.8/dist-packages/flake8/main/application.py", line 300, in run_checks
    self.file_checker_manager.run()
  File "/usr/local/lib/python3.8/dist-packages/flake8/checker.py", line 331, in run
    self.run_serial()
  File "/usr/local/lib/python3.8/dist-packages/flake8/checker.py", line 315, in run_serial
    checker.run_checks()
  File "/usr/local/lib/python3.8/dist-packages/flake8/checker.py", line 598, in run_checks
    self.run_ast_checks()
  File "/usr/local/lib/python3.8/dist-packages/flake8/checker.py", line 502, in run_ast_checks
    for (line_number, offset, text, check) in runner:
  File "/usr/local/lib/python3.8/dist-packages/flake8_django/checker.py", line 56, in run
    parser.visit(self.tree)
  File "/usr/lib/python3.8/ast.py", line 371, in visit
    return visitor(node)
  File "/usr/lib/python3.8/ast.py", line 379, in generic_visit
    self.visit(item)
  File "/usr/local/lib/python3.8/dist-packages/flake8_django/checker.py", line 39, in visit_ClassDef
    self.capture_issues_visitor('ClassDef', node)
  File "/usr/local/lib/python3.8/dist-packages/flake8_django/checker.py", line 33, in capture_issues_visitor
    self.generic_visit(node)
  File "/usr/lib/python3.8/ast.py", line 381, in generic_visit
    self.visit(value)
  File "/usr/local/lib/python3.8/dist-packages/flake8_django/checker.py", line 36, in visit_Call
    self.capture_issues_visitor('Call', node)
  File "/usr/local/lib/python3.8/dist-packages/flake8_django/checker.py", line 30, in capture_issues_visitor
    issues = checker.run(node)
  File "/usr/local/lib/python3.8/dist-packages/flake8_django/checkers/render.py", line 22, in run
    if isinstance(arg, ast.Call) and arg.func.id == 'locals':
AttributeError: 'Attribute' object has no attribute 'id'

@BigRoy
Copy link
Collaborator

BigRoy commented Sep 1, 2023

Unfortunately I did end up using system_settings on our end for a Deadline creator plug-in.

See here to use it here

See here to use it here.

Correction: These are not actually creator plug-ins - but they are publishing plug-ins. Does this PR affect those too? Looking at the changed files it doesn't but I'm assuming a PR for that might be incoming too? So it'd be good to maybe figure out how to solve the issue I describe below for both cases.

Any good ideas on how I could still optimally retrieve our globally define deadline URL - since the project settings URL just picks one by name from the Module Settings? The only thing I can think of is that if in the apply_settings I'd initialize a ModuleManager I could access deadline_module.deadline_urls but I'd still need to do that per plug-in to get the instantiated modules at the time of apply_settings so I couldn't get it from a module instance either without this becoming slow.


Also, since this is a backwards incompatible change for external code bases (e.g. anyone having a custom new style creator using apply_settings) it might be good to merge this into a next minor release maybe with a clear note in the changelog?

@iLLiCiTiT
Copy link
Member Author

iLLiCiTiT commented Sep 1, 2023

Does this PR affect those too?

No.

Looking at the changed files it doesn't but I'm assuming a PR for that might be incoming too?

Publish plugins already have changed code to allow expect only project settings, but it is "less radical" there, because system settings are still used, which won't change until full AYON release.
I've chose more radical approach in create plugins, because I didn't find any usage of them anywhere and couldn't think of the usage...

Also, since this is a backwards incompatible change for external code bases (e.g. anyone having a custom new style creator using apply_settings) it might be good to merge this into a next minor release maybe with a clear note in the changelog?

I would rather change it to be more backwards compatible than wait for next-minor, last next-minor took more than 6 months.

EDITED: But I don't think it would break anything. System settings does not contain much relevant information for create plugins.

@BigRoy
Copy link
Collaborator

BigRoy commented Sep 1, 2023

For Create plug-ins I'm personally fine with removing it - I'd just need to sync up potential custom creators but if it's clear WHEN I should be doing that then I'm totally fine with it. It's a trivial change. Plus it moves the cleanup to now instead of pushing it into future for forever.

Copy link

@hound hound bot left a comment

Choose a reason for hiding this comment

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

Some files could not be reviewed due to errors:

Traceback (most recent call last):
Traceback (most recent call last):
  File "/usr/local/bin/flake8", line 8, in 
    sys.exit(main())
  File "/usr/local/lib/python3.8/dist-packages/flake8/main/cli.py", line 18, in main
    app.run(argv)
  File "/usr/local/lib/python3.8/dist-packages/flake8/main/application.py", line 393, in run
    self._run(argv)
  File "/usr/local/lib/python3.8/dist-packages/flake8/main/application.py", line 381, in _run
    self.run_checks()
  File "/usr/local/lib/python3.8/dist-packages/flake8/main/application.py", line 300, in run_checks
    self.file_checker_manager.run()
  File "/usr/local/lib/python3.8/dist-packages/flake8/checker.py", line 331, in run
    self.run_serial()
  File "/usr/local/lib/python3.8/dist-packages/flake8/checker.py", line 315, in run_serial
    checker.run_checks()
  File "/usr/local/lib/python3.8/dist-packages/flake8/checker.py", line 598, in run_checks
    self.run_ast_checks()
  File "/usr/local/lib/python3.8/dist-packages/flake8/checker.py", line 502, in run_ast_checks
    for (line_number, offset, text, check) in runner:
  File "/usr/local/lib/python3.8/dist-packages/flake8_django/checker.py", line 56, in run
    parser.visit(self.tree)
  File "/usr/lib/python3.8/ast.py", line 371, in visit
    return visitor(node)
  File "/usr/lib/python3.8/ast.py", line 379, in generic_visit
    self.visit(item)
  File "/usr/local/lib/python3.8/dist-packages/flake8_django/checker.py", line 39, in visit_ClassDef
    self.capture_issues_visitor('ClassDef', node)
  File "/usr/local/lib/python3.8/dist-packages/flake8_django/checker.py", line 33, in capture_issues_visitor
    self.generic_visit(node)
  File "/usr/lib/python3.8/ast.py", line 381, in generic_visit
    self.visit(value)
  File "/usr/local/lib/python3.8/dist-packages/flake8_django/checker.py", line 36, in visit_Call
    self.capture_issues_visitor('Call', node)
  File "/usr/local/lib/python3.8/dist-packages/flake8_django/checker.py", line 30, in capture_issues_visitor
    issues = checker.run(node)
  File "/usr/local/lib/python3.8/dist-packages/flake8_django/checkers/render.py", line 22, in run
    if isinstance(arg, ast.Call) and arg.func.id == 'locals':
AttributeError: 'Attribute' object has no attribute 'id'

@iLLiCiTiT
Copy link
Member Author

Added backwards compatibility, System settings are still passed to Create plugin. A warning message is logged if __init__ is overriden or apply_settings still expect system_settings.

Copy link

@hound hound bot left a comment

Choose a reason for hiding this comment

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

Some files could not be reviewed due to errors:

Traceback (most recent call last):
Traceback (most recent call last):
  File "/usr/local/bin/flake8", line 8, in 
    sys.exit(main())
  File "/usr/local/lib/python3.8/dist-packages/flake8/main/cli.py", line 18, in main
    app.run(argv)
  File "/usr/local/lib/python3.8/dist-packages/flake8/main/application.py", line 393, in run
    self._run(argv)
  File "/usr/local/lib/python3.8/dist-packages/flake8/main/application.py", line 381, in _run
    self.run_checks()
  File "/usr/local/lib/python3.8/dist-packages/flake8/main/application.py", line 300, in run_checks
    self.file_checker_manager.run()
  File "/usr/local/lib/python3.8/dist-packages/flake8/checker.py", line 331, in run
    self.run_serial()
  File "/usr/local/lib/python3.8/dist-packages/flake8/checker.py", line 315, in run_serial
    checker.run_checks()
  File "/usr/local/lib/python3.8/dist-packages/flake8/checker.py", line 598, in run_checks
    self.run_ast_checks()
  File "/usr/local/lib/python3.8/dist-packages/flake8/checker.py", line 502, in run_ast_checks
    for (line_number, offset, text, check) in runner:
  File "/usr/local/lib/python3.8/dist-packages/flake8_django/checker.py", line 56, in run
    parser.visit(self.tree)
  File "/usr/lib/python3.8/ast.py", line 371, in visit
    return visitor(node)
  File "/usr/lib/python3.8/ast.py", line 379, in generic_visit
    self.visit(item)
  File "/usr/local/lib/python3.8/dist-packages/flake8_django/checker.py", line 39, in visit_ClassDef
    self.capture_issues_visitor('ClassDef', node)
  File "/usr/local/lib/python3.8/dist-packages/flake8_django/checker.py", line 33, in capture_issues_visitor
    self.generic_visit(node)
  File "/usr/lib/python3.8/ast.py", line 381, in generic_visit
    self.visit(value)
  File "/usr/local/lib/python3.8/dist-packages/flake8_django/checker.py", line 36, in visit_Call
    self.capture_issues_visitor('Call', node)
  File "/usr/local/lib/python3.8/dist-packages/flake8_django/checker.py", line 30, in capture_issues_visitor
    issues = checker.run(node)
  File "/usr/local/lib/python3.8/dist-packages/flake8_django/checkers/render.py", line 22, in run
    if isinstance(arg, ast.Call) and arg.func.id == 'locals':
AttributeError: 'Attribute' object has no attribute 'id'

Copy link
Member

@jakubjezek001 jakubjezek001 left a comment

Choose a reason for hiding this comment

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

Nuke and TrayPublisher tested and worked normally

Copy link
Member

@antirotor antirotor left a comment

Choose a reason for hiding this comment

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

Creators in Maya, Houdini, 3dsmax and Blender works

Copy link
Member

@kalisp kalisp left a comment

Choose a reason for hiding this comment

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

Tested in PS, AE, works.

@kalisp kalisp assigned iLLiCiTiT and unassigned kalisp Sep 5, 2023
@iLLiCiTiT iLLiCiTiT merged commit 2b2209c into develop Sep 5, 2023
@iLLiCiTiT iLLiCiTiT deleted the enhancement/remove-system-settings-requirement branch September 5, 2023 10:00
@ynbot ynbot added this to the next-patch milestone Sep 5, 2023
Comment on lines +217 to +218
init_overriden = self.__class__.__init__ is not BaseCreator.__init__
if init_overriden or expect_system_settings:
Copy link
Collaborator

@BigRoy BigRoy Sep 5, 2023

Choose a reason for hiding this comment

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

Ok, so this warning is now always logged for all classes inheriting from the new Creator due to the Creator class already overriding __init__.

image

I guess we'll need to hotfix?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

6 participants