Jump to content

custom location is created, but ftrack does not publish to this location


Nikolay Skolkov

Recommended Posts

Hi

I'm trying to create custom location as described in this webinar but something goes wrong

ftrack connect starts normally and Location is created - I can see it on ftrack web page....

I've set priority to -100 (as it's been said in webinar) so it must be the first location where ftrack should write file... but it doesn't

and there is no  "Transfer component(s)" action on asset's page.... 

 

here is my script. It does not differ much from that one in webinar video

import os
import sys
import functools
import logging
import getpass
import ftrack_api
import ftrack_api.accessor.disk as _disk
import ftrack_api.structure.standard as _standart

logger = logging.getLogger(
    'ftrack user location'
)
LOCATION_NAME = 'nik.local'
DISK_PREFIX = 'D:\jobs'

def configure_location(session,event):
    #session = event['data']['session']
    location = session.ensure('Location',
        {
            'name':LOCATION_NAME
        }
    )
    location.accessor = _disk.DiskAccessor(prefix=DISK_PREFIX)
    location.structure = _standart.StandardStructure()
    location.priority = -100
    logger.warning(
        u'Registering using location {0} @ {1} with priority {2}'.format(LOCATION_NAME,DISK_PREFIX,location.priority)
    )
    


def register(api_object,**kw):
    if not isinstance(api_object,ftrack_api.Session):
        return
    
    if not os.path.exists(DISK_PREFIX) or not os.path.isdir(DISK_PREFIX):
        logger.error('disk prefix does not exist')
        return
    
    api_object.event_hub.subscribe('topic=ftrack.api.session.configure-location',
        functools.partial(configure_location,api_object)
    )

image.thumb.png.f45bb1c154c9656a5a57d245c3ad82d1.png

Link to comment
Share on other sites

Hi @Nikolay Skolkov

assuming your code is reacheable by PYTHONPATH and FTRACK_EVENT_PLUGIN_PATH (or installed as plugin in connect as by our example) and the storage scenario is disabled, you can ensure the location is properly setup calling from api : session.pick_location() if this returns a location entity , you can then check whether the location.accessor and location.structure points are not set to None.

Note the transfer component is a separate code from the Location itself , you can find it as part of another example.

You can find more information on how location works on our api documentation.
Hope it helps.

Cheers.
L.

Link to comment
Share on other sites

yes it is reachable both in PYTHONPATH and FTRACK_EVENT_PLUGIN_PATH

when I disable storage scenario I get this in my DCCimage.thumb.png.886f7259d4530ca51572b2f330a75bad.png

 

i also run script outside my DCC and it seems like my location does exist

import ftrack_api as ftr
session = ftr.Session(server_url='https://XXX.ftrackapp.com',api_key='XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',api_user='XXXXXXXXX')
q = session.query('Location where name is "nik.local"').one()
print(q.accessor)
print(q.structure)

===============response====>>>>
PS C:\krab> & "c:/Program Files/Side Effects Software/Houdini 19.0.657/python37/python3.7.exe" c:/krab/ft.py
Registering using location nik.local @ D:\jobs\ with priority -100
<ftrack_api.accessor.disk.DiskAccessor object at 0x000002166D0E5948>
<ftrack_api.structure.standard.StandardStructure object at 0x000002166CC65108>
PS C:\krab>

 

Link to comment
Share on other sites

but inside DCC(houdini) I get this

>>> session = ftrack_api.Session()
>>> loc = session.query('Location where name is "nik.local"')
>>> loc = session.query('Location where name is "nik.local"').one()
>>> print(loc.accessor)
NOT_SET
>>> print(loc.structure)
NOT_SET

 just to ensure that session is correct 

>>> loc = session.query('Project where name is "napo"').one()
>>> print(loc)
<Project(36473c44-7cf2-11eb-a32d-861b18b6aec9)>
>>> print(loc.items)
<bound method Entity.items of <dynamic ftrack Project object 2065106400>>
>>> print(loc['name'])
napo
>>> print(loc['full_name'])
Napo (Animation demo)

and ... just in case... i'm testing this on trial account if it does matter

 

 

Link to comment
Share on other sites

Hi @Nikolay Skolkov
it does make sense the behaviour you are seeying as you need to have the location registered when the application start.
Please have a look at this custom location for the other events you want to subscribe to.

namely : 

* 'topic=ftrack.connect.application.launch'
* 'topic=ftrack.action.launch'


This is because when application starts all the environment variables are reset to ensure the application start from a clean slate and these events, re inject the modules in the application.

hope it helps.
 

Link to comment
Share on other sites

here is my code . it is almost the same as in the first message

just summarize problem : it works when publishing from ftrack connect application - it writes to my local location

DCC keeps writing data to server....

neither accessor or structure properties for this location are not defined in DCC. probably i need subscribe to application-launch event, but I haven't managed to do that....i just tried to copy-paste subscription on configure-location event ... but it didn't work

import os
import sys
import functools
import logging
import getpass
import ftrack_api
import ftrack_api.accessor.disk as _disk
import ftrack_api.structure.standard as _standart

