How to use the dallinger.utils.generate_random_id function in dallinger

To help you get started, we’ve selected a few dallinger 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 Dallinger / Dallinger / tests / test_mturk.py View on Github external
def name_with_hostname_prefix():
    hostname = socket.gethostname()
    name = "{}:{}".format(hostname, generate_random_id(size=32))
    return name
github Dallinger / Dallinger / tests / test_mturk.py View on Github external
def fake_qualification_type_response():
    canned_response = {
        'AutoGranted': u'0',
        'QualificationType': '',
        'Description': u'***TEST SUITE QUALIFICATION***',
        'QualificationTypeId': generate_random_id(size=32),
        'IsValid': u'True',
        'Request': '',
        'QualificationTypeStatus': u'Active',
        'CreationTime': u'2017-02-02T17:36:03Z',
        'Name': u'Test Qualifiction'
    }

    qtype = QualificationType(None)
    for k, v in canned_response.items():
        qtype.endElement(k, v, None)

    return as_resultset(qtype)
github Dallinger / Dallinger / tests / test_data.py View on Github external
def test_user_s3_bucket_thrice(self):
        id = generate_random_id()
        for i in range(3):
            bucket = dallinger.data.user_s3_bucket(canonical_user_id=id)
            assert bucket
        bucket.delete()
github Dallinger / Dallinger / dallinger / recruiters.py View on Github external
def recruit(self, n=1):
        """Generate experiemnt URLs and print them to the console."""
        logger.info("Recruiting {} CLI participants".format(
            n
        ))
        urls = []
        template = "{}/ad?recruiter={}&assignmentId={}&hitId={}&workerId={}&mode={}"
        for i in range(n):
            ad_url = template.format(
                get_base_url(),
                self.nickname,
                generate_random_id(),
                generate_random_id(),
                generate_random_id(),
                self._get_mode()
            )
            logger.info('{} {}'.format(NEW_RECRUIT_LOG_PREFIX, ad_url))
            urls.append(ad_url)

        return urls
github Dallinger / Dallinger / dallinger / recruiters.py View on Github external
def recruit(self, n=1):
        """Generate experiemnt URLs and print them to the console."""
        urls = []
        template = "{}/ad?assignmentId={}&hitId={}&workerId={}&mode={}"
        for i in range(n):
            ad_url = template.format(
                get_base_url(),
                generate_random_id(),
                generate_random_id(),
                generate_random_id(),
                self._get_mode()
            )
            logger.info('{} {}'.format(NEW_RECRUIT_LOG_PREFIX, ad_url))
            urls.append(ad_url)

        return urls
github Dallinger / Dallinger / dallinger / recruiters.py View on Github external
def recruit(self, n=1):
        """Generate experiemnt URLs and print them to the console."""
        logger.info("Recruiting {} CLI participants".format(
            n
        ))
        urls = []
        template = "{}/ad?recruiter={}&assignmentId={}&hitId={}&workerId={}&mode={}"
        for i in range(n):
            ad_url = template.format(
                get_base_url(),
                self.nickname,
                generate_random_id(),
                generate_random_id(),
                generate_random_id(),
                self._get_mode()
            )
            logger.info('{} {}'.format(NEW_RECRUIT_LOG_PREFIX, ad_url))
            urls.append(ad_url)

        return urls
github Dallinger / Dallinger / dallinger / recruiters.py View on Github external
def recruit(self, n=1):
        """Recruit n new participant bots to the queue"""
        factory = self._get_bot_factory()
        urls = []
        q = _get_queue()
        for _ in range(n):
            base_url = get_base_url()
            worker = generate_random_id()
            hit = generate_random_id()
            assignment = generate_random_id()
            ad_parameters = 'assignmentId={}&hitId={}&workerId={}&mode=sandbox'
            ad_parameters = ad_parameters.format(assignment, hit, worker)
            url = '{}/ad?{}'.format(base_url, ad_parameters)
            urls.append(url)
            bot = factory(url, assignment_id=assignment, worker_id=worker)
            job = q.enqueue(bot.run_experiment, timeout=60 * 20)
            logger.info("Created job {} for url {}.".format(job.id, url))

        return urls
github Dallinger / Dallinger / dallinger / recruiters.py View on Github external
def recruit(self, n=1):
        """Recruit n new participant bots to the queue"""
        factory = self._get_bot_factory()
        urls = []
        q = _get_queue()
        for _ in range(n):
            base_url = get_base_url()
            worker = generate_random_id()
            hit = generate_random_id()
            assignment = generate_random_id()
            ad_parameters = 'assignmentId={}&hitId={}&workerId={}&mode=sandbox'
            ad_parameters = ad_parameters.format(assignment, hit, worker)
            url = '{}/ad?{}'.format(base_url, ad_parameters)
            urls.append(url)
            bot = factory(url, assignment_id=assignment, worker_id=worker)
            job = q.enqueue(bot.run_experiment, timeout=60 * 20)
            logger.info("Created job {} for url {}.".format(job.id, url))

        return urls
github Dallinger / Dallinger / dallinger / recruiters.py View on Github external
def recruit(self, n=1):
        """Recruit n new participant bots to the queue"""
        factory = self._get_bot_factory()
        urls = []
        q = _get_queue()
        for _ in range(n):
            base_url = get_base_url()
            worker = generate_random_id()
            hit = generate_random_id()
            assignment = generate_random_id()
            ad_parameters = 'assignmentId={}&hitId={}&workerId={}&mode=sandbox'
            ad_parameters = ad_parameters.format(assignment, hit, worker)
            url = '{}/ad?{}'.format(base_url, ad_parameters)
            urls.append(url)
            bot = factory(url, assignment_id=assignment, worker_id=worker)
            job = q.enqueue(bot.run_experiment, timeout=60 * 20)
            logger.info("Created job {} for url {}.".format(job.id, url))

        return urls