Skip to content

Commit

Permalink
Merge pull request #62 from taylorsteffanj/3.1.4
Browse files Browse the repository at this point in the history
Release 3.1.4
  • Loading branch information
taylorsteffanj authored Sep 25, 2024
2 parents 69c2422 + 37b6608 commit 3e8c0d0
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 23 deletions.
2 changes: 1 addition & 1 deletion ibmpairs/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ def __init__(self,
self._version = 3

if host is not None:
self._host = common.ensure_api_path(common.ensure_protocol(host))
self._host = common.ensure_api_path(common.ensure_protocol(host), version)
else:
if self._legacy is True:
self.set_version(2)
Expand Down
28 changes: 18 additions & 10 deletions ibmpairs/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,18 @@ def to_dict(self):
client_dict["authentication"] = self._authentication
if self._body is not None:
client_dict["body"] = self._body
if self._client_id is not None:
client_dict["client_id"] = self._client_id
if self._tenant_id is not None:
client_dict["tenant_id"] = self._tenant_id

try:
if self._client_id is not None:
client_dict["client_id"] = self._client_id
except Exception as e:
pass
try:
if self._tenant_id is not None:
client_dict["tenant_id"] = self._tenant_id
except Exception as e:
pass

if self._legacy is not None:
client_dict["legacy"] = self._legacy
return client_dict
Expand Down Expand Up @@ -274,11 +282,11 @@ def __init__(self,
self._headers = headers
else:
self._headers = dict(constants.CLIENT_JSON_HEADER)

if (host is not None):
self._host = common.ensure_api_path(common.ensure_protocol(host))
self._host = common.ensure_api_path(common.ensure_protocol(host), version)
elif (host is None) and (self._authentication is not None) and (self._authentication.host is not None) and (self._legacy is False):
self._host = common.ensure_api_path(common.ensure_protocol(self._authentication.host))
self._host = common.ensure_api_path(common.ensure_protocol(self._authentication.host), version)
else:
if self._legacy is True:
self.set_version(2)
Expand All @@ -294,7 +302,7 @@ def __init__(self,
else:
self.set_version(3)
self._host = common.ensure_api_path(common.ensure_protocol(constants.CLIENT_URL_V3))

logger.info("HOST: " + self._host)

self._body = body
Expand Down Expand Up @@ -593,7 +601,7 @@ async def async_get(self,
elif ((self._legacy is False) and (client_response.status == 500)):
token_refresh_message = constants.CLIENT_TOKEN_REFRESH_MESSAGE_APIC
if client_response.body is not None:
response_string = client_response.body
response_string = str(client_response.body)
if token_refresh_message in response_string:
logger.info(response_string)
retry = True
Expand Down Expand Up @@ -845,7 +853,7 @@ async def async_post(self,
elif ((self._legacy is False) and (client_response.status == 500)):
token_refresh_message = constants.CLIENT_TOKEN_REFRESH_MESSAGE_APIC
if client_response.body is not None:
response_string = client_response.body
response_string = str(client_response.body)
if token_refresh_message in response_string:
logger.info(response_string)
retry = True
Expand Down
2 changes: 0 additions & 2 deletions ibmpairs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,8 +538,6 @@ def ensure_api_path(host: str,
else:
result = result + "/core" + version_path

print(result)

return result

#
Expand Down
1 change: 1 addition & 0 deletions ibmpairs/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
QUERY_DOWNLOAD_DEFAULT_FOLDER = 'download'
QUERY_WORKER_DEBUG = os.environ.get('QUERY_WORKER_DEBUG', "False")
QUERY_WORKER_DEBUG = False
QUERY_ID_PATTERN = "[0-9]{10}+_[0-9]{8}+"

#
IBM_CLOUD_OBJECT_STORE_CONTROL_URL = 'control.cloud-object-storage.cloud.ibm.com'
Expand Down
21 changes: 11 additions & 10 deletions ibmpairs/query.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Environmental Intelligence: Geospatial APIs SDK (ibmpairs): A Python module to
wrap the core functionality of the Geospatial APIs component.
wrap the core functionality of the Geospatial APIs component.
Copyright 2019-2024 IBM Software: Sustainability, IBM Corp. All Rights Reserved.
Expand Down Expand Up @@ -6498,6 +6498,7 @@ async def async_download(self,
error making request to server,
the status of the request is not 200.
"""

online_skip = False

cli = common.set_client(input_client = client,
Expand Down Expand Up @@ -6530,8 +6531,9 @@ async def async_download(self,

if download_file_name is not None:
self.download_file_name = download_file_name

if self.download_file_name is None:

# None or Rerun
if ((self.download_file_name is None) or (re.match(str(constants.QUERY_ID_PATTERN), self.download_file_name))):
self.download_file_name = self.id

incomplete = True
Expand All @@ -6555,7 +6557,9 @@ async def async_download(self,
# Deleted(31)
# Failed(40)
# FailedConversion(41)

# FailedProcessor(42)
# MaxAllowedQuerySizeExceeded(43)

if query.status_response.status_code == 20:

self._create_download_folder()
Expand Down Expand Up @@ -6726,7 +6730,7 @@ async def async_download(self,
else:
self.download_status = "FAILED"

msg = messages.ERROR_QUERY_FAILED.format(query.id, query.status_response.status, ' and therefore cannot be downloaded.')
msg = messages.ERROR_QUERY_FAILED.format(query.id, query.status_response.status + ': ' + str(query.status_response.message), ' and therefore cannot be downloaded.')
logger.error(msg)
raise common.PAWException(msg)

Expand Down Expand Up @@ -9629,11 +9633,8 @@ def search(self,
float(search_term)
search = aoi_df.query('id ==' + search_term, engine='python')
except:
key = aoi_df.query('key.str.contains("'+search_term+'", case = False)', engine='python')
name = aoi_df.query('name.str.contains("'+ search_term +'", case = False)', engine='python')
search = pandas.concat([key, name])

search.drop_duplicates(subset=None, keep='first', inplace=False)
search = aoi_df.query('key.str.contains("'+search_term+'", case = False)', engine='python')

search.reset_index(inplace=True, drop=True)

return search
Expand Down

0 comments on commit 3e8c0d0

Please sign in to comment.