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>, 2019
0010 
0011 
0012 """
0013 operations related to Catalog(Collections and Contents).
0014 """
0015 
0016 from idds.core import catalog
0017 
0018 
0019 def get_collections(scope, name, request_id=None, workload_id=None):
0020     """
0021     Get collections by scope, name, request_id and workload id.
0022 
0023     :param scope: scope of the collection.
0024     :param name: name the the collection.
0025     :param request_id: the request id.
0026     :param workload_id: The workload_id of the request.
0027 
0028     :returns: dict of collections
0029     """
0030     return catalog.get_collections(scope=scope, name=name, request_id=request_id,
0031                                    workload_id=workload_id)
0032 
0033 
0034 def get_contents(coll_scope=None, coll_name=None, request_id=None, workload_id=None, relation_type=None):
0035     """
0036     Get contents with collection scope, collection name, request id, workload id and relation type.
0037 
0038     :param coll_scope: scope of the collection.
0039     :param coll_name: name the the collection.
0040     :param request_id: the request id.
0041     :param workload_id: The workload_id of the request.
0042     :param relation_type: The relation type between the collection and transform: input, outpu, logs and etc.
0043 
0044     :returns: dict of contents
0045     """
0046     return catalog.get_contents(coll_scope=coll_scope, coll_name=coll_name, request_id=request_id,
0047                                 workload_id=workload_id, relation_type=relation_type)
0048 
0049 
0050 def register_output_contents(coll_scope, coll_name, contents, request_id=None, workload_id=None):
0051     """
0052     register contents with collection scope, collection name, request id, workload id and contents.
0053 
0054     :param coll_scope: scope of the collection.
0055     :param coll_name: name the the collection.
0056     :param request_id: the request id.
0057     :param workload_id: The workload_id of the request.
0058     :param contents: list of contents [{'scope': <scope>, 'name': <name>, 'min_id': min_id, 'max_id': max_id, 'path': <path>}].
0059     """
0060     catalog.register_output_contents(coll_scope=coll_scope, coll_name=coll_name, contents=contents,
0061                                      request_id=request_id, workload_id=workload_id)
0062 
0063 
0064 def get_match_contents(coll_scope, coll_name, scope, name, min_id=None, max_id=None,
0065                        request_id=None, workload_id=None, only_return_best_match=False):
0066     """
0067     Get matched contents with collection scope, collection name, scope, name, min_id, max_id,
0068     request id, workload id and only_return_best_match.
0069 
0070     :param coll_scope: scope of the collection.
0071     :param coll_name: name the the collection.
0072     :param scope: scope of the content.
0073     :param name: name of the content.
0074     :param min_id: min_id of the content.
0075     :param max_id: max_id of the content.
0076     :param request_id: the request id.
0077     :param workload_id: The workload_id of the request.
0078     :param only_return_best_match: only return best matched content if it's true.
0079 
0080     :returns: list of contents
0081     """
0082     return catalog.get_match_contents(coll_scope=coll_scope, coll_name=coll_name, scope=scope, name=name, min_id=min_id,
0083                                       max_id=max_id, request_id=request_id, workload_id=workload_id,
0084                                       only_return_best_match=only_return_best_match)