From 235a44be66e26c8540e80d489d445e2d4dbd3f58 Mon Sep 17 00:00:00 2001 From: Steve Nyemba Date: Wed, 19 Jun 2024 08:38:46 -0500 Subject: [PATCH] bug fix: registry and parameter handling --- README.md | 10 +++++++++- info/__init__.py | 6 ++++++ transport/__init__.py | 11 ++++++++--- transport/registry.py | 5 +++++ 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 42bc859..dd2beb1 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,14 @@ Within the virtual environment perform the following : pip install git+https://github.com/lnyemba/data-transport.git +## What's new + +Unlike older versions 2.0 and under, we focus on collaborative environments like jupyter-x servers; apache zeppelin: + + 1. Simpler syntax to create reader or writer + 2. auth-file registry that can be referenced using a label + + ## Learn More -We have available notebooks with sample code to read/write against mongodb, couchdb, Netezza, PostgreSQL, Google Bigquery, Databricks, Microsoft SQL Server, MySQL ... Visit [data-transport homepage](https://healthcareio.the-phi.com/data-transport) \ No newline at end of file +We have available notebooks with sample code to read/write against mongodb, couchdb, Netezza, PostgreSQL, Google Bigquery, Databricks, Microsoft SQL Server, MySQL ... Visit [data-transport homepage](https://healthcareio.the-phi.com/data-transport) diff --git a/info/__init__.py b/info/__init__.py index d34b2f4..d84150e 100644 --- a/info/__init__.py +++ b/info/__init__.py @@ -12,3 +12,9 @@ The above copyright notice and this permission notice shall be included in all c 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. """ + +__whatsnew__=f"""version {__version__}, focuses on collaborative environments like jupyter-base servers (apache zeppelin; jupyter notebook, jupyterlab, jupyterhub) + + 1. simpler syntax to create readers/writers + 2. auth-file registry that can be referenced using a label +""" diff --git a/transport/__init__.py b/transport/__init__.py index 27f2efb..6062453 100644 --- a/transport/__init__.py +++ b/transport/__init__.py @@ -22,7 +22,7 @@ from transport import sql, nosql, cloud, other import pandas as pd import json import os -from info import __version__,__author__,__email__,__license__,__app_name__ +from info import __version__,__author__,__email__,__license__,__app_name__,__whatsnew__ from transport.iowrapper import IWriter, IReader, IETL from transport.plugins import PluginLoader from transport import providers @@ -38,7 +38,11 @@ def init(): if _provider_name.startswith('__') or _provider_name == 'common': continue PROVIDERS[_provider_name] = {'module':getattr(_module,_provider_name),'type':_module.__name__} - +def _getauthfile (path) : + f = open(path) + _object = json.loads(f.read()) + f.close() + return _object def instance (**_args): """ This function returns an object of to read or write from a supported database provider/vendor @@ -82,7 +86,8 @@ def instance (**_args): if _info : # - _args = dict(_args,**_info) + # _args = dict(_args,**_info) + _args = dict(_info,**_args) #-- we can override the registry parameters with our own arguments if 'provider' in _args and _args['provider'] in PROVIDERS : _info = PROVIDERS[_args['provider']] diff --git a/transport/registry.py b/transport/registry.py index b8d5b16..ad94481 100644 --- a/transport/registry.py +++ b/transport/registry.py @@ -10,6 +10,11 @@ This class manages data from the registry and allows (read only) """ REGISTRY_PATH=os.sep.join([os.environ['HOME'],'.data-transport']) +# +# This path can be overriden by an environment variable ... +# +if 'DATA_TRANSPORT_REGISTRY_PATH' in os.environ : + REGISTRY_PATH = os.environ['DATA_TRANSPORT_REGISTRY_PATH'] REGISTRY_FILE= 'transport-registry.json' DATA = {}