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

Draft: Feature: Handling out of date workfiles in Blender #4176

Conversation

Sharkitty
Copy link
Contributor

Draft: This PR depends on this other PR: #4102

Description

Added warning and validator when workfile is out of file (in Blender).
The warning shows up as a props dialog that user cannot ignore as it will be reinvoked on cancel (So if they click anywhere outside of the dialog, it reappears). This props dialog has an enum to select what action to perform, then they can click "OK" to execute.

There are three actions provided:

  • Download last workfile
  • Quit blender
  • Proceed anyway

There is also a variable set when the workfile has been detected as out of date. The validator checks it, so if user decide to proceed anyway, they won't be able to publish, unless they explicitly untick this box.
A warning sign will appear next to the OpenPype menu as well, and there is also an Update workfile button in the OpenPype menu, which is grayed out if the workfile is up to date.
This system however presents a limitation: As the workfile is determined as up to date, or out of date based on modification time, if it is modified and saved then it will always be considered up to date. This brings a few unwanted behavior. For instance if the users proceeds anyway, then closes blender, as the file is saved when making paths absolute, it will always be considered up to date from now on.

Testing

General

  • Have a local workfile (blender) with its datetime older than the last published workfile
  • Open it in blender using OpenPype launcher
  • Notice the props dialog popping, try to click somewhere else and see that it reappears whatever you do
  • Select an option in the enum and click ok to test it.

Download last workfile using the props dialog

  • Select Download last workfile in the enum and click ok
  • The last workfile should now download and be automatically opened, with the correct version number
  • Confirm props dialog does not reopen
  • Confirm OpenPype menu does not have a warning sign
  • Confirm Update workfile in the OpenPype menu is grayed out
  • Open pyblish and do a publish test (at least test the validators)

Quit blender using props dialog

  • Select Quit blender in the enum and click ok
  • Blender should close

Proceed anyway

  • Select proceed anyway in the enum and click ok
  • You should now be able to work
  • OpenPype menu should have a warning sign
  • Try to publish, the workfile up to date validator should fail
  • Reset pyblish, untick the workfile up to date validator, and do a publish test again (at least test validators)
  • Confirm Update workfile is available in the OpenPype menu and has the same behavior as the Download last workfile option in the props dialog

Workfile is up to date case

  • Confirm props dialog does not display
  • Confirm OpenPype menu should does not have a warning sign
  • Confirm Update workfile in the OpenPype menu is grayed out
  • Confirm you can publish (at least test validators)

Tilix4 and others added 12 commits November 17, 2022 16:06
* Enhancement: copy last published workfile as reusable methods (WiP)

* Added get_host_extensions method, added subset_id and las_version_doc access, added optional arguments to get_last_published_workfile

* Plugged in the new methods + minor changes

* Added docstrings, last workfile optional argument, and removed unused code

* Using new implementation to get local workfile path. Warning: It adds an extra dot to the extension which I need to fix

* Refactoring and fixed double dots

* Added match subset_id and get representation method, plus clan up

* Removed unused vars

* Fixed some rebasing errors

* delinted unchanged code and renamed get_representation into get_representation_with_task

* This time it's really delinted, I hope...

* Update openpype/modules/sync_server/sync_server.py

reprenation isn't the right spelling (:

Co-authored-by: Félix David <felixg.david@gmail.com>

* Changes based on reviews

* Fixed non imperative docstring and missing space

* Fixed another non imperative docstring

* Update openpype/modules/sync_server/sync_server.py

Fixed typo

Co-authored-by: Félix David <felixg.david@gmail.com>

Co-authored-by: Hayley GUILLOT <hayleyguillot@outlook.com>
Co-authored-by: Félix David <felixg.david@gmail.com>
from openpype.lib import Logger
from openpype.lib.local_settings import get_local_site_id
from openpype.modules.base import ModulesManager
from openpype.pipeline import Anatomy
Copy link
Member

@iLLiCiTiT iLLiCiTiT Dec 5, 2022

Choose a reason for hiding this comment

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

This is public definition of sync server which must be at this moment Python 2 compatible and should be clear without pipeline imports if possible. Sorry not true, this is not in public part.

BTW Even I understand the use case I don't think those functions should be called directly from blender as blender workflow is now dependent on sync server in it's core (which is not good). He should find if there is sync server addon, if it's enabled, and then call a method which does all the logic and return or raise result, but blender should not know anything about how it works (whole content of DownloadLastWorkfile). If anything changes how sync server works (and it will soon) Blender will break too so he should know almost nothing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I see what you mean. I'll edit my implementation.


