def post(self, analysis_id): analysis_id = int(analysis_id) rarefaction_depth = self.get_argument('rarefaction-depth') # convert to integer if rarefaction level given if rarefaction_depth: rarefaction_depth = int(rarefaction_depth) else: rarefaction_depth = None analysis = Analysis(analysis_id) check_analysis_access(self.current_user, analysis) command_args = self.get_arguments("commands") split = [x.split("#") for x in command_args] moi_user_id = get_id_from_user(self.current_user.id) moi_group = create_info(analysis_id, 'group', url='/analysis/', parent=moi_user_id, store=True) moi_name = 'Creating %s' % analysis.name moi_result_url = '/analysis/results/%d' % analysis_id submit(ctx_default, moi_group['id'], moi_name, moi_result_url, run_analysis, analysis_id, split, rarefaction_depth=rarefaction_depth) r_client.hset('analyis-map', analysis_id, moi_group['id']) self.render("analysis_waiting.html", group_id=moi_group['id'], aname=analysis.name)
def post(self, analysis_id): analysis_id = int(analysis_id) rarefaction_depth = self.get_argument('rarefaction-depth') mdsi = self.get_argument('merge-duplicated-sample-ids', default=False) if mdsi == 'on': mdsi = True # convert to integer if rarefaction level given if rarefaction_depth: rarefaction_depth = int(rarefaction_depth) else: rarefaction_depth = None analysis = Analysis(analysis_id) check_analysis_access(self.current_user, analysis) command_args = self.get_arguments("commands") cmd_split = [x.split("#") for x in command_args] moi_user_id = get_id_from_user(self.current_user.id) moi_group = create_info(analysis_id, 'group', url='/analysis/', parent=moi_user_id, store=True) moi_name = ("Creating %s... When finished, please click the 'Success' " "link to the right" % analysis.name) moi_result_url = '/analysis/results/%d' % analysis_id submit(ctx_default, moi_group['id'], moi_name, moi_result_url, run_analysis, analysis_id, cmd_split, rarefaction_depth=rarefaction_depth, merge_duplicated_sample_ids=mdsi) r_client.hset('analyis-map', analysis_id, moi_group['id']) self.render("analysis_waiting.html", group_id=moi_group['id'], aname=analysis.name)
def post(self, analysis_id): analysis_id = int(analysis_id) rarefaction_depth = self.get_argument('rarefaction-depth') mdsi = self.get_argument('merge-duplicated-sample-ids', default=False) if mdsi == 'on': mdsi = True # convert to integer if rarefaction level given if rarefaction_depth: rarefaction_depth = int(rarefaction_depth) else: rarefaction_depth = None analysis = Analysis(analysis_id) check_analysis_access(self.current_user, analysis) command_args = self.get_arguments("commands") cmd_split = [x.split("#") for x in command_args] moi_user_id = get_id_from_user(self.current_user.id) moi_group = create_info(analysis_id, 'group', url='%s/analysis/' % qiita_config.portal_dir, parent=moi_user_id, store=True) moi_name = ("Creating %s... When finished, please click the 'Success' " "link to the right" % analysis.name) moi_result_url = '%s/analysis/results/%d' % (qiita_config.portal_dir, analysis_id) submit(ctx_default, moi_group['id'], moi_name, moi_result_url, run_analysis, analysis_id, cmd_split, rarefaction_depth=rarefaction_depth, merge_duplicated_sample_ids=mdsi) r_client.hset('analyis-map', analysis_id, moi_group['id']) self.render("analysis_waiting.html", group_id=moi_group['id'], aname=analysis.name)
def post(self): name = self.get_argument("jobname", None) group_name = self.get_argument("jobgroup", None) parent = get_id_from_user("no-user") job_url = "/result" if name is not None: submit(ctx_default, parent, name, job_url, say_hello, name) else: group_url = "/group" group = create_info(group_name, 'group', url=group_url, parent=parent, store=True) group_id = group['id'] for i in range(5): name = group_name + '-%d' % i submit(ctx_default, group_id, name, job_url, say_hello, name) self.redirect('/')
def post(self, analysis_id): analysis_id = int(analysis_id) rarefaction_depth = self.get_argument('rarefaction-depth') # convert to integer if rarefaction level given if rarefaction_depth: rarefaction_depth = int(rarefaction_depth) else: rarefaction_depth = None analysis = Analysis(analysis_id) check_analysis_access(self.current_user, analysis) command_args = self.get_arguments("commands") split = [x.split("#") for x in command_args] moi_user_id = get_id_from_user(self.current_user.id) moi_group = create_info(analysis_id, 'group', url='/analysis/', parent=moi_user_id, store=True) moi_name = ("Creating %s... When finished, please click the 'Success' " "link to the right" % analysis.name) moi_result_url = '/analysis/results/%d' % analysis_id submit(ctx_default, moi_group['id'], moi_name, moi_result_url, run_analysis, analysis_id, split, rarefaction_depth=rarefaction_depth) r_client.hset('analyis-map', analysis_id, moi_group['id']) self.render("analysis_waiting.html", group_id=moi_group['id'], aname=analysis.name)
def test_submit(self): def foo(a, b, c=10, **kwargs): return a+b+c for ctx in ctxs: id_, pid_ = submit(ctx, 'no parent', 'test', '/', foo, 1, 2, c=15) self.test_keys.append(id_) self.test_keys.append(pid_) sleep(2) obs = json.loads(r_client.get(id_)) self.assertEqual(obs['result'], 18) self.assertEqual(obs['status'], 'Success') self.assertNotEqual(obs['date_start'], None) self.assertNotEqual(obs['date_end'], None)
def test_submit(self): def foo(a, b, c=10, **kwargs): return a + b + c for ctx in ctxs: id_, pid_ = submit(ctx, 'no parent', 'test', '/', foo, 1, 2, c=15) self.test_keys.append(id_) self.test_keys.append(pid_) sleep(2) obs = json.loads(r_client.get(id_)) self.assertEqual(obs['result'], 18) self.assertEqual(obs['status'], 'Success') self.assertNotEqual(obs['date_start'], None) self.assertNotEqual(obs['date_end'], None)
def _submit_with_deps(self, deps, name, func, *args, **kwargs): """Submit with dependencies Parameters ---------- deps : list of AsyncResult AsyncResults that this new job depend on name : str A job name func : function The function to submit Returns ------- AsyncResult The result returned by IPython's apply_async. """ parent_id = self._group url = None with self._context.bv.temp_flags(after=deps, block=False): _, _, ar = submit(self._context, parent_id, name, url, func, *args, **kwargs) return ar