Skip to content

Commit

Permalink
Merge pull request #63 from soay/master
Browse files Browse the repository at this point in the history
return globus urls
  • Loading branch information
agstephens committed Feb 3, 2021
2 parents 74b1edc + 5e9bacb commit 7440473
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pyesgf/search/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ class BaseResult(object):
if available
:property gridftp_url: The url for downloading the result by Globus
if available
:property globus_url: The url for downloading the result by Globus
if available (including endpoint)
:property index_node: The index node from where the metadata is stored.
Calls to ``*_context()`` will optimise queries to only address this node.
Expand Down Expand Up @@ -155,6 +157,15 @@ def gridftp_url(self):

return url

@property
def globus_url(self):
try:
url, mime = self.urls['Globus'][0]
except (KeyError, IndexError):
return None

return url

@property
def index_node(self):
try:
Expand Down
16 changes: 16 additions & 0 deletions tests/test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,22 @@ def test_gridftp_url_in_file_result(self):
assert gridftp_url.split(":")[0] == "gsiftp"
assert file_result.gridftp_url.endswith(".nc")

@pytest.mark.slow
def test_globus_url_in_file_result(self):
conn = SearchConnection(self.test_service, distrib=False)

ctx = conn.new_context(project='CMIP5')
results = ctx.search()

r1 = results[0]
f_ctx = r1.file_context()

file_results = f_ctx.search()
for file_result in file_results:
globus_url = file_result.globus_url
assert globus_url.split(":")[0] == "globus"
assert file_result.globus_url.endswith(".nc")

@pytest.mark.slow
def test_aggregations(self):
conn = SearchConnection(self.test_service, distrib=False)
Expand Down

0 comments on commit 7440473

Please sign in to comment.