Ejemplo n.º 1
0
# set vars and init sessions for both Molgenis instances
load_dotenv()
rd3_acc = Molgenis(url=environ['MOLGENIS_ACC_HOST'])
rd3_prod = Molgenis(url=environ['MOLGENIS_PROD_HOST'])

rd3_prod.login(username=environ['MOLGENIS_PROD_USR'],
               password=environ['MOLGENIS_PROD_PWD'])

rd3_acc.login(username=environ['MOLGENIS_ACC_USR'],
              password=environ['MOLGENIS_ACC_PWD'])

# read contents of the menu config file
with open('rd3/molgenis_menu.json', 'r') as file:
    menu = file.read()
    file.close()

# parse json and stringify
molgenisMenuJson = json.loads(menu)
menuStringified = json.dumps(molgenisMenuJson)

# push to RD3
rd3_acc.update_one(entity='sys_set_app',
                   id_='app',
                   attr='molgenis_menu',
                   value=menuStringified)
rd3_prod.update_one(entity='sys_set_app',
                    id_='app',
                    attr='molgenis_menu',
                    value=menuStringified)
# encounter a lot of timeout errors and sometimes you won't. I have no idea why
# but it is possible to update the values the good old fashion way.

# import into the subjects table of the current freeze
# rd3.batch_update_one_attr(entity=paths['rd3_subjects'], attr='fid', values=upload_fid)
# rd3.batch_update_one_attr(entity=paths['rd3_subjects'], attr='mid', values=upload_mid)
# rd3.batch_update_one_attr(entity=paths['rd3_subjects'], attr='pid', values=upload_pid)
# rd3.batch_update_one_attr(entity=paths['rd3_subjects'], attr='clinical_status', values=upload_clinical)

# otherwise, import the old way.

# update fid
for index, el in enumerate(upload_fid):
    statusMsg('{} Updating FID for {}'.format(index, el['id']))
    rd3.update_one(entity=paths['rd3_subjects'],
                   id_=el['id'],
                   attr='fid',
                   value=el['fid'])

# update mid
for index, el in enumerate(upload_mid):
    statusMsg('{} Updating MID for {}'.format(index, el['id']))
    rd3.update_one(entity=paths['rd3_subjects'],
                   id_=el['id'],
                   attr='mid',
                   value=el['mid'])

# update pid
for index, el in enumerate(upload_pid):
    statusMsg('{} Updating PID for {}'.format(index, el['id']))
    rd3.update_one(entity=paths['rd3_subjects'],
                   id_=el['id'],