Skip to content

Commit

Permalink
Merge pull request #23 from materials-data-facility/forge-dev
Browse files Browse the repository at this point in the history
Forge dev
  • Loading branch information
jgaff authored Mar 14, 2018
2 parents 889be4b + e9d8803 commit 5d9a022
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
Untitled*.ipynb

*.cache*
.pytest_cache*

*temp/*

Expand Down
1 change: 1 addition & 0 deletions mdf_forge/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .forge import Forge
21 changes: 10 additions & 11 deletions mdf_forge/forge.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand All @@ -49,12 +50,12 @@ 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:
clients = toolbox.anonymous_login(services)
services = kwargs.get('services', self.__anon_services)
clients = mdf_toolbox.anonymous_login(services)
else:
clients = toolbox.login(credentials={
services = kwargs.get('services', self.__auth_services)
clients = mdf_toolbox.login(credentials={
"app_name": self.__app_name,
"services": services,
"index": self.index})
Expand Down Expand Up @@ -820,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
Expand Down Expand Up @@ -1210,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
Expand Down Expand Up @@ -1298,7 +1299,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"])
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

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"
" to interface and leverage the MDF Data Discovery service. "
"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",
Expand Down
6 changes: 3 additions & 3 deletions tests/test_forge.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit 5d9a022

Please sign in to comment.