CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
querying.factory Class Reference

Public Member Functions

def __init__ (self, connection)
 
def object (self, class_name, pkargs)
 

Public Attributes

 connection
 

Detailed Description

Contains methods for creating objects.

Definition at line 296 of file querying.py.

Constructor & Destructor Documentation

◆ __init__()

def querying.factory.__init__ (   self,
  connection 
)

Definition at line 300 of file querying.py.

300  def __init__(self, connection):
301  self.connection = connection
302 
def __init__(self, dataset, job_number, job_id, job_name, isDA, isMC, applyBOWS, applyEXTRACOND, extraconditions, runboundary, lumilist, intlumi, maxevents, gt, allFromGT, alignmentDB, alignmentTAG, apeDB, apeTAG, bowDB, bowTAG, vertextype, tracktype, refittertype, ttrhtype, applyruncontrol, ptcut, CMSSW_dir, the_dir)

Member Function Documentation

◆ object()

def querying.factory.object (   self,
  class_name,
  pkargs 
)

Definition at line 306 of file querying.py.

References models.apply_filters(), querying.factory.connection, and ReggeGribovPartonMC_EposLHC_2760GeV_PbPb_cfi.model.

306  def object(self, class_name, **pkargs):
307  from .data_sources import json_list
308  from .models import apply_filters
309  # get the class that self.connection holds from the class name
310  model = self.connection.model(class_name)
311 
312  if self.connection.session == None:
313  return None
314 
315  # query for the ORM object, and return the appropriate object (None, CondDBFW object, or json_list)
316  model_data = self.connection.session.query(model)
317  if len(list(pkargs.items())) != 0:
318  # apply the filters defined in **kwargs
319  model_data = apply_filters(model_data, model, **pkargs)
320  amount = pkargs["amount"] if "amount" in list(pkargs.keys()) else None
321  model_data = model_data.limit(amount)
322  if model_data.count() > 1:
323  # if we have multiple objects, return a json_list
324  return json_list(model_data.all())
325  elif model_data.count() == 1:
326  # if we have a single object, return that object
327  return model_data.first()
328  else:
329  # if we have no objects returned, return None
330  return None
331  else:
332  # no column arguments were given, so return an empty object
333  new_object = model()
334  new_object.empty = True
335  return new_object
336 
def apply_filters(orm_query, orm_class, filters)
Definition: models.py:181

Member Data Documentation

◆ connection

querying.factory.connection

Definition at line 301 of file querying.py.

Referenced by querying.factory.object(), shell_tests.shell_tests.tearDown(), querying_tests.querying_tests.tearDown(), data_formats_tests.data_formats_tests.tearDown(), data_sources_tests.data_sources_tests.tearDown(), querying_tests.result_type_tests.tearDown(), querying_tests.tag_tests.test_all_tags_empty_tag(), querying_tests.tag_tests.test_all_tags_non_empty_tag(), querying_tests.querying_tests.test_check_connection(), data_formats_tests.data_formats_tests.test_dicts_to_orm_objects(), querying_tests.result_type_tests.test_factory_empty_result(), querying_tests.result_type_tests.test_factory_multiple_results(), querying_tests.result_type_tests.test_factory_no_result(), querying_tests.global_tag_map_tests.test_get_empty_global_tag_map(), querying_tests.iov_tests.test_get_empty_iov(), querying_tests.payload_tests.test_get_empty_payload(), querying_tests.tag_tests.test_get_empty_tag(), querying_tests.global_tag_map_tests.test_get_global_tag_map(), querying_tests.iov_tests.test_get_iov(), querying_tests.iov_tests.test_get_iovs_by_iov_query(), querying_tests.tag_tests.test_get_parent_global_tags(), querying_tests.payload_tests.test_get_parent_tags_payload(), querying_tests.payload_tests.test_get_payload(), querying_tests.tag_tests.test_get_tag(), data_formats_tests.data_formats_tests.test_orm_objects_to_dicts(), querying_tests.misc_tests.test_search_everything(), data_sources_tests.data_sources_tests.test_type_all_iovs(), data_sources_tests.data_sources_tests.test_type_all_tags(), data_sources_tests.data_sources_tests.test_type_parent_global_tags(), and querying_tests.payload_tests.test_type_parent_tags().