示例#1
0
def Lochness():
    args = Args('tmp_lochness')
    create_lochness_template(args)
    KeyringAndEncryptLochnessTransfer(args.outdir)

    lochness = config_load_test('tmp_lochness/config.yml', '')
    return lochness
示例#2
0
def test_do_init(args):
    syncArgs = SyncArgs('tmp_lochness')
    create_lochness_template(args)
    syncArgs.config = args.outdir / 'config.yml'
    _ = KeyringAndEncrypt(args.outdir)
    Lochness = config_load_test(syncArgs.config, syncArgs.archive_base)
    show_tree_then_delete('tmp_lochness')
示例#3
0
def syncArgsForLochnessSync(args):
    syncArgs = SyncArgs('tmp_lochness')
    create_lochness_template(args)
    syncArgs.config = args.outdir / 'config.yml'
    syncArgs.update_source(args.sources)
    _ = KeyringAndEncryptLochnessTransfer(args.outdir)

    return syncArgs
示例#4
0
def test_create_lochness_template_for_documentation(args):
    args.outdir = 'lochness_root'
    args.studies = ['BWH', 'McLean']
    args.sources = ['redcap', 'xnat', 'box', 'mindlamp']
    args.poll_interval = 43200
    args.det_csv = '/data/data_entry_trigger_db.csv'
    args.pii_csv = '/data/personally_identifiable_process_mappings.csv'

    create_lochness_template(args)
    show_tree_then_delete('lochness_root')
示例#5
0
def args_and_Lochness():
    args = Args('tmp_lochness')
    create_lochness_template(args)
    keyring = KeyringAndEncrypt(args.outdir)
    for study in args.studies:
        keyring.update_for_redcap(study)

    lochness_obj = config_load_test('tmp_lochness/config.yml', '')

    return args, lochness_obj
示例#6
0
def test_read_phoenix_data(args):
    syncArgs = SyncArgs('tmp_lochness')
    create_lochness_template(args)
    _ = KeyringAndEncrypt(args.outdir)
    args.source = ['xnat', 'box']
    args.studies = ['mclean']
    args.dry = [False]
    Lochness = config.load(syncArgs.config, syncArgs.archive_base)

    for subject in lochness.read_phoenix_metadata(Lochness, args.studies):
        print(subject)
示例#7
0
def test_sync_from_empty(args):
    outdir = 'tmp_lochness'
    args.outdir = outdir
    create_lochness_template(args)
    KeyringAndEncryptRPMS(args.outdir)
    create_fake_rpms_repo()

    dry = False
    study_name = 'StudyA'
    Lochness = config_load_test(f'{args.outdir}/config.yml', '')
    initialize_metadata(Lochness, study_name, 'record_id1', 'Consent')

    for subject in lochness.read_phoenix_metadata(Lochness,
                                                  studies=['StudyA']):
        sync(Lochness, subject, dry)

    # print the structure
    show_tree_then_delete('tmp_lochness')
示例#8
0
def test_do_with_mindlamp(args):
    syncArgs = SyncArgs(args.outdir)
    sources = ['mindlamp']
    syncArgs.update_source(sources)

    create_lochness_template(args)
    syncArgs.config = args.outdir / 'config.yml'
    _ = KeyringAndEncryptMindlamp(args.outdir)


    phoenix_root = args.outdir / 'PHOENIX'
    information_to_add_to_metadata = {'mindlamp': {'subject_id': '1001',
                                                   'source_id': 'U7045332804'}}
    initialize_metadata_test(phoenix_root, 'StudyA',
                             information_to_add_to_metadata)
    
    do(syncArgs)
    show_tree_then_delete('tmp_lochness')
示例#9
0
def args_and_Lochness():
    args = Args('tmp_lochness')
    args.sources = ['box']
    create_lochness_template(args)
    keyring = KeyringAndEncrypt(args.outdir)
    information_to_add_to_metadata = {'box': {
        'subject_id': '1001',
        'source_id': 'O1234'}}

    for study in args.studies:
        keyring.update_for_box(study)

        # update box metadata
        initialize_metadata_test('tmp_lochness/PHOENIX', study,
                                 information_to_add_to_metadata)

    lochness_obj = config_load_test('tmp_lochness/config.yml', '')

    return args, lochness_obj
示例#10
0
def test_lochness_to_lochness_transfer_receive(Lochness):
    print()

    protected_dir = Path(Lochness['phoenix_root']) / 'PROTECTED'

    for i in range(10):
        with tf.NamedTemporaryFile(suffix='tmp.text',
                                   delete=False,
                                   dir=protected_dir) as tmpfilename:

            with open(tmpfilename.name, 'w') as f:
                f.write('ha')

    #pull all
    # lochness_to_lochness_transfer(Lochness, general_only=False)

    with tf.NamedTemporaryFile(suffix='tmp.tar', delete=False,
                               dir='.') as tmpfilename:
        # compress
        compress_new_files(Lochness['lochness_sync_history_csv'],
                           Lochness['phoenix_root'], tmpfilename.name, False)

    show_tree_then_delete('tmp_lochness')

    compressed_file = list(Path('.').glob('tmp*tar'))[0]
    os.popen(f'tar -xf {compressed_file}').read()
    os.remove(str(compressed_file))

    show_tree_then_delete('PHOENIX')

    out_dir = 'DPACC'
    args = DpaccArgs(out_dir)
    create_lochness_template(args)
    update_keyring_and_encrypt_DPACC(args.outdir)

    lochness = config_load_test(f'{out_dir}/config.yml', '')
    lochness_to_lochness_transfer_receive(lochness)

    show_tree_then_delete('DPACC')
示例#11
0
def test_sync_mindlamp(args):
    syncArgs = SyncArgs(args.outdir)
    syncArgs.studies = ['StudyA']
    sources = ['mindlamp']
    syncArgs.update_source(sources)

    create_lochness_template(args)
    syncArgs.config = args.outdir / 'config.yml'
    _ = KeyringAndEncryptMindlamp(args.outdir)


    phoenix_root = args.outdir / 'PHOENIX'
    information_to_add_to_metadata = {'mindlamp': {'subject_id': '1001',
                                                   'source_id': 'U7045332804'}}
    
    initialize_metadata_test(phoenix_root, 'StudyA',
                             information_to_add_to_metadata)
    Lochness = config_load_test(syncArgs.config)
    for subject in lochness.read_phoenix_metadata(Lochness, syncArgs.studies):
        sync(Lochness, subject, False)

    show_tree_then_delete('tmp_lochness')
示例#12
0
def test_create_lochness_template_multiple_study(args):
    args.studies = ['StudyA', 'StudyB']
    create_lochness_template(args)
    show_tree_then_delete('tmp_lochness')
示例#13
0
def test_create_lochness_template(args):
    create_lochness_template(args)
    show_tree_then_delete('tmp_lochness')