From 260099106ba631f73007c74814e9f35d027adf75 Mon Sep 17 00:00:00 2001 From: jgaff Date: Fri, 9 Feb 2018 14:49:15 -0600 Subject: [PATCH 1/4] Remove old Search fix --- mdf_forge/__init__.py | 1 + mdf_forge/forge.py | 4 +--- setup.cfg | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/mdf_forge/__init__.py b/mdf_forge/__init__.py index e69de29..6e5db86 100644 --- a/mdf_forge/__init__.py +++ b/mdf_forge/__init__.py @@ -0,0 +1 @@ +from .forge import Forge diff --git a/mdf_forge/forge.py b/mdf_forge/forge.py index daf218d..5ccf2e9 100644 --- a/mdf_forge/forge.py +++ b/mdf_forge/forge.py @@ -1298,7 +1298,5 @@ def mapping(self, index): dict: The full mapping for the index. """ return (self.__search_client.get( - # TODO: Re-enable when Search handles index UUIDs - # "/unstable/index/{}/mapping".format(self.__translate_index(index))) - "/unstable/index/{}/mapping".format(index)) + "/unstable/index/{}/mapping".format(self.__translate_index(index))) ["mappings"]) diff --git a/setup.cfg b/setup.cfg index 585ec41..73c5409 100644 --- a/setup.cfg +++ b/setup.cfg @@ -6,5 +6,5 @@ universal = 1 addopts = --ignore=setup.py --cov=mdf_forge [flake8] -exclude = .git,*.egg* +exclude = .git,*.egg*, *__init__.py max-line-length = 100 From 9e8102b5e08cdd10efa07cc8c7d56997e9d93bf9 Mon Sep 17 00:00:00 2001 From: jgaff Date: Fri, 16 Feb 2018 16:26:14 -0600 Subject: [PATCH 2/4] Bugfix Fix Forge creation in anonymous mode still attempting login to auth-only mdf service. --- mdf_forge/forge.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mdf_forge/forge.py b/mdf_forge/forge.py index 5ccf2e9..421da07 100644 --- a/mdf_forge/forge.py +++ b/mdf_forge/forge.py @@ -26,7 +26,8 @@ class Forge: index is the Globus Search index to be used. """ __default_index = "mdf" - __services = ["mdf", "transfer", "search"] + __auth_services = ["mdf", "transfer", "search"] + __anon_services = ["search"] __app_name = "MDF_Forge" def __init__(self, index=__default_index, local_ep=None, anonymous=False, **kwargs): @@ -49,11 +50,11 @@ def __init__(self, index=__default_index, local_ep=None, anonymous=False, **kwar self.index = index self.local_ep = local_ep - services = kwargs.get('services', self.__services) - if self.__anonymous: + services = kwargs.get('services', self.__anon_services) clients = toolbox.anonymous_login(services) else: + services = kwargs.get('services', self.__auth_services) clients = toolbox.login(credentials={ "app_name": self.__app_name, "services": services, From 72cab057b7f157b193cffad0503fac9659ddd563 Mon Sep 17 00:00:00 2001 From: jgaff Date: Mon, 26 Feb 2018 14:17:20 -0600 Subject: [PATCH 3/4] Update Toolbox imports (will fail testing) Update Toolbox imports in advance of releasing next Toolbox version. This does mean that this commit will fail testing until the Toolbox import changes are live in PyPI. --- .gitignore | 1 + mdf_forge/forge.py | 10 +++++----- tests/test_forge.py | 6 +++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 1ae5326..36e0bd1 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ Untitled*.ipynb *.cache* +.pytest_cache* *temp/* diff --git a/mdf_forge/forge.py b/mdf_forge/forge.py index 421da07..e7774bb 100644 --- a/mdf_forge/forge.py +++ b/mdf_forge/forge.py @@ -6,7 +6,7 @@ from six import print_, string_types -from mdf_toolbox import toolbox +import mdf_toolbox # Maximum recommended number of HTTP file transfers # Large transfers are much better suited to Globus Transfer use @@ -52,10 +52,10 @@ def __init__(self, index=__default_index, local_ep=None, anonymous=False, **kwar if self.__anonymous: services = kwargs.get('services', self.__anon_services) - clients = toolbox.anonymous_login(services) + clients = mdf_toolbox.anonymous_login(services) else: services = kwargs.get('services', self.__auth_services) - clients = toolbox.login(credentials={ + clients = mdf_toolbox.login(credentials={ "app_name": self.__app_name, "services": services, "index": self.index}) @@ -821,7 +821,7 @@ def globus_download(self, results, dest=".", dest_ep=None, preserve_dir=False, results = results[0] if not dest_ep: if not self.local_ep: - self.local_ep = toolbox.get_local_ep(self.__transfer_client) + self.local_ep = mdf_toolbox.get_local_ep(self.__transfer_client) dest_ep = self.local_ep # Assemble the transfer data @@ -1211,7 +1211,7 @@ def search(self, q=None, index=None, advanced=None, limit=SEARCH_LIMIT, info=Fal "limit": limit, "offset": 0 } - res = toolbox.gmeta_pop(self.__search_client.post_search(uuid_index, qu), info=info) + res = mdf_toolbox.gmeta_pop(self.__search_client.post_search(uuid_index, qu), info=info) # Add additional info if info: res[1]["query"] = qu diff --git a/tests/test_forge.py b/tests/test_forge.py index c0cd15c..ac584cd 100644 --- a/tests/test_forge.py +++ b/tests/test_forge.py @@ -4,12 +4,12 @@ import globus_sdk from globus_sdk.exc import SearchAPIError from mdf_forge import forge -from mdf_toolbox import toolbox +import mdf_toolbox # Manually logging in for Query testing -query_search_client = toolbox.login(credentials={"app_name": "MDF_Forge", - "services": ["search"]})["search"] +query_search_client = mdf_toolbox.login(credentials={"app_name": "MDF_Forge", + "services": ["search"]})["search"] def test_query_init(): From e9d8803850e08ca4293103def62d407af0e7b8b7 Mon Sep 17 00:00:00 2001 From: jgaff Date: Mon, 5 Mar 2018 10:52:56 -0600 Subject: [PATCH 4/4] Require newest Toolbox, increment version number --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index fd1d7ca..dabc8a6 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name='mdf_forge', - version='0.5.1', + version='0.5.2', packages=['mdf_forge'], description='Materials Data Facility python package', long_description=("Forge is the Materials Data Facility Python package" @@ -10,7 +10,7 @@ "Forge allows users to perform simple queries and " "facilitiates moving and synthesizing results."), install_requires=[ - "mdf-toolbox>=0.1.4", + "mdf-toolbox>=0.1.6", "globus-sdk>=1.4.1", "requests>=2.18.4", "tqdm>=4.19.4",