From e8616bc86bc0ed2c56851f0055f08678bcc69163 Mon Sep 17 00:00:00 2001 From: erickson Date: Tue, 18 May 2010 21:30:37 +0000 Subject: [PATCH] only load dynamic test objects when they are not already defined in the properties file; in batch api loader, only load/parse the file once at start (instead of once per thread); removed some unused code git-svn-id: svn://svn.open-ils.org/ILS-Contrib/constrictor/trunk@887 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- contrib/evergreen/eg_batch.py | 41 +++----------------------------------- contrib/evergreen/eg_data.py | 46 ++++++++++++++++++++++++++++++------------- 2 files changed, 35 insertions(+), 52 deletions(-) diff --git a/contrib/evergreen/eg_batch.py b/contrib/evergreen/eg_batch.py index 32ec881b6..0dcc3019f 100755 --- a/contrib/evergreen/eg_batch.py +++ b/contrib/evergreen/eg_batch.py @@ -25,41 +25,7 @@ class BatchScript(Script): def __init__(self): Script.__init__(self) self.calls = [] - self.loaded = False self.data_mgr = None - self.bibs = [] - self.copies = [] - self.call_numbers = [] - self.org_unis = [] - - - ''' - def _fetch_dynamic_data(self): - pcrud = 'open-ils.pcrud' - method = 'open-ils.pcrud.search.%s.atomic' - - auth = eg_utils.authtoken() - thread_count = props.get_property('constrictor.numThreads') - - self.bibs = BatchMethodTask(pcrud, method % 'bre').start( - params = [auth, {'deleted' : 'f', 'id' : {'>' : 0}}, {'limit' : thread_count}]) - - self.copies = BatchMethodTask(pcrud, method % 'acp').start( - params = [auth, {'deleted' : 'f', 'id' : {'>' : 0}}, {'limit' : thread_count}]) - - self.call_numbers = BatchMethodTask(pcrud, method % 'acn').start( - params = [auth, {'deleted' : 'f', 'id' : {'>' : 0}}, {'limit' : thread_count}]) - - self.org_units = BatchMethodTask(pcrud, method % 'aou').start( - params = [auth, {'id' : {'>' : 0}}, {'limit' : thread_count}]) - - self.data_mgr.insert_prop_data(eg_data.PROP_TITLE_ID, [obj.id() for obj in self.bibs]) - self.data_mgr.insert_prop_data(eg_data.PROP_COPY_ID, [obj.id() for obj in self.copies]) - self.data_mgr.insert_prop_data(eg_data.PROP_COPY_BARCODE, [obj.barcode() for obj in self.copies]) - self.data_mgr.insert_prop_data(eg_data.PROP_CALLNUMBER_ID, [obj.id() for obj in self.call_numbers]) - self.data_mgr.insert_prop_data(eg_data.PROP_ORG_ID, [obj.id() for obj in self.org_units]) - self.data_mgr.insert_prop_data(eg_data.PROP_ORG_SHORTNAME, [obj.shortname() for obj in self.org_units]) - ''' def load_file(self): @@ -147,9 +113,6 @@ class BatchScript(Script): def run(self): - if not self.loaded: - self.load_file() - for idx in range(0, len(self.calls)): call = self.calls[int(random.random() * len(self.calls))] try: @@ -164,4 +127,6 @@ class BatchScript(Script): -ScriptManager.go(BatchScript()) +script = BatchScript() +script.load_file() # load the batch API file +ScriptManager.go(script) diff --git a/contrib/evergreen/eg_data.py b/contrib/evergreen/eg_data.py index e81c1bd84..1f9df6956 100644 --- a/contrib/evergreen/eg_data.py +++ b/contrib/evergreen/eg_data.py @@ -48,24 +48,42 @@ class DataManager(object): auth = eg_utils.authtoken() thread_count = self.props.get_property('constrictor.numThreads') - bibs = DataMethodTask(pcrud, method % 'bre').start( - params = [auth, {'deleted' : 'f', 'id' : {'>' : 0}}, {'limit' : thread_count}]) + if not self.data.get(PROP_TITLE_ID): - copies = DataMethodTask(pcrud, method % 'acp').start( - params = [auth, {'deleted' : 'f', 'id' : {'>' : 0}}, {'limit' : thread_count}]) + bibs = DataMethodTask(pcrud, method % 'bre').start( + params = [auth, {'deleted' : 'f', 'id' : {'>' : 0}}, {'limit' : thread_count}]) - call_numbers = DataMethodTask(pcrud, method % 'acn').start( - params = [auth, {'deleted' : 'f', 'id' : {'>' : 0}}, {'limit' : thread_count}]) + self.insert_prop_data(PROP_TITLE_ID, [obj.id() for obj in bibs]) - org_units = DataMethodTask(pcrud, method % 'aou').start( - params = [auth, {'id' : {'>' : 0}}, {'limit' : thread_count}]) + if not self.data.get(PROP_COPY_ID) or not self.data.get(PROP_COPY_BARCODE): - self.insert_prop_data(PROP_TITLE_ID, [obj.id() for obj in bibs]) - self.insert_prop_data(PROP_COPY_ID, [obj.id() for obj in copies]) - self.insert_prop_data(PROP_COPY_BARCODE, [obj.barcode() for obj in copies]) - self.insert_prop_data(PROP_CALLNUMBER_ID, [obj.id() for obj in call_numbers]) - self.insert_prop_data(PROP_ORG_ID, [obj.id() for obj in org_units]) - self.insert_prop_data(PROP_ORG_SHORTNAME, [obj.shortname() for obj in org_units]) + copies = DataMethodTask(pcrud, method % 'acp').start( + params = [auth, {'deleted' : 'f', 'id' : {'>' : 0}}, {'limit' : thread_count}]) + + if not self.data.get(PROP_COPY_ID): + self.insert_prop_data(PROP_COPY_ID, [obj.id() for obj in copies]) + + if not self.data.get(PROP_COPY_BARCODE): + self.insert_prop_data(PROP_COPY_BARCODE, [obj.barcode() for obj in copies]) + + if not self.data.get(PROP_CALLNUMBER_ID): + + call_numbers = DataMethodTask(pcrud, method % 'acn').start( + params = [auth, {'deleted' : 'f', 'id' : {'>' : 0}}, {'limit' : thread_count}]) + + self.insert_prop_data(PROP_CALLNUMBER_ID, [obj.id() for obj in call_numbers]) + + if not self.data.get(PROP_ORG_ID) or not self.data.get(PROP_ORG_SHORTNAME): + + org_units = DataMethodTask(pcrud, method % 'aou').start( + params = [auth, {'id' : {'>' : 0}}, {'limit' : thread_count}]) + + if not self.data.get(PROP_ORG_ID): + self.insert_prop_data(PROP_ORG_ID, [obj.id() for obj in org_units]) + + if not self.data.get(PROP_ORG_SHORTNAME): + + self.insert_prop_data(PROP_ORG_SHORTNAME, [obj.shortname() for obj in org_units]) def __str__(self): -- 2.11.0