Returns:
None: This is a void method.
"""

sync_server = self.modules_manager.get("sync_server")
Copy link
Member

Choose a reason for hiding this comment

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

So if sync server is not available or enabled it will happen anyway?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This part comes from #4102 (which this PR depends on) so I think it's more appropriate to discuss it in #4102
But to answer your question the check still exists it's just been moved to download_last_published_workfile in sync_server.py

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think these kind of checks must remain in hooks to have explicit logging.

Copy link
Collaborator

@Tilix4 Tilix4 left a comment

Choose a reason for hiding this comment

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

Works fine, good job! (even if I'll review it after #4102 is merged and your branch will be rebased)

Doesn't work when local settings are both on studio. It holds forever.

from openpype.hosts.blender.api.workio import current_file


def is_work_file_out_of_date() -> bool:

This comment was marked as resolved.

Comment on lines 450 to 452
("DL", "Download last workfile", "Download last workfile"),
("QUIT", "Quit blender", "Quit blender"),
("PROC", "Proceed anyway", "Proceed anyway AT YOUR OWN RISK"),

This comment was marked as resolved.

return self.execute(context)


class DrawWorkFileOutOfDateWarning(bpy.types.Operator):

This comment was marked as resolved.

project_name, subset_id, fields=["_id", "name"]
)
if not last_version_doc:
print("Subset does not have any version")

This comment was marked as resolved.

openpype/hooks/pre_copy_last_published_workfile.py Outdated Show resolved Hide resolved
@antirotor antirotor added host: Blender type: enhancement Enhancements to existing functionality labels Dec 7, 2022
openpype/hosts/blender/api/ops.py Outdated Show resolved Hide resolved
bl_idname = "wm.workfile_out_of_date"
bl_label = "WARNING: Workfile is out of date"

action_enum: bpy.props.EnumProperty(
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd rename it simply "action"

openpype/hosts/blender/api/pipeline.py Outdated Show resolved Hide resolved
openpype/hosts/blender/api/pipeline.py Outdated Show resolved Hide resolved

# Getting date and time of the latest locally installed workfile
# Time is converted to use the same format as for `last_publishd_time`
workfile_time = get_timestamp(
Copy link
Collaborator

Choose a reason for hiding this comment

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

You better keep the value of the last publish time in a bpy.props.StringProperty or maybe in a FloatProperty to have fewer conversions.

@LiborBatek
Copy link
Member

@Tilix4 is it already ok to test it / review it?

Hayley GUILLOT and others added 8 commits December 20, 2022 15:29
…k implementation. Using blender self.report, changing ops prefixes, changing enum short names, added sync_server availability check.
Co-authored-by: Félix David <felixg.david@gmail.com>
Using context passed as argument

Co-authored-by: Félix David <felixg.david@gmail.com>
Renamed `is_work_file_out_of_date` into `check_workfile_up_to_date`

Co-authored-by: Félix David <felixg.david@gmail.com>
Fixed typo in comment

Co-authored-by: Félix David <felixg.david@gmail.com>
…r StringProperty, applied check_workfile_up_to_date renaming, added no published workfile exception
@Sharkitty Sharkitty force-pushed the ft_blender_workfile_out_of_date_handling branch from a72b1f8 to f369486 Compare December 20, 2022 14:29
Copy link
Member

@LiborBatek LiborBatek left a comment

Choose a reason for hiding this comment

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

Did all testing with following findings...

  1. Pop up win shows up when out of date workfile being present
    B3d_OutdatedWorkfile_01

  2. when selecting Proceed option , OP menu shows out of date workfile warning and Publish validator will fail correctly...
    B3d_OutdatedWorkfile_02
    B3d_OutdatedWorkfile_03

  3. when selecting "Download workfile" blender freezes instantly (I guess its because absence of Sync Server on my machine or?!

B3d_OutdatedWorkfile_04

  1. When correct up-to-date workfile exists in asset workfile folder the win pop up doesnt show up as expected and also OP menu doesnt have that workfile warning and all behaves normally in Blender.

B3d_OutdatedWorkfile_05

So my only concern is about that "download workfile" feature and how should I test it so its properly synced/downloaded... other than that all seems working fine.

openpype/hosts/blender/api/ops.py Outdated Show resolved Hide resolved
local_workfile_path,
)

return local_workfile_path
Copy link
Collaborator

Choose a reason for hiding this comment

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

In fact, download_last_published_workfile shouldn't return the local path but the last published wf which has been downloaded. The resolving of the local_workfile_path must be put into another function and the copy made my the master process or into a utility function.

Co-authored-by: Félix David <felixg.david@gmail.com>
Hayley GUILLOT and others added 9 commits January 25, 2023 13:16
…to 'studio/ft_blender_workfile_out_of_date_handling'

Enhancement: workfile out of date check no longer uses modification time.

See merge request NORMAAL/openpype-for-normaal!28
calling the check for update operator. Also fixed missing return value
in the check for update operator, when user selects "Quit blender".
Feature: Blender update button in OP menu
@Sharkitty Sharkitty closed this Jun 6, 2023
@ynbot ynbot added this to the next-patch milestone Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

7 participants