How to use the psiturk.services_manager.psiturk_services_manager.amt_services_wrapper function in PsiTurk

To help you get started, we’ve selected a few PsiTurk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NYUCCL / psiTurk / psiturk / api / __init__.py View on Github external
def patch(self, hit_id):
        data = request.json
        if 'is_expired' in data and data['is_expired']:
            response = services_manager.amt_services_wrapper.expire_hit(hit_id)
            if not response.success:
                raise response.exception
        if 'action' in data:
            if data['action'] == 'approve_all':
                response = services_manager.amt_services_wrapper.approve_assignments_for_hit(hit_id)
                if not response.success:
                    raise response.exception
        return services_manager.amt_services_wrapper.get_hit(hit_id).data, 201
github NYUCCL / psiTurk / psiturk / api / __init__.py View on Github external
def patch(self, hit_id):
        data = request.json
        if 'is_expired' in data and data['is_expired']:
            response = services_manager.amt_services_wrapper.expire_hit(hit_id)
            if not response.success:
                raise response.exception
        if 'action' in data:
            if data['action'] == 'approve_all':
                response = services_manager.amt_services_wrapper.approve_assignments_for_hit(hit_id)
                if not response.success:
                    raise response.exception
        return services_manager.amt_services_wrapper.get_hit(hit_id).data, 201
github NYUCCL / psiTurk / psiturk / api / __init__.py View on Github external
def get(self, action=None):
        if action == 'expire_all':
            response = services_manager.amt_services_wrapper.expire_all_hits()
            if response.success:
                return response.data['results'], 201
            else:
                raise response.exception
        
        elif action == 'delete_all':
            response = services_manager.amt_services_wrapper.delete_all_hits()
            if response.success:
                return response.data['results'], 201
            else:
                raise response.exception
                
        elif action == 'approve_all':
            hits = services_manager.amt_services_wrapper.get_all_hits().data
            
            _return = []
            for hit in hits:
                hit_response = services_manager.amt_services_wrapper.approve_assignments_for_hit(hit.options['hitid'], all_studies=True)
                _return.append(hit_response)
            return _return, 201
                
        else:
            raise APIException(message='action `{}` not recognized!'.format(action))
github NYUCCL / psiTurk / psiturk / api / __init__.py View on Github external
if action == 'expire_all':
            response = services_manager.amt_services_wrapper.expire_all_hits()
            if response.success:
                return response.data['results'], 201
            else:
                raise response.exception
        
        elif action == 'delete_all':
            response = services_manager.amt_services_wrapper.delete_all_hits()
            if response.success:
                return response.data['results'], 201
            else:
                raise response.exception
                
        elif action == 'approve_all':
            hits = services_manager.amt_services_wrapper.get_all_hits().data
            
            _return = []
            for hit in hits:
                hit_response = services_manager.amt_services_wrapper.approve_assignments_for_hit(hit.options['hitid'], all_studies=True)
                _return.append(hit_response)
            return _return, 201
                
        else:
            raise APIException(message='action `{}` not recognized!'.format(action))
github NYUCCL / psiTurk / psiturk / api / __init__.py View on Github external
else:
                raise response.exception
        
        elif action == 'delete_all':
            response = services_manager.amt_services_wrapper.delete_all_hits()
            if response.success:
                return response.data['results'], 201
            else:
                raise response.exception
                
        elif action == 'approve_all':
            hits = services_manager.amt_services_wrapper.get_all_hits().data
            
            _return = []
            for hit in hits:
                hit_response = services_manager.amt_services_wrapper.approve_assignments_for_hit(hit.options['hitid'], all_studies=True)
                _return.append(hit_response)
            return _return, 201
                
        else:
            raise APIException(message='action `{}` not recognized!'.format(action))
github NYUCCL / psiTurk / psiturk / dashboard / __init__.py View on Github external
def wrapped_view(**kwargs):
        try:
            _ = services_manager.amt_services_wrapper
            return view(**kwargs)
        except Exception as e:
            message = e.message if hasattr(e, 'message') else str(e)
            flash(message, 'danger')
            return redirect(url_for('.index'))
    return wrapped_view
github NYUCCL / psiTurk / psiturk / api / __init__.py View on Github external
def post(self, action=None):
        data = request.json
        if action == 'approve_all':
            response = services_manager.amt_services_wrapper.approve_all_assignments()
            if not response.success:
                raise response.exception
            return response.data['results']
        elif action == 'bonus_all':
            if 'reason' not in data or not data['reason']:
                raise APIException(message='bonus reason is missing!')
                
            response = services_manager.amt_services_wrapper.bonus_all_local_assignments(amount='auto', reason=data['reason'])
            if not response.success:
                raise response.exception
            return response.data['results'], 201
        else:
            raise APIException(message='action `{}` not recognized!'.format(action))
github NYUCCL / psiTurk / psiturk / dashboard / __init__.py View on Github external
def mode():
    if request.method == 'POST':
        mode = request.form['mode']
        if mode not in ['live','sandbox']:
            flash('unrecognized mode: {}'.format(mode), 'danger')
        else:
            result = services_manager.amt_services_wrapper.set_mode(mode)
            if result.success:
                flash('mode successfully updated to {}'.format(mode), 'success')
            else:
                flash(str(result.exception), 'danger')
    mode = services_manager.amt_services_wrapper.get_mode().data
    return render_template('dashboard/mode.html', mode=mode)
github NYUCCL / psiTurk / psiturk / api / __init__.py View on Github external
def get(self, action=None):
        if action == 'expire_all':
            response = services_manager.amt_services_wrapper.expire_all_hits()
            if response.success:
                return response.data['results'], 201
            else:
                raise response.exception
        
        elif action == 'delete_all':
            response = services_manager.amt_services_wrapper.delete_all_hits()
            if response.success:
                return response.data['results'], 201
            else:
                raise response.exception
                
        elif action == 'approve_all':
            hits = services_manager.amt_services_wrapper.get_all_hits().data
            
            _return = []
github NYUCCL / psiTurk / psiturk / api / __init__.py View on Github external
def get(self):
        try:
            mode = services_manager.amt_services_wrapper.get_mode().data
        except PsiturkException:
            mode = 'unavailable'
        return {'mode':mode}