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

Publish: register publishes without copying them #4157

Conversation

kalisp
Copy link
Member

@kalisp kalisp commented Dec 1, 2022

Brief description

This PR introduces 'source' publish template which could be used in 'in-place' publish, eg. files are published from their current location without copying them into 'publish' folder.

Description

This kind of publishing helps with massive files as pointcaches or renders when files are already created in proper location. Without copying publish process takes less time.

Additional logic to check that publish path is inside of project data folder (eg. in at least one configured root in Anatomy) to protect from publishing to "my C:/ folder".

!!! ExtractThumbnail* plugins are now adding _thumb suffix to names (my_project_seq02_shot01_renderCompositingMain_v018.1004_thumb.jpg)

Additional details

originalDirname was added to collector for resources, but some subset might be created only during Extract phase, so it was added also into integrate plugin, which might not be optimal. Comments welcomed.

I tested it in DCC with render which ended up in work/.../renders subfolders which doesn't seem too right, as they might be purged (they weren't in Maya and Nuke though).

Testing notes:

  1. Double check that your project has 'source' template filled in project_anatomy/templates/others
    source_template
  2. Configure which hosts and families should use this template in project_settings/global/publish/IntegrateAssetNew or better in project_settings/global/tools/publish/template_name_profiles (see deprecation warning and move template profiles to later location) (I tested in on combination Traypublisher - render and Maya - render
    Screenshot 2022-12-02 144422
  3. In TP it should create representation containing data.path: "URL_OF_DRAGGED_FILE", no new version subfolder should be created in publish folder

Will be used to fill 'source' (and 'online') template.
Source template is used to publish in-situ, eg. without copying possibly massive files (as pointcaches etc.)
Will be used to fill 'source' (and 'online') template.
Added check for publishing to project folder
…P-4504_Publishing-Register-publishes-without-copying-them
CollectSources should run on all hosts whenever some output is expected. It seems to be best location to put parsing of source file, unless we want to create completely new separate plugin.
Adding originalDirname to all hosts could be an ordeal, adding logic here is simpler, but might not be best solution.
@kalisp kalisp self-assigned this Dec 1, 2022
@ynbot
Copy link
Contributor

ynbot commented Dec 1, 2022

Source template is used in-situ publishing, eg. use files at their location, don't copy them anywhere.
@kalisp kalisp added the type: feature Larger, user affecting changes and completely new things label Dec 2, 2022
@kalisp kalisp marked this pull request as ready for review December 2, 2022 13:47
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.

Tested it in Tray Publisher and found strange problem with Extract Thumbnail (from source) - this is producing jpg file from input, but it is placed in staging directory like C:\Users\annat\AppData\Local\Temp\pyblish_tmp_tduppdsg\VFX025_00001.jpg in my testing data.

Now integrator will skip copying it:

WARNING: Destination 'e:/projects/foo/bar/vfx025/vfx_out/v10/vfx025_00001.jpg' is not in project folder. Skipping

but since it is in staging tmp directory it will never be find by integrator when registering.

To wrap it up: We need to handle moving stuff produced during the publishing process that is generated into temporary destinations even if the source template is used.

…e' into feature/OP-4504_Publishing-Register-publishes-without-copying-them
…e' into feature/OP-4504_Publishing-Register-publishes-without-copying-them
# optionals
# retrieve additional anatomy data from representation if exists
if not instance.data.get("originalDirname"):
Copy link
Member

@iLLiCiTiT iLLiCiTiT Dec 6, 2022

Choose a reason for hiding this comment

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

I would say original dirname and basename is representation specific and not instance specific.
EDITED:
The dirname is used for all representations. But I think it should be always set to staging dir from instance and never from representation.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, used instance_stagingdir instead.

@iLLiCiTiT
Copy link
Member

iLLiCiTiT commented Dec 6, 2022

We must be carefull about original basename because thumbnail extractors use same name as source so if .jpeg would be published the thumbnail would "override" the source file. So we should modify thumbnail extractors to add _thumbnail suffix to avoid conflicts with source file.

I'm 90% convinced that template in anatomy should look like {root[work]}/{originalDirname}/{originalBasename}<.{@frame}><_{udim}>.{ext} with the {root[...]} and we should look for exactly the one root. OR if not, then we should "change" the template for representation to contain {root[...]} because of multiplatform support (or potentially site sync if necessary).

Another question is if the originalBasename should not be originalFilename to template would be {root[work]}/{originalDirname}/{originalFilename} without anything else. The original basename is anyway defined by "files" and may can contain the frame already, or?

_rootless = self.get_rootless_path(anatomy, original_directory)
if _rootless == original_directory:
raise KnownPublishError((
"Destination path '{}' ".format(original_directory) +
Copy link

Choose a reason for hiding this comment

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

continuation line over-indented for hanging indent

@kalisp
Copy link
Member Author

kalisp commented Dec 14, 2022

Added explicit collector and validator to check if source file is in project folder.

…P-4504_Publishing-Register-publishes-without-copying-them
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.

it will publish, but during the publishing it does strange things with the name. Here is a piece of log from the integrator:

DEBUG: Source: P:\PROJECTS\OP01_CG_demo\tests\tree-736885_960_720.jpg
DEBUG: Creating new version ...
INFO: Prepared version: v002
DEBUG: Anatomy template name: source
DEBUG: Anatomy template name: source
WARNING: File transfer in queue replaced..
DEBUG: Removed from queue: P:\PROJECTS\OP01_CG_demo\tests\tree-736885_960_720.jpg -> P:\PROJECTS\op01_cg_demo\tests\tree-736885_960_720.jpg.jpg replaced by C:\Users\annat\AppData\Local\Temp\pyblish_tmp_3fx1tx9p\tree-736885_960_720.jpg -> P:\PROJECTS\op01_cg_demo\tests\tree-736885_960_720.jpg.jpg
DEBUG: Anatomy template name: source
INFO: Subset renderAnimationMain and Version 2 written to database..
DEBUG: Integrating source files to destination ...
DEBUG: Copying file ... C:\Users\annat\AppData\Local\Temp\pyblish_tmp_3fx1tx9p\tree-736885_960_720.jpg -> P:\PROJECTS\op01_cg_demo\tests\tree-736885_960_720.jpg.jpg
DEBUG: Copying file ... P:\PROJECTS\OP01_CG_demo\tests\tree-736885_960_720_png.png -> P:\PROJECTS\op01_cg_demo\tests\tree-736885_960_720_png.png.png

Again, note the extensions...

based on this template:
image

openpype/plugins/publish/validate_publish_dir.py Outdated Show resolved Hide resolved
@@ -91,7 +91,7 @@ def process(self, instance):
full_input_path = os.path.join(src_staging, input_file)
self.log.info("input {}".format(full_input_path))
filename = os.path.splitext(input_file)[0]
jpeg_file = filename + ".jpg"
jpeg_file = filename + "_thumb.jpg"
Copy link
Member

@iLLiCiTiT iLLiCiTiT Dec 19, 2022

Choose a reason for hiding this comment

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

I would use full name for suffix.

Suggested change
jpeg_file = filename + "_thumb.jpg"
jpeg_file = filename + "_thumbnail.jpg"

Opinions @antirotor @kalisp @mkolar @jakubjezek001 ?

What about other thumbnail extractors (e.g. in Maya)?

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.

Happy to report that it works as expected!

@kalisp kalisp merged commit 61d255a into develop Jan 9, 2023
@kalisp kalisp deleted the feature/OP-4504_Publishing-Register-publishes-without-copying-them branch January 9, 2023 17:41
@github-actions github-actions bot added this to the next-patch milestone Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature Larger, user affecting changes and completely new things
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants