Jump to content

PeterH

Members
  • Posts

    15
  • Joined

  • Last visited

  • Days Won

    6

PeterH last won the day on June 7 2022

PeterH had the most liked content!

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

PeterH's Achievements

  1. I just spent hours yesterday digging into an issue, thought I'd share the findings if anyone comes across the same thing in the future. One bit of code was consistently getting 502 FTrack server errors, but it had minimal calls to FTrack and was failing due to an unrelated reason, which was obviously quite weird. The short version is I found out that when an exception occurs, Sentry (which we're using for error reporting across the studio) will serialise all the local variables in the stack frames, even if not directly related to the exception. Because FTrack entities are dict-like, Sentry converts them to a dict, which in turn hammers the API while it makes hundreds of requests to load all the values and relationships, causing the server to overload. To highlight just how easy it is to cause the problem, the below code just sent 130 queries and caused 3x 502 errors in the process. def func(): entity = FTrackQuery().query('Task').first() logger.exception('test') func() To fix, there's an event "scrubber" that runs before the serialisation, where it's possible to intercept and clear out any FTrack entities. I'd really recommend anyone running Sentry to do this. class FTrackScrubber(sentry_sdk.scrubber.EventScrubber): def scrub_event(self, event): import ftrack_api for frame in sentry_sdk.utils.iter_event_frames(event): for k, v in dict(frame.get('vars', {}).items()): if isinstance(v, ftrack_api.entity.base.Entity): del frame['vars'][k] return super(FTrackScrubber, self).scrub_event(event) sentry_sdk.init( ... send_default_pii=False, event_scrubber=FTrackScrubber(), ) Alternatively a message for the FTrack devs: Sentry checks first for a __sentry_repr__ method, if this was added to the Entity class then it'd prevent the issue from occurring.
  2. Hey, I'm finding the same thing is happening again, I can't load any action that contains a label. I gave incognito mode a try and asked someone else to test, so it doesn't appear to be an issue with cookies or settings on an account. Each time one of these forms attempts to load, It pops up with one of two JS errors in the chrome console: Edit: Figured it out, was my fault. I'd done a multiline string, but one of the lines had a comma by mistake which turned it to a tuple. That was breaking the form display code and leaving it unable to display labels anywhere, hence why I thought it was broken for everything.
  3. PeterH

    Undo !

    That sounds great, however I think 1 week would be too short. For example, someone deleted an asset (without realising) last week thinking they'd just removed it from a list. In their eyes, nothing needed recovering, so it could have easily gone unnoticed for longer than a week.
  4. Seems to work if you just manually call "session.event_hub.connect()" instead of "auto_connect_event_hub=True"
  5. PeterH

    API Explorer GUI

    I made a tool for exploring the API a while back (just remembered to post here after catching a few errors earlier this week), as I was a bit fed up of my old process which was like this: >>> user = session.query('User').first() >>> print(user.keys()) # Look for a key related to groups >>> print(user['memberships']) # Perhaps this, check if entity or list >>> print(user['memberships'][0].keys()) # It's a list, check what each item has available >>> print(user['memberships'][0]['group'].keys()) # I see group, what keys does that have >>> print(user['memberships'][0]['group']['name']) # Found what I needed (random example though, I've never actually needed this) >>> user_groups = [membership['group']['name'] for membership in user['memberships']] I find myself loading it now whenever I'm coding something that I'm unfamiliar with, so just sharing here in case anyone else would find it useful. https://github.com/huntfx/ftrack-api-explorer
  6. The web UI uses "full_name" to display the project (instead of "name"), perhaps that's what you're meaning to check?
  7. Hi, I've been trying to use casting with the `populate` command, but I can't find anything that works. Is it not supported or am I doing something wrong? >>> shot = session.get('Shot', shot_id) >>> session.populate(shot, 'children.status') ServerError: Server reported error: KeyError("Multiple schemas [u'Project', u'TypedContext'] found for relationship u'status'.") >>> session.populate(shot, 'children[Project].status') >>> session.populate(shot, 'children[TypedContext].status') ServerError: Server reported error: KeyError(u'children[Project]') >>> session.populate(shot, 'children.status[Project]') >>> session.populate(shot, 'children.status[TypedContext]') ServerError: Server reported error: KeyError(u"No attribute u'status[Project]' exists for schema u'Context'."
  8. I'm coming in 2 years late, but I was attempting to do this myself and found some info which might help others: If api_user == target_user, then target_user will never receive any notification. It can only be found in the sent items of author_user. The browser notification will always be from api_user. The note itself will correctly be from author_user.
  9. I'm finding that if I attempt to use a label, it stops the action form interface from loading. This appears to be a FTrack bug, as the same thing happens when trying the example form action. If I copy and paste the exact code (and change a bit to connect to the event hub), clicking on the action does absolutely nothing. If I go and remove the label entry from the form, then it loads fine.
  10. Hi, I was going to do this as a pull request but it appears you need permission for that. There's a (easily fixable) limitation with `ftrack_api.event.subscription.Subscription` in that if the object given to it is a non-string object, it will fail because it's returning the object itself inside `Subscription.__str__`. My suggestion is to call the objects `__str__` method when the class is initialised. n my particular use case, I have an object containing multiple parts of a query, and it will generate the final query after being converted to a string. It seems a bit redundant doing `event_hub.subscribe(str(obj))` when `obj` acts like a string in every way other than type. Current def __init__(self, subscription): '''Initialise with *subscription*.''' self._subscription = subscription self._expression = self.parser.parse(_subscription) # Traceback (most recent call last): # File "file.py", line 89, in <module> # session.event_hub.subscribe(<some object>, callback) # File "ftrack_api\event\hub.py", line 436, in subscribe # self._notify_server_about_subscriber(subscriber) # File "ftrack_api\event\hub.py", line 491, in _notify_server_about_subscriber # subscription=str(subscriber.subscription) # TypeError: __str__ returned non-string (type <some object>) Proposed def __init__(self, subscription): '''Initialise with *subscription*.''' self._subscription = str(subscription) self._expression = self.parser.parse(self._subscription)
  11. Edit: This can be closed/deleted, figured it out here Hi, I'm attempting to send notes from an API user to use as a custom notification. It shows up in the sent items area of the inbox, but doesn't appear to the recipient. What am I missing here? The below method worked very well for my other tool of mass writing notes on an episode, the only difference being it's not being appended to task['notes'] this time. Create Note with content and author Create NoteLabelLink with note_id and label_id (set to "Notification" note label) Create Recipient with note_id and resource_id (the user) Commit session To provide a bit of background, I'm trying to make something where artists can subscribe to certain status changes on items (eg. animators want to know when a rig is updated). An event listener will detect that and send them a notification, I'm just a bit stuck on the notification part.
  12. I like the API but I'm not a huge fan of writing the queries as text, so I made something a while back using inspiration from SQLAlchemy. As a very quick example, if the original code is this: episode = session.query('Episode').first() task_link = session.query('select link from Task where (name not like "%task%" or name is "new") and parent.id is "{}" order by name descending'.format(episode['id'])).first() It would be constructed like this: task_link = session.Task.where( or_(~entity.name.like('%task%'), name='new'), parent=session.Episode.first(), ).select(entity.link).sort(entity.name.desc()).first() It's able to do everything I've come across so far, if anyone is interested in using it the github page is here.
  13. You could perform the connection and query in a thread (or process), so if the user makes an amendment, just terminate the thread and spawn a new one.
  14. Our company has recently started making a move from ProofHQ to Review, but people have having trouble when notifying others, starting from about 2 weeks ago. As far as I'm aware this is only happening with Review and not Studio. This is from one of the producers: It appears to affect both the website notifications as well as emails, but it's very inconsistent and affects different people each time. The producers are having to write separate emails to follow up since they can't currently rely on the notifications. Is this likely something on our end or not? I've attached a couple of images to show the invites are saying they've sent, and the users notification settings are as expected.
×
×
  • Create New...