Skip to content

Commit

Permalink
Alpha9 (#150)
Browse files Browse the repository at this point in the history
* Update clientType and clientVersion, fixes #149

* Reduce number of times json() property is called, fixes #148

* Check if static access_token exists before developer token refresh, fixes #147

* Bump version to alpha9
  • Loading branch information
sserrata committed Apr 3, 2020
1 parent 754b589 commit d3709b3
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 12 deletions.
8 changes: 8 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# History

## 2.0.0-alpha9 (2020-04-04)

- Now checking if static `access_token` exists before attempting a developer token refresh (#147)
- Reduced the number of times `json()` property is called in `QueryService` and `HTTPClient` (#148)
- Updated `clientType` and `clientVersion` in `create_query()` method (#149)
- Updated `iter_job_results()` to use `pageCursor` instead of deprecated `scrollToken` (#145)
- Switched to using `rowsInPage` instead of `rowsInJob` when updating `stats.records` in `get_job_results()` (#146)

## 2.0.0-alpha8 (2020-03-25)

- Updated docstrings
Expand Down
2 changes: 1 addition & 1 deletion pan_cortex_data_lake/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""Main package for cortex."""

__author__ = "Palo Alto Networks"
__version__ = "2.0.0-a8"
__version__ = "2.0.0-a9"

from .exceptions import ( # noqa: F401
CortexError,
Expand Down
4 changes: 3 additions & 1 deletion pan_cortex_data_lake/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,9 @@ def refresh(self, access_token=None, **kwargs):
if not self.token_lock.locked():
with self.token_lock:
if access_token == self.access_token or access_token is None:
if self.developer_token is not None:
if self.developer_token is not None and not any(
[self.access_token_, os.getenv("PAN_ACCESS_TOKEN")]
):
parsed_provider = urlparse(self.developer_token_provider)
url = "{}://{}".format(
parsed_provider.scheme, parsed_provider.netloc
Expand Down
18 changes: 10 additions & 8 deletions pan_cortex_data_lake/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

from .exceptions import CortexError, HTTPError
from .httpclient import HTTPClient
from . import __version__


class QueryService(object):
Expand Down Expand Up @@ -110,9 +111,9 @@ def create_query(self, job_id=None, query_params=None, **kwargs):
if value is not None:
json.update({name: value})
json.update(
{ # auto-apply cortex-sdk client type and version
"clientType": "cortex-sdk-python",
"clientVersion": "0.1.0",
{
"clientType": "cortex-data-lake-python",
"clientVersion": "%s" % __version__,
}
)
endpoint = "/query/v2/jobs"
Expand Down Expand Up @@ -241,22 +242,23 @@ def iter_job_results(
)
if not r.ok:
raise HTTPError("%s" % r.text)
if r.json()["state"] == "DONE":
page_cursor = r.json()["page"].get("pageCursor")
r_json = r.json()
if r_json["state"] == "DONE":
page_cursor = r_json["page"].get("pageCursor")
if page_cursor is not None:
params["pageCursor"] = page_cursor
yield r
else:
yield r
break
elif r.json()["state"] in ("RUNNING", "PENDING"):
elif r_json["state"] in ("RUNNING", "PENDING"):
yield r
time.sleep(1)
elif r.json()["state"] == "FAILED":
elif r_json["state"] == "FAILED":
yield r
break
else:
raise CortexError("Bad state: %s" % r.json()["state"])
raise CortexError("Bad state: %s" % r_json["state"])

def list_jobs(
self,
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 2.0.0a8
current_version = 2.0.0a9
commit = True
tag = True

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

setup(
name="pan-cortex-data-lake",
version="2.0.0-a8",
version="2.0.0-a9",
description="Python idiomatic SDK for Cortex™ Data Lake.",
long_description=readme + "\n\n" + history,
long_description_content_type="text/markdown",
Expand Down

0 comments on commit d3709b3

Please sign in to comment.