eight

Members
  • Content Count

    50
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by eight

  1. I found the proxy location documentation from efestolab. Although it's helpful, it looks like it's meant to filter by Task Types and Component Types rather than by Project. I think I can base something off that, but it would be better to have this kind of thing already built into ftrack Connect.
  2. Is it possible to choose the root directory on a per project basis? We have a studio with multiple file storages paths, and we want some projects to go on one file storage and other projects to go on a different file storage. For example: City1 - Storage1 - Storage2 City2 -Storage1 -Storage2 If I want to work on Project1 in City1, Storage1 and City2, Storage1, but I want to work on Project2 in City1, Storage2 and City2, Storage2. What's the best way to do this?
  3. eight

    New API: getTasks

    Thank you for the reply. It helps.
  4. eight

    New API: getTasks

    Forgot to mention using includeChildren=True.
  5. You could try session.populate(tasks, 'name,status.name,assignments.resource') instead. I know if you use assignments.resource.name it will break even though it seems like it should be valid. So you can always add name as a default projection for Task similar to this example: Default Projections
  6. eight

    New API: getTasks

    Any way to create the equivalent of Task.getTasks in the new API? I could recursively get children of children, but that seems pretty slow.
  7. You can use both APIs together, so if there is something you cannot do with the new API, you can just fall back on the old API. I don't know where to find extra tutorials, but ftrack has a public bitbucket account with some examples you can study. Most of them seem to be using the old API though.
  8. Hi, When, I'm looking in ftrack web in the Tasks view, I want to add a column for a custom attribute, but it looks like it's not there. I can see some of my custom attributes, but it seems that only custom attributes that are not hierarchical are shown. How can I show these attributes?
  9. Is there an easy way to query an entity from an event? My problem is that each item in event['data']['selection'] contains an 'entityType' which is 'task' whether it is a Task, Shot, Sequence, etc. So I don't know whether to do session.get('Task', id), session.get('Shot', id), session.get('Sequence', id) or whatever it might be. How do I know what the actual type to query is?
  10. So you mean the cache maker would look like this? def testCacheMaker(session): return ftrack_api.cache.MemoryCache() I get very similar performance as not using a FileCache. Also, I forgot to mention that I was deleting the file that the FileCache made before each run.
  11. I have another update. The missing select statement was only a part of the problem. The rest was because of FileCache. I tried the example below with and without the session cache (183 tasks). With the cache, it took about 13 seconds, and without, it took about 4 seconds. The big difference showed when adding a lot of select statements. With select statements + cache, it took about 35 seconds while select statements without cache took about 6 seconds. import os import time import tempfile import ftrack_api def testCacheMaker(session): testCachePath = os.path.join(tempfile.gettempdir(), 'ftrack') try: os.makedirs(testCachePath) except: pass testCachePath = os.path.join(testCachePath, 'test_cache.dbm') print 'testCachePath: {}'.format(testCachePath) return ftrack_api.cache.SerialisedCache( ftrack_api.cache.FileCache(testCachePath), encode=session.encode, decode=session.decode ) def test(): start = time.time() session = ftrack_api.Session(cache=testCacheMaker) query = 'User where username is "fred"' user = session.query(query).one() query = 'Task where project.status is active and assignments any (resource_id={})'.format(user['id']) tasks = session.query(query).all() print len(tasks) print 'time: {}'.format(time.time() - start)
  12. I realized my problem while I was trying to create an example for you. I was looping through each task and accessing a key that wasn't projected making it a lot slower. It was for parent.type.name. Yet, I can't select this because I get a ServerError. It must be similar to the problem deex had. Here's the example code if you still want to see it: session = ftrack_api.Session() query = 'User where username is "fred"' user = session.query(query).one() query = 'Task where project.status is active and assignments any (resource_id={})'.format(user['id']) tasks = session.query(query).all()
  13. It turns out that getting all tasks for a user is very slow, even if I filter out projects that are no longer active. It's taking about 45 seconds to load for someone with 181 active tasks. Is there a way to make it faster or is this just an inherently slow query? I've tried two different ways. One is the way I did it in a previous post in this thread, and the other way is the way that Mattius did it. They both are similar in time.
  14. eight

    Location Setup

    Thank you! This helps a lot!
  15. eight

    Location Setup

    Thank you! This makes a lot more sense now. Is it possible to port the example transfer code to the new API or are there some things in there that the new API doesn't support? I can figure out how to convert most of it, but some things that stand out at me are: ftrack.getLocations(excludeInaccessible=True) and targetLocation.addComponent(component, manageData=True) I know how to get all locations with the new API, but I don't know how to excludeInaccessible. Also, the Location.add_component method in the new API does not have a manageData parameter, and also adds a source parameter, so I don't know if it would work the same way.
  16. eight

    Location Setup

    I changed everything to the legacy API and I'm able to get the custom locations to show up, but transfers do not work. I get: Do I need to create my own accessor to transfer files between two different studios? Or is there something that magically makes it work like piping the data through the ftrack server somehow?
  17. eight

    Location Setup

    I could use more help since I'm now trying to transfer components between two locations. I'm using this example: https://www.ftrack.com/portfolio/transfer-components . However, the custom locations are not showing up. I know it's because of ftrack.getLocations(excludeInaccessible=True) . If I change it to False, my locations will show up. But why are my locations considered inaccessible? I'm creating locations like this: query = 'Location where name is "{name}"'.format(name=locationName) location = session.query(query).one() location.accessor = DiskAccessor('') location.structure = LocationStructure(prefix='') location.priority = 50 Shouldn't the DiskAccessor be enough for the Location to be considered accessible?
  18. eight

    Location Setup

    Okay. Thank you for helping me understand how this all works!
  19. eight

    Location Setup

    So, I would instead publish components using a relative path like: assetVersion.create_component(relativePath, {'name': componentName}, location='my.location') Then, for the path resolver I would do this? def mainCallback(event): query = 'Location where name is "{name}"'.format(name=event['data']['locationName']) location = session.query(query).one() component = session.get('Component', event['data']['componentId']) relativePath = location.get_filesystem_path(component) if event['data']['platform'] == 'Windows': resolvedPath = os.path.join(r'\\SHARED\jobs', relativePath) resolvedPath = resolvedPath.replace('/', '\\') elif event['data']['platform'] == 'Linux': resolvedPath = os.path.join('/mnt/jobs', relativePath) resolvedPath = resolvedPath.replace('\\', '/') return {'path': resolvedPath} If this is the case, then I'm confused what the purpose of prefix is for the constructors of Accessor and Structure when configuring locations. Also, there's no way to tell if the platform is a Mac? I thought Macs used /Volumes instead of /mnt?
  20. eight

    Location Setup

    I created my own location. The code is similar to the tutorial, but there is no resolver example for the new API, so here's my code for that: def mainCallback(event): query = 'Location where name is "{name}"'.format(name=event['data']['locationName']) location = session.query(query).one() component = session.get('Component', event['data']['componentId']) resolvedPath = location.get_filesystem_path(component) return {'path': resolvedPath} session.event_hub.subscribe('topic=ftrack.location.request-resolve', mainCallback)
  21. eight

    Location Setup

    Hi, I've read the locations tutorial for the new API, but I still find it hard to understand. My goal was to simply show the correct path for a component in the web interface based on the platform the user is on. So the component is published with a relative path and based on whether the user is looking at the ftrack web interface from Windows, Mac, or Linux, the prefix would change to use the correct mount point for them. So something like: if platform == 'Windows': prefix = r'\\SHARED\jobs' elif platform == 'Mac': prefix = '/Volumes/jobs' elif platform == 'Linux': prefix = '/mnt/jobs' I can't figure out how to do this.
  22. Since a new version gets created every time you publish you can do something like this: query = 'select task, task.id, task.name from 'query += 'AssetVersion where date after "{}" and date before "{}"'.format( arrow.now().replace(weeks=-2), arrow.now().replace(weeks=-1))tasks = {}versions = session.query(query).all()for version in versions: task = version['task'] if task: tasks[task['id']] = task for task in tasks.itervalues(): print task['name']As for status, I don't think ftrack keeps track of the date every time a status changes.
  23. I'm using the new API. With it, I'm trying to get the users assigned to a task when they are added or removed, but this is giving my trouble. First of all, the entity in the event I get has 'changes': None. So I can't get the user list from this like I normally would. The other thing I tried to do was query the Task and get its 'assignments'. This works the first time, but because of caching, it does not work anymore after that. Is there a way to temporarily ignore the cache similar to how someone would turn off auto_populating?