Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize REST API workload by using Session and slowing down polling loop #220

Merged
merged 2 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

## Changes

- [195](https:/dremio/dbt-dremio/issues/195) Ensure the adapter does not try and create folders in object storage source
- [#195](https:/dremio/dbt-dremio/issues/195) Ensure the adapter does not try and create folders in object storage source
- [#220](https:/dremio/dbt-dremio/pull/220) Optimize networking performance with Dremio server


# dbt-dremio v1.5.1
Expand Down
4 changes: 4 additions & 0 deletions dbt/adapters/dremio/api/cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
# limitations under the License.


import time

import agate

from dbt.adapters.dremio.api.rest.endpoints import (
Expand Down Expand Up @@ -123,6 +125,8 @@ def _populate_rowcount(self):
job_status_state = job_status_response["jobState"]

while True:
time.sleep(0.2)

if job_status_state != last_job_state:
logger.debug(f"Job State = {job_status_state}")

Expand Down
7 changes: 4 additions & 3 deletions dbt/adapters/dremio/api/rest/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@

logger = AdapterLogger("dremio")

session = requests.Session()

def _get(url, request_headers, details="", ssl_verify=True):
response = requests.get(url, headers=request_headers, verify=ssl_verify)
response = session.get(url, headers=request_headers, verify=ssl_verify)
return _check_error(response, details)


Expand All @@ -55,7 +56,7 @@ def _post(
):
if isinstance(json, str):
json = jsonlib.loads(json)
response = requests.post(
response = session.post(
url,
headers=request_headers,
timeout=timeout,
Expand All @@ -66,7 +67,7 @@ def _post(


def _delete(url, request_headers, details="", ssl_verify=True):
response = requests.delete(url, headers=request_headers, verify=ssl_verify)
response = session.delete(url, headers=request_headers, verify=ssl_verify)
return _check_error(response, details)


Expand Down