Remus Avram

Members
  • Content Count

    486
  • Joined

  • Last visited

  • Days Won

    12

Posts posted by Remus Avram


  1. 3 hours ago, Mike said:

    What if we want to implement renaming? A lot of our projects require us to rename assets, shots, and even sometimes the project name itself. Has anyone implemented a workflow with renaming capabilities or does one already exist in ftrack?

    What do you mean? Automatic renaming? like if you rename something in Ftrack, it should be renamed also on the filesystem?


  2. 11 minutes ago, Martin Pengelly-Phillips said:

    Note that you could also write your own cache interface to connect to a shared cache if you want to reduce DB hits. For example, we run a Redis cache per site and created a RedisCache implementation as a subclass of ftrack_api.cache.Cache.

     

    Thanks for the info! We will try to test this, too.


  3. 2 minutes ago, Nebukadhezer said:

    we also use one session across threads and I am constantly running into the same behavior.
    As a workaround I am setting the auto_populate attribute to True at many places as this seems to be setting itself to False when the same session object is used from multiple threads...

    We tried multiple ways. It will not work.

    If you are using multi threads, use multiple session.


  4. 21 minutes ago, tokejepsen said:

    I thought this was the intention, so we are using it as a feature. If we want to create the next available version, we set the version to 0 when creating the asset version.
    It would be nice to still retain this feature somehow. Maybe -1 would make more sense for this? Or a dedicated method or argument for getting the next available version number.

    I think not specifying the version number when you create the assetVersion it's the best way. In this way it's automatically creating the next version.


  5. Hi @Mattias Lagergren

    the offline documentation was awesome for the production and artists as they could find it easily.

    Unfortunately, our users don't have direct internet connection and they can not easily access it.

    Another think is that we are not migrating to the latest version all the time. Especially when we are close to a show deadline. In this way, if there are new features which production is interested in, but they are not in the Ftrack version used in production, then it could create confusion.


  6. Thanks @Martin Pengelly-Phillips for the info!

    So as I understand the cache is build per session. If there is a session per thread, then for each thread there is a cache file which can contain the same data as the other sessions. Am I correct?

    Having only one session, there is only one cache file with all the data and the queries are faster. Less queries to the database.

    Do you know if the sessions connected?

    I did a test and it seems that they are. I query in assetBuild in one session and I created a task using as parent the assetbuild from the other session and the task was created.

    @Martin Pengelly-Phillips: I am interested how are you using the session. Are you creating a new session for each query / commit?


  7. Thanks @Mattias Lagergren for your answer!

    For us it's quite important because we are planing to use threads in all of our tools. We would like to use at least 1 thread in order to not freeze the UI while it is fetching the data.

    2 minutes ago, Mattias Lagergren said:

    One possible way to move forward with this is to change the example above and pass in the project id to the threads and then query for TypedContext where project_id is <project_id> in the thread.

    You mean something like this:

    from multiprocessing.dummy import Pool as ThreadPool
    
    import ftrack_api
    from ftrack_api.symbol import Symbol
    
    
    session = ftrack_api.Session()
    
    
    def check_keys(entity):
        for key in entity.keys():
            if isinstance(entity[key], Symbol):
                print entity, ': ', key
    
    
    def check_children(entity_id):
        entity = session.get('TypedContext', entity_id)
        if 'children' in entity.keys():
            for child in entity['children']:
                check_keys(entity=child)
                check_children(entity_id=child['id'])
    
    
    def main():
        projects = session.query("Project").all()
        projects_id = [project["id"] for project in projects]
        pool = ThreadPool()
        pool.map(check_children, projects_id)
    
    
    if __name__ == "__main__":
        main()

    It still doesn't work. In the thread most of the time session.get('TypedContext', entity_id) returns None.


  8. Hi Mattias,

    ahh... are you going to make it thread safe?

    The problem is that if it is not specified when the session is created to not auto-populate, then it should never return a Symbol (NOT SET) value.

    Creating a session per thread works as expected. But it doesn't help us as the sessions are not connected.


  9. Hi Ftrack Team,

    we would like to use the ftrack session in threads, but, unfortunately, it seems that ftrack_api is not thread safe.

    When we are using the session in multiple threads the return of the attribute value of the entities is a Symbol (NOT SET).

    Please find below a script where we were able to reproduce the issue:

    from multiprocessing.dummy import Pool as ThreadPool
    
    import ftrack_api
    from ftrack_api.symbol import Symbol
    
    
    session = ftrack_api.Session()
    
    
    def check_keys(entity):
        for key in entity.keys():
            if isinstance(entity[key], Symbol):
                print entity, ': ', key
    
    
    def check_children(entity):
        if 'children' in entity.keys():
            for child in entity['children']:
                check_keys(entity=child)
                check_children(entity=child)
    
    
    def main():
        projects = session.query("Project").all()
        pool = ThreadPool()
        pool.map(check_children, projects)
    
    
    if __name__ == "__main__":
        main()

    ftrack_api version: 1.3.2

    ftrack server version: 3.5.6