logger = logging.getLogger(
    'ftrack user location'
)
LOCATION_NAME = 'nik.local'
DISK_PREFIX = 'D:\\jobs\\'

def configure_location(session,event):
    
    location = session.ensure('Location',
        {
            'name':LOCATION_NAME
        }
    )
    location.accessor = _disk.DiskAccessor(prefix=DISK_PREFIX)
    location.structure = _standart.StandardStructure()
    location.priority = -100
    logger.warning(
        u'Registering using location {0} @ {1} with priority {2}'.format(LOCATION_NAME,DISK_PREFIX,location.priority)
    )
    


def register(api_object,**kw):
    if not isinstance(api_object,ftrack_api.Session):
        return
    
    if not os.path.exists(DISK_PREFIX) or not os.path.isdir(DISK_PREFIX):
        logger.error('disk prefix does not exist')
        return
    
    api_object.event_hub.subscribe('topic=ftrack.api.session.configure-location',
        functools.partial(configure_location,api_object)
    )

 

Link to comment
Share on other sites

@Nikolay Skolkov

the code you have provided is just the location creation, and is lacking of the other registration part , which is hooked to the application (DCC) or connect action startup.

Please have a look at this example location which does it using two separate scripts:

1) the hook which set the environment variables and register the location

2) the actual location code

You can also use one single function do to it all as by this other example.


Hope it helps.

L.


 

Link to comment
Share on other sites

  • 6 months later...
On 9/22/2023 at 6:12 PM, Nikolay Skolkov said:

here is my code . it is almost the same as in the first message

just summarize problem : it works when publishing from ftrack connect application - it writes to my local location

DCC keeps writing data to server....

neither accessor or structure properties for this location are not defined in DCC. probably i need subscribe to application-launch event, but I haven't managed to do that....i just tried to copy-paste subscription on configure-location event ... but it didn't work

import os
import sys
import functools
import logging
import getpass
import ftrack_api
import ftrack_api.accessor.disk as _disk
import ftrack_api.structure.standard as _standart

logger = logging.getLogger(
    'ftrack user location'
)
LOCATION_NAME = 'nik.local'
DISK_PREFIX = 'D:\\jobs\\'

def configure_location(session,event):
    
    location = session.ensure('Location',
        {
            'name':LOCATION_NAME
        }
    )
    location.accessor = _disk.DiskAccessor(prefix=DISK_PREFIX)
    location.structure = _standart.StandardStructure()
    location.priority = -100
    logger.warning(
        u'Registering using location {0} @ {1} with priority {2}'.format(LOCATION_NAME,DISK_PREFIX,location.priority)
    )
    


def register(api_object,**kw):
    if not isinstance(api_object,ftrack_api.Session):
        return
    
    if not os.path.exists(DISK_PREFIX) or not os.path.isdir(DISK_PREFIX):
        logger.error('disk prefix does not exist')
        return
    
    api_object.event_hub.subscribe('topic=ftrack.api.session.configure-location',
        functools.partial(configure_location,api_object)
    )

 

Sorry, I'm new, should I write this code in the plugin and load the plugin using ftrack connect?

Link to comment
Share on other sites

20 hours ago, Lorenzo Angeli said:

Hi @dima if you are just starting with the Location system, I'd suggest having a look at our location webinar.
If you are after some more technical details have a look at our documentation  and our recipes repository.
Please start using this as plugin , following the example from the recipes.
Hope ithelps.
L.

I already tried to use ftrack-s3-accessor as a plugin, but apparently it is outdated, so now plugins are installed through the hook folder. I tried to upload it to the plugins folder but there were no obvious changes. I also tried using ftrack-sftp-accessor, but also to no avail.

Maybe there is someone on the forum who can help with installing ftrack-s3-accessor? I've been trying to install it for 2 weeks now, but these are the conclusions:

1. We tried to install ftrack on our server (self-hosted), and try to install ftrask-s3-connect there, but we had difficulties with it. Firstly, if we deploy ftrack on our server, then we will need to maintain it, and if everything goes wrong there, then we ourselves will need to restore the data, etc.
In addition, to set up kubernetes, we need to involve a specialist.
This means that this option is not very acceptable for us. Also on the forum we never received answer anything about plugin S3 

2. I tried to make a plugin and upload it to ftrack connect, but there are no instructions on how to debug plugins, most likely this can be done if ftrack is located on its own server, see point 1

3. I have an idea to try using the ftrack api to connect to ourdomain.ftrackapp.com, make a kind of service, an AWS Lambda Function or locally on a PS/MAC and try to listen to events and try to transfer files to this service.

Link to comment
Share on other sites

Hi @dima,

both ftrack-sftp-accessor and ftrack-s3-accessor are api plugins and not server ones, therefore there's no point in trying to have them installed on the self hosted server.
In each repository you can find a snippet on how to initialise and use them just through the api:

s3-example , sftp-example

You can find an example use of the s3-accessor in this user-location plugin
 

for your third point, there's no need of using lambdas , you can just rely on the internal ftrack events to do so, please check the user-location above as reference.

hope it helps/
L.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...