Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def wait_for_athena_query(session: Session, query_execution_id: str, poll: int =
state = get_query_execution(session, query_execution_id)["QueryExecution"]["Status"][
"State"
]
if state in ("SUCCEEDED", "FAILED"):
if state in ("SUCCEEDED", "FAILED", "CANCELLED"):
logger.info("Query %s %s.", query_execution_id, state.lower())
break
logger.info("Query %s is being executed.", query_execution_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
ingest_dataframe,
get_session_from_role,
_is_collection_column,
wait_for_athena_query,
)


Expand Down Expand Up @@ -201,6 +202,22 @@ def test_raises_when_no_metastore(self, mock_fg_class):
create_athena_query("my-fg", session)


class TestWaitForAthenaQuery:
@pytest.mark.parametrize("terminal_state", ["SUCCEEDED", "FAILED", "CANCELLED"])
@patch("sagemaker.mlops.feature_store.feature_utils.time.sleep")
@patch("sagemaker.mlops.feature_store.feature_utils.get_query_execution")
def test_returns_on_terminal_state(self, mock_get, mock_sleep, terminal_state):
mock_get.side_effect = [
{"QueryExecution": {"Status": {"State": "RUNNING"}}},
{"QueryExecution": {"Status": {"State": terminal_state}}},
]

wait_for_athena_query(Mock(), "query-id", poll=1)

assert mock_get.call_count == 2
mock_sleep.assert_called_once_with(1)


class TestIngestDataframe:
@patch("sagemaker.mlops.feature_store.feature_utils.IngestionManagerPandas")
@patch("sagemaker.mlops.feature_store.feature_utils.CoreFeatureGroup")
Expand Down
Loading