comparison omero_metadata_upload.py @ 2:e41f70e69349 draft

planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 266752b0162fbdb32f132a6702cb661ae36f48f0
author ufz
date Thu, 12 Sep 2024 16:30:50 +0000
parents 352e9d4eaf70
children 4291d37da555
comparison
equal deleted inserted replaced
1:588d6fa22fc4 2:e41f70e69349
1 import argparse 1 import argparse
2 import json
2 from datetime import datetime 3 from datetime import datetime
3 4
4 import ezomero as ez 5 import ezomero as ez
5 import pandas as pd 6 import pandas as pd
6 7
71 log_error(f"Connection error: {str(e)}") 72 log_error(f"Connection error: {str(e)}")
72 73
73 74
74 if __name__ == "__main__": 75 if __name__ == "__main__":
75 parser = argparse.ArgumentParser(description='Import metadata into OMERO.') 76 parser = argparse.ArgumentParser(description='Import metadata into OMERO.')
76 parser.add_argument('--user', required=True, help='OMERO username') 77 parser.add_argument("--credential-file", dest="credential_file", type=str, required=True, help="Credential file (JSON file with username and password for OMERO)")
77 parser.add_argument('--pws', required=True, help='OMERO password')
78 parser.add_argument('--host', required=True, help='OMERO host') 78 parser.add_argument('--host', required=True, help='OMERO host')
79 parser.add_argument('--port', required=True, type=int, help='OMERO port') 79 parser.add_argument('--port', required=True, type=int, help='OMERO port')
80 parser.add_argument('--obj_type', required=True, choices=['project', 'screen', 'dataset', 'image'], 80 parser.add_argument('--obj_type', required=True, choices=['project', 'screen', 'dataset', 'image'],
81 help='Type of OMERO object') 81 help='Type of OMERO object')
82 parser.add_argument('--did', type=int, help='ID of the object (if it exists)') 82 parser.add_argument('--did', type=int, help='ID of the object (if it exists)')
85 parser.add_argument('--an_name', required=True, help='Namespace or title for the annotation') 85 parser.add_argument('--an_name', required=True, help='Namespace or title for the annotation')
86 parser.add_argument('--log_file', default='metadata_import_log.txt', help='Path to the log file') 86 parser.add_argument('--log_file', default='metadata_import_log.txt', help='Path to the log file')
87 87
88 args = parser.parse_args() 88 args = parser.parse_args()
89 89
90 metadata_import_ezo(user=args.user, pws=args.pws, host=args.host, port=args.port, 90 with open(args.credential_file, 'r') as f:
91 crds = json.load(f)
92
93 metadata_import_ezo(user=crds['username'], pws=crds['password'], host=args.host, port=args.port,
91 obj_type=args.obj_type, did=args.did, ann_type=args.ann_type, 94 obj_type=args.obj_type, did=args.did, ann_type=args.ann_type,
92 ann_file=args.ann_file, an_name=args.an_name, log_file=args.log_file) 95 ann_file=args.ann_file, an_name=args.an_name, log_file=args.log_file)