Search the Community

Showing results for tags 'query'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Company news
    • General announcements
  • ftrack Studio (main app)
    • General discussion
    • Feature requests
    • API
    • Help
    • Actions and Widgets
    • ftrack Go
  • Connect (plugins)
    • General discussion
    • Releases
    • Feature requests
    • Help
  • Reviews
    • General discussion
    • Feature requests
    • Help
  • Advisory Forum
  • Tech preview
    • New integrations
    • Studio overview
    • ftrack Review
  • Jobs board
    • Job listings

Categories

There are no results to display.


Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

Found 15 results

  1. lukas g

    Query Project Schema Objects

    Hello, I need to write some checks using the python api to make sure the current ftrack project is configured correctly. There fore i need to query the currents project Project Schema and check its configuration. Specifically: I need to query the assigned Objecty (ObjectTypes) of a Project Schema. I can access the the Types and objects with 'ProjectSchema.get_types()' as well as the statuses an by calling 'ProjectSchema.get_statuses()' but i can't find a way to actually figure out if an object (ObjectType) is assigned to the list of objects of the particular Project Schema. (I can easily find out if a specific object type exists at all using 'session.query("ObjectType where name is my_object_type_name")' but not which schemas it is assigned to.) I know from a different post, that creating new ProjectSchemas and "manage" them (editing them?) is only supported using the GUI. But What about retrieving the assigned Objects (ObjectTypes) ? It should be possible i guess. The Docs from ProjectSchema dont show any more methods: http://ftrack-python-api.rtd.ftrack.com/en/1.4.0/api_reference/entity/project_schema.html Examples for get_types() and get_statuses: http://ftrack-python-api.rtd.ftrack.com/en/1.4.0/example/project.html I Hope someone can help me out. Thank you in advance Lukas
  2. Hello everybody! This action populates some custom attributes within a Task that is nested under selected item. These attributes are paths to working directories and render outputs.. I have other actions that rely on these custom paths to do other things such as opening a shot with quicktime / launching the shot folder in explorer /etc.. Everything works as it should.... but I am concerned about the efficiency and speed of my code as populating each task takes about a second... and of course, the more tasks nested under my selection, the longer this process takes. Ideally... I would like to run this action at Project or at least Sequence level and let it update the custom attributes for all tasks nested under it. EpisodicS2 └-- Episode1 └-- Seq001 └-- Shot1 └-- Task1 └-- Task2 └-- Task..10 Am I doing everything right? Are there major deficiencies in my code? Thank you for all the help! Ali import logging import ftrack_api import os import re import ftrack import getpass import time os.environ['FTRACK_SERVER'] = ### os.environ['FTRACK_API_KEY'] = ### #this script will populate parameters of each task and shot nested under selected item with direct paths to file locations. ### prerequisites: #Task should have the following attributes : path, out_path, base_path #Shot should have the following attributes : plate_path #Project should have the following attributes : Project_Path #<----naming will need to be conformed ### class UpdatePaths(object): '''Custom action.''' label = 'Update Paths' identifier = 'update.task.paths' description = 'This updates the path parameter of all tasks nested under selected' icon = 'https://d30y9cdsu7xlg0.cloudfront.net/png/1406969-200.png' def __init__(self, session): '''Initialise action.''' super(UpdatePaths, self).__init__() self.session = session self.logger = logging.getLogger( __name__ + '.' + self.__class__.__name__ ) def register(self): '''Register action.''' try: ftrack.EVENT_HUB.subscribe( 'topic=ftrack.action.discover and source.user.username={0}'.format( getpass.getuser() ), self.discover ) ftrack.EVENT_HUB.subscribe( 'topic=ftrack.action.launch and source.user.username={0} ' 'and data.actionIdentifier={1}'.format( getpass.getuser(), self.identifier ), self.launch ) except: self.session.event_hub.subscribe( 'topic=ftrack.action.discover', self.discover ) self.session.event_hub.subscribe( 'topic=ftrack.action.launch and data.actionIdentifier={0}'.format( self.identifier), self.launch ) def discover(self, event): '''Return action config if triggered on a single asset version.''' data = event['data'] # If selection contains more than one item return early since # this action can only handle a single version. selection = data.get('selection', []) self.logger.info('Got selection: {0}'.format(selection)) #if len(selection) != 1 or selection[0]['entityType'] != 'assetversion': # return return { 'items': [{ 'label': self.label, 'description': self.description, 'actionIdentifier': self.identifier, 'icon': self.icon }] } def launch(self, event): start_time = time.time() data = event['data'] selection = data.get('selection', []) entityTypes = ['Project', 'Episode', 'Sequence', 'Shot', 'Task'] session = ftrack_api.Session() for entity in selection: num = 0 et = entityTypes[num] item = session.query('select name from {0} where id is {1}'.format(et, entity['entityId'])).first() while item == None: num += 1 et = entityTypes[num] item = session.query('select name from {0} where id is {1}'.format(et, entity['entityId'])).first() prj_item_selected = False #If the current selected item is a project, first process it byitself. if item['parent'] == None: project = item prj_item_selected = True project_base = item['custom_attributes']['Project_Path']+item['full_name']+'/' if item['custom_attributes']['base_path']!= project_base: item['custom_attributes']['base_path'] = project_base #now look for the selected items descendants items = item['descendants'][:] #if the selected item is not a project, then we will also need to add taht to the list we will iterate through. if not prj_item_selected: items += [item] project = session.get('Project', item['project_id']) print 'Total nested items:',len(items) for i in items: link_list = i['link'][1:] episode = '' #search for an episode item in the links for l in link_list: link_item = session.get(l['type'], l['id']) if link_item['object_type']['name'] == 'Episode': episode = link_item['name'] project_path = project['custom_attributes']['Project_Path'] project_name = project['full_name'] base_path = project_path+project_name+'/'+episode+'/' base_path = base_path.replace('//','/') if i['custom_attributes']['base_path'] != base_path: i['custom_attributes']['base_path'] = base_path if i['object_type']['name'] == 'Task': shot_name = i['parent']['name'] #this may break when it comes to asset builds since they are not nested under a shot.. task_type = i['type']['name'] task_name = i['name'] path = base_path out_path = base_path if task_type in ['Compositing', 'Precomp', 'Cleanplate', 'Retime', 'Rotoscoping', 'Paintout']: comp_out_dir = '02_OUTPUT/03_comp' if task_type.lower() != task_name.lower(): comp_out_dir = '02_OUTPUT/01_precomp/{task_name}'.format(task_name=task_name) path = '{base_path}{dept_name}/{shot_name}/'.format(base_path=base_path,shot_name=shot_name,dept_name='05_COMP') out_path = '{base_path}{dept_name}/{shot_name}/{comp_out_dir}/'.format(base_path=base_path,shot_name=shot_name,dept_name='05_COMP',comp_out_dir=comp_out_dir) if task_type in ['Matchmove', 'Tracking']: path = '{base_path}{dept_name}/scenes/{shot_name}/tracking/'.format(base_path=base_path,shot_name=shot_name,dept_name='04_3D') out_path = '{base_path}{dept_name}/{shot_name}/TRAC/'.format(base_path=base_path,shot_name=shot_name,dept_name='06_RENDERS') if task_type in ['Animation']: path = '{base_path}{dept_name}/scenes/{shot_name}/anim/'.format(base_path=base_path,shot_name=shot_name,dept_name='04_3D') out_path = '{base_path}{dept_name}/{shot_name}/ANIM/'.format(base_path=base_path,shot_name=shot_name,dept_name='06_RENDERS') if task_type in ['Layout']: path = '{base_path}{dept_name}/scenes/{shot_name}/layout/'.format(base_path=base_path,shot_name=shot_name,dept_name='04_3D') out_path = '{base_path}{dept_name}/{shot_name}/LYT/'.format(base_path=base_path,shot_name=shot_name,dept_name='06_RENDERS') if task_type in ['Lighting']: path = '{base_path}{dept_name}/scenes/{shot_name}/lighting/'.format(base_path=base_path,shot_name=shot_name,dept_name='04_3D') out_path = '{base_path}{dept_name}/{shot_name}/FINL/'.format(base_path=base_path,shot_name=shot_name,dept_name='06_RENDERS') if task_type in ['FX']: path = '{base_path}{dept_name}/scenes/{shot_name}/fx/'.format(base_path=base_path,shot_name=shot_name,dept_name='04_3D') out_path = '{base_path}{dept_name}/{shot_name}/FX/'.format(base_path=base_path,shot_name=shot_name,dept_name='06_RENDERS') path = path.replace('//', '/') out_path = out_path.replace('//', '/') if i['custom_attributes']['path']!= path: #only make changes if they dont already exist i['custom_attributes']['path'] = path if i['custom_attributes']['out_path'] != out_path: #only make changes if they dont already exist i['custom_attributes']['out_path'] = out_path session.commit() print("--- %s seconds ---" % (time.time() - start_time)) return { 'success': True, 'message': 'updated task paths!' } def register(session, **kw): '''Register plugin.''' # Validate that session is an instance of ftrack_api.Session. If not, # assume that register is being called from an incompatible API # and return without doing anything. if not isinstance(session, ftrack_api.Session): # Exit to avoid registering this plugin again. return action = UpdatePaths(session) action.register() if __name__ == '__main__': logging.basicConfig(level=logging.INFO) session = ftrack_api.Session() register(session) # Wait for events. session.event_hub.wait()
  3. HYP_STGR

    Querying filtered tasks

    I'm writing an action script that get as input all tasks whose parent(Asset Build) have a specific value in a custom attribute. Ideally, the right value of the custom attribute would be found in the Filter button/option from the site. The first problem is that i want to be able to query all tasks that have the right filter value using the API's expression language. Something like this: filtered_value = ??? #somehow get the filter from the site list_of_tasks = session.query('Task where parent.custom_attributes.my_custom_attr is {0}'.format(filtered_value)).all() The second problem is that the custom attribute is actually a list so in the query expression i need to be able to do something like this: list_of_filtered_values = ??? #somehow get the filters from the site for value in list_of_filtered_values: #get all tasks that have the value in the custom attribute list. list_of_tasks = session.query('Task where {0} in parent.custom_attributes.my_custom_attr'.format(value)).all() #Do stuff As of right now i'm having to query all task from the project and check which ones have the right value(i get the value from the task where the action was triggered) and then apply my action with it. It's a very inefficient approach since the project has lots of tasks(and it will have more in the future) and Python is not very fast at looping around huge lists. My code right now looks like this: right_value = entity.get("my_custom_attr") tasks = session.query('Task where parent.object_type.name is "Asset Build" and project.name is "my_project"').all() for task in tasks: if episode not in task["parent"]["custom_attributes"]['my_custom_attr']: continue else: #do_stuff Is there a better solution? Thanks!
  4. Luigi

    Query Latest Version

    Hi, You implemented in the version filter in the version view a "latest Version" checker box field, to be able to see just the latest versions. I'm missing this feature in the Widget settings of the Latest Version. Is there a way to query the latest version through the query field? Thanks. Best, Luigi
  5. Hi, We would like to be able to filter all latest versions of type "X" (e.g. a released playblast) that have a task "Y" (e.g. animation) and are linked to my current selection "Z" (e.g. a character in my asset library) We need to be able to query it though the browser UI of ftrack, without any line of code or a developer for it. e.g.: Show me the latest playblasts from the animation dept linked to my selected character The interface should filter the list accordingly. a simple query like: task.type.name="Animation" AND asset.parent.incoming_link.from = MY_SELECTION_LEFT or something like this: task.type.name is "Animation" AND task.parent.link.name is 'charactername' Would this be possible? If not, how long would it take that to implement this request? Best, Luigi
  6. Hi, I'm trying to figure out a query to retrieve all or selected custom_attributes in a query. I have some custom attributes on a project and my session has autopopulating turned OFF. project = session.query('select custom_attributes from Project where name is "{0}"'.format(name)).one() if I try to access my custom attribute "foo" the value of it is not set print project['custom_attributes']['foo'] > NOT_SET I tried to pass the attribute name directly to the query but that in key error project = session.query('select custom_attributes.foo from Project where name is "{0}"'.format(name, key)).one() > ServerError: Server reported error: KeyError(u"No attribute u'foo' exists for schema u'CustomAttributeValue'.") is it possible to fetch custom attributes in the main query?
  7. pawel

    is query by link possible

    Hi, We are in the process of evaluating ftrack as a replacement for our in-house system. Quite often we need to find database entries based on a system path. From the system path, we can extract the project/sequence/shot etc names that are unique for an entity. One way to retrieve a shot information is with multiple queries to access specific IDs: project_number = 4444 sequence = 'Online' shot_name = 'sh010' project_id = session.query('select name, id from Project where name is {0}'.format(project_number)).first()['id'] sequence_id = session.query('select id from Sequence where name is {0} and project.id is {1}'.format(sequence,project_id)).first()['id'] shot = session.query('select name, link from Shot where name is {1} and parent.id is {0}'.format(sequence_id, shot_name)).first() this seems to be quite convoluted and potentially slow. however shot['link'] contains the same information of the parent structure that we can extract from the path and we could easily create it (without the IDs). is it possible to construct the 'link' with the names of the items in the hierarchy and use it to query? I tried something like this but the query doesn't like the square brackets (this is where my sql knowledge ends): [p['name'] for p in session.query('select name, link from Shot where name is sh010 and link[0].name is 4444 and link[1] is online')] is there another better way to query a shot (or another entity) knowing its logical path (link)? thank you Pawel
  8. jerome

    Query join

    Hi, Is it possible to send queries with the new API that will use joins on several objects. I would like to query an asset for a specific asset build, i.e. something like this: Asset where parent.id is ( select id from AssetBuild where project.id is <projectId> and name is "<myAssetBuildName>")Is this kind of request valid with the new API ?
  9. Remus Avram

    Query ' where ... is ...' not case sensitive

    Hi all, I have 2 assets in Ftrack: 'asset_name' and 'ASSET_NAME'. When I query via the API both assets, all the time I get only the first one because the name is not case sensitive. Example: assets = session.query("Asset where name is 'asset_name'").all() print len(assets) print assets[0]['name'] print assets[0]['id'] # Return: 1 asset_name 4c63aa70-6475-11e6-b6fd-005056a76761 assets = session.query("Asset where name is 'ASSET_NAME'").all() print len(assets) print assets[0]['name'] print assets[0]['id'] # Return: 1 asset_name 4c63aa70-6475-11e6-b6fd-005056a76761 Ftrack server: v3.3.30 API: v0.15.5
  10. In our Ftrack installation, we have defined a custom attribute at the project level--let's call it "locations". I would like to create a function that allows users to add an additional location to a project after querying that the provided argument is indeed an available option in the collection of locations. I can't find an example of this kind of query; I just need to know whether this is something attached to Session or somewhere else. So let's say locations = {'Uptown': 'uptown', 'Downtown': 'downtown', 'Midtown': 'midtown'} (in settings it's an Enumerator that seems to be represented as a dictionary) We created our own wrappers for some of several of the Ftrack queries, so I decided not to include that code. The part in bold is what I'm getting at... is this the way to access it? I thought this might be the way because the documentation says: "The custom attributes available on entities are cached on the Session." It isn't working when I run unit tests.
  11. So I'm trying to create a tool that creates tasks from Maya. I got the initial prototype working, but I'm having trouble with optimization. Originally, when the user hit the create task button, the session would query the schema, get the available task types, and then put them into a combobox. This worked fine, but the long loading time proved to be too slow for production. So I figured what if I loaded the task types when the user first ran the tool? That way when they went to create a task, the combobox would be filled and ready to go. This worked at first, but along the way things started to fall apart as I added more automation to the code. Maya started to hang at random times and eventually started to consistently hang during every startup. I ended up removing the code that builds the combobox data cache and that fixed the issue (so that code is the problem). The data is being added in a way so the task type name is displayed, but the task type id data is returned on selection. Here's what I have so far, the problem area is the for loop: # Ftrack session data to get shot name for tab widget shot_id = os.getenv('FTRACK_SHOTID') shot = session.get('Shot', shot_id) self.shot_name = shot['name'] project = shot['project'] schema = project['project_schema'] self.cb_task_types = QtGui.QComboBox() self.task_types = schema.get_types('Task') for task_type in self.task_types: self.cb_task_types.addItem(task_type['name'], task_type['id'])
  12. Mike

    New API: Query entity type

    I'm trying to figure out how to query what an item is based on user selection. In my tool, a user might be selecting a Sequence, Task, Shot, etc and I'd like different things to happen based on their selection. Is there any way to query this with the new API? The docs seem to just show how to query something only if you know exactly what entity type you want. I have this right now: dir_contents = [] for item in project['children']: dir_contents.append( item ) for item in dir_contents: item_name = item['name'] item_type = item['context_type'] item_id = item['id'] When I tested this code out by selecting a Sequence entity, I printed out every attribute and expected to find 'sequence' as a value somewhere, but only the attribute, context_type, resulted in something close to what I was looking for ( print item['context_type'] resulted in 'task' as a value ) Thanks for any help!
  13. 1) I'm having trouble getting the criteria system to work. When the tool starts up, in the main window module queries all of the active projects and populates a QTreeView: session = ftrack_api.Session() dir_contents = [] for project in session.query('Project'): dir_contents.append( project ) When a user selects a project to work with, another module creates a tab and queries the project data- populating this new tab with directory hierarchy, tasks, thumbnails, notes, etc. I was able to begin querying a project's ftrack data by using the legacy method getProject('string'), but I'm having trouble getting the equivalent to work using the latest API. This is what I have right now: selected_index = self.tab_projects.tv_projects_view.selectedIndexes()[0] session = ftrack_api.Session() project = session.query( 'Project where name is "{0}"' .format(selected_index.data()) ) The value for selected_index.data() is just a string like 'MY_PROJECT_NAME'. I keep getting this error: QueryResult.__getitem__ in query line 89: list indices must be integers, not str. 2) Also, if I'm querying, should I be setting a session variable in every module that queries, or should I be doing this globally somewhere? Thanks! ----------------EDIT------------- 3) So I figured out from here that I needed to add .one() at the end of the query like this. I guess it's a python method to only return 1 value. Why wouldn't this query return just 1 value by default though? project = self.session.query( 'Project where name is {0}' .format(selected_index.data()) ).one()
  14. jerome

    Query operator

    Hi, Is there a simple way to query for the last version of an asset with the new API ? And more generally is there a plan to add new selection operator like: max, avg, sum or count ? Cheers, Jerome
  15. I want to get list of task that was changed in status or published during some period of time. There should be a function with input - start_date,end_date and output - List of Tasks