Tutorial - Publish workflow

Rev 1.005, 23.12.19

How to read this tutorial

Scenario


Your task would be to setup access to a folder here they grab work as assigned and perform their task. When they are done, subcontractor should be able to publish back results directly into the correct folder structure, with metadata that should be saved in production database and relevant notifications. 

Installing accsyn


The following guide is a short summary of the installation process described in detail here: accsyn Admin Manual


By now you have a fully working file transfer solution that can be used by external user to receive and send back large file packages at high speed (i.e. an accelerated encrypted FTP server replacement). We are now going to continue and make file transfers submitted by Python scripts to enable an automised workflow.


Configuring accsyn


Share material to test user


Note: This can be done using the accsyn Python API in an automated way upon task assignment in your production database systems. For hints on how to do this, please check this tutorial: Tutorial - Automated Production Outsourcing.



User will now get an invite, be instructed on how to install desktop application, and be to see share "TO_VENDORS" and folder "test@interpost.com" only within their accsyn. You can now copy work task source data into this folder in order to make it available to subcontractor.


Write pre-publish hook


We are now going to write the first hook out of two, the "job-pre-publish-server" hook as it is named with accsyn. Here is were you can validate the filenames remote user has supplied and return appropriate feedback.

accsyn provides the JSON data in a temporary file and then runs your configured script supplying the path to this data file. It also provides you a path to were you should write the result back in JSON format. This mechanism in Accsyn is called a "hook". 

In this tutorial, during the test, the user will drag-n-drop three files/directories resulting in the following publish data (this would be the data sent if using Python API for publish):

{

    "hook":"job-pre-publish-server",

    "user":"5d87825f045d0352d33435eb",

    "user_hr":"test@interpost.com",

    "files":[

        {

            "id":"96bc4b44-384b-497d-a119-3f07307627b6",

            "filename":"proj_task001_v001",

            "is_dir":true,

            "size":200000,

            "files":[{

                "filename":"image.0001.tif",

                "size":100000

            },

            {

                "filename":"image.0002.tif",

                "size":100000

            }]

        },{

            "id":"44f29351-e870-4f9e-b329-a43759ed35c0",

            "filename":"proj_task1_v001_preview.mov",

            "size":1000

        },{

            "id":"1ff91107-d4d2-4de5-9d87-2b3ed1198e1c",

            "filename":"proj_task001_v001_assets",

            "size":20000,

            "files":[{

                "filename":"proj_task001_projectfile.xml",

                "size":20000

            }]

        }

    ],

    "size":221000

}


The pre-publish Python script need to: 


Using a Python capable text editor such as IDLE++ or Sublime, copy this script from out Github:


https://raw.githubusercontent.com/accsyn/publish-workflow/main/pre_publish.py


The script should be quite self-explanatory if you are familiar with Python. Here follow  some explanations:




Configure pre-publish hook

Now we need to tell accsyn were to find our pre-publish hook script:


Note: Make sure Python3 is installed at the server and that python3 executable is in the PATH, for script to function.


Your accsyn is now ready to accept publishes and have them uploaded into the correct location.

Write publish hook

We now should write the publish hook script that gets execute after the files and directories have been uploaded to your server. This is of course optional and can be omitted if you do not wish to save user input (metadata) or do any other workflow integrations.

Note: These two publish scripts can be combined into one, by for example adding a --pre command line argument or similar.


The data that comes in are identical to to data arriving to your previous pre-publish script, except that user input/metadata has been appended:


https://raw.githubusercontent.com/accsyn/publish-workflow/main/publish.py


Configure publish hook

Now finally we need to tell accsyn were to find our post-publish hook script:

Windows

This tutorial described how to setup publish hooks on Linux/Mac OSX compatible system, this applies to a Windows server based deployment:

Finalising


Finally, we test it:


Your accsyn is now all setup for having your subcontractors become integrated in your workflow, in a safe, fast and user friendly manner! 

Troubleshooting

Any error that occur are displayed in the Job audit logs, log on to your workspace as a an admin and go to Admin>Audit>Job.


Log messages are also output in the accsyn deamon server log: