Exemplo n.º 1
0
 def create_classifier(self, job):
     """
         Creates classifier entry with type equal to JOB_DEFAULT_CLASSIFIER.
     """
     classifier_prefix = '%s-' % setting('SITE_URL', '127.0.0.1')
     classifier_factory.initialize_classifier(
         job_id=job.id,
         classifier_name=settings.JOB_DEFAULT_CLASSIFIER,
         prefix=classifier_prefix,
     )
Exemplo n.º 2
0
 def create_classifier(self, job):
     """
         Creates classifier entry with type equal to JOB_DEFAULT_CLASSIFIER.
     """
     classifier_prefix = '%s-' % setting('SITE_URL', '127.0.0.1')
     classifier_factory.initialize_classifier(
         job_id=job.id,
         classifier_name=settings.JOB_DEFAULT_CLASSIFIER,
         prefix=classifier_prefix,
     )
Exemplo n.º 3
0
import posix_ipc
import memcache
import threading
import weakref

from tenclouds.lock.rwlock import RWLock
from urlannotator.tools.utils import setting

import logging
log = logging.getLogger(__name__)

memcache_client = memcache.Client(['127.0.0.1:11211'], debug=0)


_posix_sem_prefix = setting('POSIX_PREFIX', setting('SITE_URL', 'testing'))


class _POSIXSemProxy(object):
    """
        Proxies access to posix_ipc.Semaphore. Closes underlying semaphore on
        finalization.
    """
    def __init__(self, name):
        self.name = name
        lock_name = '/%s-%s' % (_posix_sem_prefix, name)
        try:
            self.semaphore = posix_ipc.Semaphore(
                name=lock_name,
                flags=posix_ipc.O_CREAT,
                initial_value=1,
            )
Exemplo n.º 4
0
import hashlib
import uuid
import json
import math

from django.conf import settings
from itertools import imap
from tagapi.api import TagasaurisClient, combined_exponential_backoff
from tagapi.error import TagasaurisApiException, TagasaurisApiMaxRetries
from urlannotator.tools.utils import setting

import logging
log = logging.getLogger(__name__)

TAGASAURIS_CALLBACKS = setting('TAGASAURIS_CALLBACKS',
    'http://' + settings.SITE_URL)
TAGASAURIS_VOTING_CALLBACK = setting('TAGASAURIS_VOTING_CALLBACK',
    TAGASAURIS_CALLBACKS + '/api/v1/vote/add/tagasauris/%s/')
TAGASAURIS_BTM_VOTING_CALLBACK = setting('TAGASAURIS_BTM_VOTING_CALLBACK',
    TAGASAURIS_CALLBACKS + '/api/v1/vote/btm/tagasauris/%s/')

# Tagasauris needs sacrifice!
DUMMY_URLANNOTATOR_URL = setting('DUMMY_URLANNOTATOR_URL',
    'http://' + settings.SITE_URL + '/statics/img/favicon.png')

TAGASAURIS_HIT_SOCIAL_URL = setting('TAGASAURIS_HIT_SOCIAL_URL',
    settings.TAGASAURIS_HOST + '/actions/start_annotation/?hid=%s')

TAGASAURIS_GATHER_SAMPLES_PER_JOB = setting(
    'TAGASAURIS_GATHER_SAMPLES_PER_JOB', 5)
Exemplo n.º 5
0
NEW_JOB_VISIBILITY = 'invite-only'
NEW_JOB_HOURLY_DURATION = 0

NEW_JOB_DURATION = datetime.timedelta(days=360)

JOB_SAMPLE_GATHERING_KEY = 'sample_gathering'
JOB_VOTING_KEY = 'voting'
JOB_BTM_GATHERING_KEY = 'btm_gathering'
JOB_BTM_VOTING_KEY = 'btm_voting'

SAMPLE_GATHERING_TEAM = '%s Sample Gathering'
VOTING_TEAM = '%s Voting'
BTM_GATHERING_TEAM = '%s Beat The Machine Gathering'
BTM_VOTING_TEAM = '%s Beat The Machine Voting'

TEAM_PREFIX = setting('ODESK_TEAM_PREFIX', 'Build A Classifier')

ODESK_HIT_SPLIT = 20

ODESK_OFFERS_PAGE_SIZE = 200
OFFER_BY_WORKER = 'provider'
OFFER_BY_OWNER = 'buyer'

# Offers made by WORKERS to the OWNER:
# REJECTED - OWNER has rejected WORKER's offer
# IN_PROCESS - Not processed candidacy
# CANCELLED - Worker has cancelled candidacy (withdrew)
OFFER_CANDIDACY_W_REJECTED = 'rejected'
OFFER_CANDIDACY_W_IN_PROCESS = 'in_process'
OFFER_CANDIDACY_W_CANCELLED = 'cancelled'
Exemplo n.º 6
0
import posix_ipc
import memcache
import threading
import weakref

from tenclouds.lock.rwlock import RWLock
from urlannotator.tools.utils import setting

import logging
log = logging.getLogger(__name__)

memcache_client = memcache.Client(['127.0.0.1:11211'], debug=0)

_posix_sem_prefix = setting('POSIX_PREFIX', setting('SITE_URL', 'testing'))


class _POSIXSemProxy(object):
    """
        Proxies access to posix_ipc.Semaphore. Closes underlying semaphore on
        finalization.
    """
    def __init__(self, name):
        self.name = name
        lock_name = '/%s-%s' % (_posix_sem_prefix, name)
        try:
            self.semaphore = posix_ipc.Semaphore(
                name=lock_name,
                flags=posix_ipc.O_CREAT,
                initial_value=1,
            )
        except posix_ipc.PermissionsError: