Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:58:19

0001 #!/usr/bin/env python
0002 #
0003 # Licensed under the Apache License, Version 2.0 (the "License");
0004 # You may not use this file except in compliance with the License.
0005 # You may obtain a copy of the License at
0006 # http://www.apache.org/licenses/LICENSE-2.0OA
0007 #
0008 # Authors:
0009 # - Wen Guan, <wen.guan@cern.ch>, 2024
0010 
0011 
0012 """
0013 operations related to Meta info.
0014 """
0015 
0016 from idds.common.constants import MetaStatus
0017 from idds.orm import meta as orm_meta
0018 from idds.orm.base.session import read_session, transactional_session
0019 
0020 
0021 @transactional_session
0022 def add_meta_item(name, status=MetaStatus.Active, description=None, meta_info=None, session=None):
0023     """
0024     Add a meta item.
0025 
0026     :param name: The meta name.
0027     :param status: The meta status.
0028     :param description: The meta description.
0029     :param meta_info: The metadata.
0030     :param session: The database session.
0031     """
0032     return orm_meta.add_meta_item(name=name, status=status, description=description,
0033                                   meta_info=meta_info, session=session)
0034 
0035 
0036 @read_session
0037 def get_meta_item(name, session=None):
0038     """
0039     Retrieve meta item.
0040 
0041     :param name: The meta name.
0042     :param session: The database session.
0043 
0044     :returns metainfo: dictionary of meta info
0045     """
0046     orm_meta.get_meta_item(name=name, session=session)
0047 
0048 
0049 @read_session
0050 def get_meta_items(session=None):
0051     """
0052     Retrieve meta items.
0053 
0054     :param session: The database session.
0055 
0056     :returns metainfo: List of dictionaries
0057     """
0058     orm_meta.get_meta_items(session=session)