Skip to content

Commit

Permalink
Merge pull request #143 from moj-analytical-services/boto3_session_fix
Browse files Browse the repository at this point in the history
Pass boto3_session
  • Loading branch information
gwionap authored Sep 27, 2024
2 parents 994427e + 78840c8 commit c2e7bd2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## v5.6.4 - 2024-09-27

- Explicitly pass boto3_session to helper functions

## v5.6.3 - 2024-08-15

Expand Down
2 changes: 1 addition & 1 deletion pydbtools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@
)
from .utils import s3_path_join # noqa: F401

__version__ = "5.6.3"
__version__ = "5.6.4"
14 changes: 7 additions & 7 deletions pydbtools/_wrangler.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,11 @@ def create_temp_table(
table_path = os.path.join(db_path, ts, table_name)
temp_db_name = get_database_name_from_userid(user_id)

_ = create_temp_database(temp_db_name, boto3_session)
_ = create_temp_database(temp_db_name, boto3_session=boto3_session)

# Clear out table every time, making sure other tables aren't being
# cleared out
delete_temp_table(table_name)
delete_temp_table(table_name, boto3_session=boto3_session)

ctas_query = f"""
CREATE TABLE {temp_db_name}.{table_name}
Expand Down Expand Up @@ -502,9 +502,9 @@ def delete_temp_table(table: str, boto3_session=None):
does not exist
"""

user_id, table_dir = get_user_id_and_table_dir()
user_id, table_dir = get_user_id_and_table_dir(boto3_session=boto3_session)
database = get_database_name_from_userid(user_id)
_create_temp_database(database)
_create_temp_database(database, boto3_session=boto3_session)

if table in list(tables(database=database, limit=None)["Table"]):
path = get_table_location(
Expand Down Expand Up @@ -614,11 +614,11 @@ def dataframe_to_temp_table(df: pd.DataFrame, table: str, boto3_session=None) ->
table (str): The name of the table in the temporary database
boto3_session: opeional boto3 sesssion
"""
user_id, table_dir = get_user_id_and_table_dir()
user_id, table_dir = get_user_id_and_table_dir(boto3_session=boto3_session)
db = get_database_name_from_userid(user_id)
_create_temp_database(db)
_create_temp_database(db, boto3_session=boto3_session)

delete_temp_table(table)
delete_temp_table(table, boto3_session=boto3_session)

# Include timestamp in path to avoid permissions problems with
# previous sessions
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool]
[tool.poetry]
name = "pydbtools"
version = "5.6.3"
version = "5.6.4"
description = "A python package to query data via amazon athena and bring it into a pandas df using aws-wrangler."
license = "MIT"
authors = ["Karik Isichei <[email protected]>"]
Expand Down

0 comments on commit c2e7bd2

Please sign in to comment.