Unable to publish PNG

Hello,

something strange is happening. I added a png profile to the tank write node, but when I publish it fails during the upload_version.py step.

here is the error that happens during the png publish:

Traceback (most recent call last):
  File "\\fs1\Tools\Pipeline\flow_toolkit_config_staging\install\app_store\tk-multi-publish2\v2.10.4\python\tk_multi_publish2\api\plugins\publish_plugin_instance.py", line 306, in _handle_plugin_error
    yield
  File "\\fs1\Tools\Pipeline\flow_toolkit_config_staging\install\app_store\tk-multi-publish2\v2.10.4\python\tk_multi_publish2\api\plugins\publish_plugin_instance.py", line 199, in run_publish
    self._hook_instance.publish(settings, item)
  File "\\fs1\Tools\Pipeline\flow_toolkit_config_staging\config\hooks\tk-multi-publish2\tk-nuke\basic\upload_version.py", line 316, in publish
    self.parent.shotgun.upload(
  File "\\fs1\Tools\Pipeline\flow_toolkit_config_staging\install\core\python\tank_vendor\shotgun_api3\shotgun.py", line 2630, in upload
    raise ShotgunError("Path must be a valid file, got '%s'" % path)
tank_vendor.shotgun_api3.shotgun.ShotgunError: Path must be a valid file, got '\path\to\filesequence\that\definitely\exists_v204.%04d.png'

my tk-nuke-writenode.yml file:

# shot
settings.tk-nuke-writenode.shot:
  template_script_work: nuke_shot_work
  show_convert_actions: True
  write_nodes:
  - file_type: exr
    name: Flow Mono Exr, 16 bit
    promote_write_knobs: [ ]
    proxy_publish_template:
    proxy_render_template:
    publish_template: nuke_shot_render_pub_mono_exr
    render_template: nuke_shot_render_mono_exr
    settings:
      datatype: 16 bit half
    tank_type: Rendered Image
    tile_color: [ ]
  - file_type: exr
    name: Flow Mono Exr, 32 bit
    promote_write_knobs: [ ]
    proxy_publish_template:
    proxy_render_template:
    publish_template: nuke_shot_render_pub_mono_exr
    render_template: nuke_shot_render_mono_exr
    settings:
      datatype: 32 bit float
    tank_type: Rendered Image
    tile_color: [ ]
  - file_type: exr
    name: Flow Stereo Exr, 32 bit
    proxy_publish_template:
    proxy_render_template:
    publish_template: nuke_shot_render_pub_stereo
    render_template: nuke_shot_render_stereo
    settings:
      datatype: 32 bit float
    tank_type: Rendered Image
    tile_color: []
    promote_write_knobs: []
  - file_type: exr
    name: Flow Stereo Exr, 16 bit
    promote_write_knobs: []
    proxy_publish_template:
    proxy_render_template:
    publish_template: nuke_shot_render_pub_stereo
    render_template: nuke_shot_render_stereo
    settings:
      datatype: 16 bit half
    tank_type: Rendered Image
    tile_color: []
  - file_type: png
    name: Flow Png, 8 bit
    promote_write_knobs: [ ]
    proxy_publish_template:
    proxy_render_template:
    publish_template: nuke_shot_render_pub_mono_png
    render_template: nuke_shot_render_mono_png
    settings:
      datatype: 8 bit
    tank_type: Image
    tile_color: [ ]
  location: "@apps.tk-nuke-writenode.location"

my templates, the added png ones are at the end:

# write node outputs
nuke_shot_render_mono_exr:
    definition: '@shot_root/work/images/v{version}/{Shot}_{Step}_{nuke.cds_tag}_{nuke.output}_v{version}.{SEQ}.exr'
    root_name: 'renders'
nuke_shot_render_pub_mono_exr:
    definition: '@shot_root/publish/elements/v{version}/{Shot}_{Step}_{nuke.cds_tag}_{nuke.output}_v{version}.{SEQ}.exr'
    root_name: 'renders'

nuke_shot_render_stereo:
    definition: '@shot_root/work/images/v{version}/{Shot}_{Step}_{nuke.cds_tag}_{nuke.output}_{eye}_v{version}.{SEQ}.exr'
    root_name: 'renders'
nuke_shot_render_pub_stereo:
    definition: '@shot_root/publish/elements/v{version}/{Shot}_{Step}_{nuke.cds_tag}_{nuke.output}_{eye}_v{version}.{SEQ}.exr'
    root_name: 'renders'

nuke_shot_render_mono_png:
    definition: '@shot_root/work/images/v{version}/{Shot}_{Step}_{nuke.cds_tag}_{nuke.output}_v{version}.{SEQ}.png'
    root_name: 'renders'
nuke_shot_render_pub_mono_png:
    definition: '@shot_root/publish/elements/v{version}/{Shot}_{Step}_{nuke.cds_tag}_{nuke.output}_v{version}.{SEQ}.png'
    root_name: 'renders'

here’s also some relevant screenshots.

the publish window when publishing an exr file:

vs when publishing a png file. note the “Upload for Review” step that’s not there in the EXR screenshot (its the step that fails):

pt2:

what I think is happening is that toolkit expects a png to be a single item - not a sequence intended to be rendered as an mp4 and uploaded.

im basing that assumption on the File Types list in the upload_version.py script where “png“ is in the “Image“ category instead of “Rendered Image”. The error still happens if I remove png from Image and move it to the Rendered Image category instead .

            "File Types": {
                "type": "list",
                "default": [
                    ["Alias File", "wire"],
                    ["Alembic Cache", "abc"],
                    ["3dsmax Scene", "max"],
                    ["NukeStudio Project", "hrox"],
                    ["Houdini Scene", "hip", "hipnc"],
                    ["Maya Scene", "ma", "mb"],
                    ["Motion Builder FBX", "fbx"],
                    ["Nuke Script", "nk"],
                    ["Photoshop Image", "psd", "psb"],
                    ["VRED Scene", "vpb", "vpe", "osb"],
                    ["Rendered Image", "dpx", "exr"],
                    ["Texture", "tiff", "tx", "tga", "dds"],
                    ["Image", "jpeg", "jpg", "png"],
                    ["Movie", "mov", "mp4"],
                    ["PDF", "pdf"],
                ]

Truly any help is appreciated,

Thank you!

Does this path start with a single or double backslash?
The error is happening when it tries to upload, so truly Python cannot find the file. Thus the publish configuration is not directly relevant (but it may have led to the situation).
You could try to e.g. normalize the path - os.path.normpath(p)
Could you show the entire log dialog, when you click on the red triangle bottom center?

@mmoshev thanks for the suggestion. You’re right that the path starts with two backslashes. but that’s not a problem when publishing the EXRs. Adding os.path.normpath(p)I’m still getting the error.

my change to the upload_version.py hook

        if settings["Upload"].value:
            self.logger.info("Uploading content...")

            # on windows, ensure the path is utf-8 encoded to avoid issues with
            # the shotgun api
            if sgtk.util.is_windows():
                upload_path = sgutils.ensure_text(path)
            else:
                upload_path = path

            upload_path = os.path.normpath(upload_path) # WHAT I ADDED
            
            # this is line 316 from the error log
            self.parent.shotgun.upload(
                "Version", version["id"], upload_path, "sg_uploaded_movie"
            )
        elif thumb:
            # only upload thumb if we are not uploading the content. with
            # uploaded content, the thumb is automatically extracted.
            self.logger.info("Uploading thumbnail...")
            self.parent.shotgun.upload_thumbnail("Version", version["id"], thumb)

        self.logger.info("Upload complete!")

here’s the screenshot of the whole log up until the error.

and the error:

Traceback (most recent call last):
  File "\\fs1\Tools\Pipeline\flow_toolkit_config_staging\install\app_store\tk-multi-publish2\v2.10.4\python\tk_multi_publish2\api\plugins\publish_plugin_instance.py", line 306, in _handle_plugin_error
    yield
  File "\\fs1\Tools\Pipeline\flow_toolkit_config_staging\install\app_store\tk-multi-publish2\v2.10.4\python\tk_multi_publish2\api\plugins\publish_plugin_instance.py", line 199, in run_publish
    self._hook_instance.publish(settings, item)
  File "\\fs1\Tools\Pipeline\flow_toolkit_config_staging\config\hooks\tk-multi-publish2\tk-nuke\basic\upload_version.py", line 316, in publish
    self.parent.shotgun.upload(
  File "\\fs1\Tools\Pipeline\flow_toolkit_config_staging\install\core\python\tank_vendor\shotgun_api3\shotgun.py", line 2630, in upload
    raise ShotgunError("Path must be a valid file, got '%s'" % path)
tank_vendor.shotgun_api3.shotgun.ShotgunError: Path must be a valid file, got '\
\path\to\filesequence\that\definitely\exists_v204.%04d.png'

and for my sanity’s sake here’s my tk-multi-publish2.yml shot step

# shot step
settings.tk-multi-publish2.nuke.shot_step:
  collector: "{self}/collector.py:{config}/tk-multi-publish2/tk-nuke/basic/collector.py"
  collector_settings:
      Work Template: nuke_shot_work
  publish_plugins:
  - name: Publish to Flow Production Tracking
    hook: "{self}/publish_file.py:{config}/tk-multi-publish2/tk-nuke/publish_file.py"
    settings: {}
  - name: Upload for review
    hook: "{self}/upload_version.py:{config}/tk-multi-publish2/tk-nuke/basic/upload_version.py"
    settings: {}
  - name: Begin file versioning
    hook: "{engine}/tk-multi-publish2/basic/nuke_start_version_control.py"
    settings: {}
  - name: Publish to Flow Production Tracking
    hook: "{self}/publish_file.py:{engine}/tk-multi-publish2/basic/nuke_publish_script.py"
    settings:
        Publish Template: nuke_shot_publish
  - name: Submit for Review
    hook: "{engine}/tk-multi-publish2/basic/submit_for_review.py"
    settings: {}
  post_phase: "{config}/tk-multi-publish2/tk-nuke/basic/post_phase.py"
  help_url: *help_url
  location: "@apps.tk-multi-publish2.location"

The double backslash is correct for UNC paths on Windows.

Re-reading your comments - is the png a sequence? If so, there is no file that is %04d.png (or whatever). Instead, you must interpolate the frame number onto the path. So e.g.
path = "test.%04d.png" % 1001
The path with placeholder is called “abstract” in SG parlance. You must make it concrete in order to upload using shotgun.upload()
In short, I think you cannot upload sequences with Submit for Review. If you check line 316, the field is called “sg_uploaded_movie”, it does not expect a sequence.

What we were doing at some point is create a mov using ffmpeg inside upload_version, and upload that.

@mmoshev you’re right about that…

what we’ve decided to do is to just not do png sequences and stick with dwaa compressed exrs. thanks for your help!

With EXRs your main problem remains - you cannot upload an image sequence from upload_version.
Usually sg_path_to_frames is used to point to the frames on disk, instead of uploading them: