From 35b261edbfe1bfd051c7d3803cff77582d2b33ba Mon Sep 17 00:00:00 2001 From: Steve Nyemba Date: Fri, 19 Jan 2024 23:55:35 -0600 Subject: [PATCH] bug fix: etl, mongodb --- info/__init__.py | 12 ++++++++++++ transport/mongo.py | 25 +++++++------------------ transport/providers.py | 3 ++- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/info/__init__.py b/info/__init__.py index ff8bcbb..d5e703a 100644 --- a/info/__init__.py +++ b/info/__init__.py @@ -1,2 +1,14 @@ __author__ = 'The Phi Technology' __version__= '1.9.6' +__license__=""" + + +Copyright 2010 - 2024, Steve L. Nyemba + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +""" diff --git a/transport/mongo.py b/transport/mongo.py index b4338b4..c7b5ed8 100644 --- a/transport/mongo.py +++ b/transport/mongo.py @@ -15,26 +15,12 @@ import gridfs # from transport import Reader,Writer import sys if sys.version_info[0] > 2 : - from transport.common import Reader, Writer + from transport.common import Reader, Writer, IEncoder else: from common import Reader, Writer import json import re from multiprocessing import Lock, RLock - -def IEncoder (self,object): - if type(object) == np.integer : - return int(object) - elif type(object) == np.floating: - return float(object) - elif type(object) == np.ndarray : - return object.tolist() - elif type(object) == datetime : - return o.isoformat() - else: - return super(IEncoder,self).default(object) - - class Mongo : lock = RLock() """ @@ -93,7 +79,7 @@ class Mongo : q = self.uid in self.client[self.dbname].list_collection_names() return p and q def setattr(self,key,value): - _allowed = ['host','port','db','doc','authSource','mechanism'] + _allowed = ['host','port','db','doc','collection','authSource','mechanism'] if key in _allowed : setattr(self,key,value) pass @@ -113,10 +99,13 @@ class MongoReader(Mongo,Reader): # # @TODO: cmd = {} + if 'aggregate' not in cmd and 'aggregate' not in args: + cmd['aggregate'] = self.uid + elif 'aggregate' in args : + cmd['aggregate'] = args['aggregate'] if 'pipeline' in args : cmd['pipeline']= args['pipeline'] - if 'aggregate' not in cmd : - cmd['aggregate'] = self.uid + if 'pipeline' not in args or 'aggregate' not in cmd : cmd = args['mongo'] if 'mongo' in args else args['cmd'] if "aggregate" in cmd : diff --git a/transport/providers.py b/transport/providers.py index 3f70a38..ddb2fcb 100644 --- a/transport/providers.py +++ b/transport/providers.py @@ -95,7 +95,8 @@ PROVIDERS = { MONGODB:{'read':mongo.MongoReader,'write':mongo.MongoWriter,'default':{'port':27017,'host':'localhost'}}, COUCHDB:{'read':couch.CouchReader,'writer':couch.CouchWriter,'default':{'host':'localhost','port':5984}}, - ETL :{'read':etl.Transporter,'write':etl.Transporter} +# ETL :{'read':etl.Transporter,'write':etl.Transporter} + ETL :{'read':etl.instance,'write':etl.instance} } DEFAULT = {PG:{'host':'localhost','port':5432},MYSQL:{'host':'localhost','port':3306}} DEFAULT[MONGODB] = {'port':27017,'host':'localhost'}