Пример #1
0
    def upload(self, token_ids, token_type, file_name):
        pc = get_picas_credentials.picas_cred()
        if self.pc_database:
            pc.database = self.pc_database
        client = CouchDB(pc.user,
                         pc.password,
                         url='https://picas-lofar.grid.surfsara.nl:6984',
                         connect=True)
        db = client[pc.database]

        tl = TokenList(token_type=token_type, database=db)
        for t_id in token_ids:
            tl.append(
                caToken(database=db, token_type=token_type, token_id=t_id))
        tl.fetch()
        tl.add_attachment(file_name, file_name.split('/')[-1])
    tok.build(TokenJsonBuilder(jsonfile))
    tok.save()
    tok.add_attachment(attachment_name='srm.txt', filename='temp_srm.txt')
    tl.append(tok)

tl.save()

for tok in tl:
    tok['OBSID'] = obsid
    tok['PIPELINE_STEP'] = 'lb_sub6asec_cal1'
    tok['status'] = 'queued'
    tok.save()

tl.add_attachment(
    attachment_name='step1_subtract_lotss.parset',
    filename=
    '/project/sksp/Software/lofar-highres-widefield/testdir/test_with_GRID_LRT/step1_subtract_lotss.parset'
)

print('5) Adding status views.')
view_cal = TokenView('step1_subtract_lotss',
                     condition='doc.PIPELINE_STEP=="lb_sub6asec_cal1"',
                     emit_values=('doc._id', 'doc.status'))
tl.add_token_views()
tl.add_view(view_cal)

tl.save()

print('6) Create and launch the jobs.')
j = submit.SpiderLauncher(numjobs=len(d.keys()),
                          token_type=tok_type,
    if (tok_type + '_scal_' + source + str(cal_obsid)) not in token_ids:
        tok = caToken(database=db,
                      token_type=tok_type,
                      token_id=tok_type + '_scal_' + source + str(cal_obsid))
        with open('temp_srm_{:s}.txt'.format(source), 'w') as f:
            f.write('\n'.join(v))
        tok.build(TokenJsonBuilder(jsonfile))
        tok.save()
        tok.add_attachment(attachment_name='srm.txt',
                           filename='temp_srm_{:s}.txt'.format(source))
        tl.append(tok)
    else:
        continue
tl.add_attachment(
    attachment_name='step3_selfcal_calibrators.parset',
    filename=
    '/project/sksp/Software/lofar-highres-widefield/testdir/test_with_GRID_LRT/step3_selfcal_calibrators.parset'
)
tl.save()

for tok in tl:
    tok['OBSID'] = obsid
    tok['PIPELINE_STEP'] = 'lb_selfcal_cal1'
    tok['status'] = 'queued'
    tok.save()

print('5) Adding status views.')
view_cal = TokenView('step3_selfcal_cals',
                     condition='doc.PIPELINE_STEP=="lb_selfcal_cal1"',
                     emit_values=('doc._id', 'doc.status'))
tl.add_token_views()