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

[HWORKS-1565][APPEND] Make sure the spark program exits after completion #334

Merged
merged 3 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
11 changes: 11 additions & 0 deletions utils/java/src/main/java/com/logicalclocks/utils/MainClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ public static void main(String[] args) throws Exception {
SparkEngine.getInstance().streamToHudiTable(streamFeatureGroup, writeOptions);
}
success = true;
} catch (Exception e) {
e.printStackTrace();
} finally {
LOGGER.info("Closing spark session...");
try {
Expand All @@ -130,6 +132,15 @@ public static void main(String[] args) throws Exception {
}
if (!success) {
System.exit(1);
manu-sj marked this conversation as resolved.
Show resolved Hide resolved
LOGGER.info("Closing spark session...");
try {
SparkEngine.getInstance().closeSparkSession();
} catch (Exception e) {
LOGGER.error("Error closing spark session", e);
}
if (!success) {
System.exit(1);
}
}
}
System.exit(0);
Expand Down
4 changes: 4 additions & 0 deletions utils/python/hsfs_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import json
from datetime import datetime
from typing import Any, Dict
import traceback

import fsspec.implementations.arrow as pfs

Expand Down Expand Up @@ -304,6 +305,9 @@ def parse_isoformat_date(da: str) -> datetime:
run_feature_monitoring(job_conf)

success = True
except Exception:
# Printing stack trace of exception so that logs are not lost.
print(traceback.format_exc())
manu-sj marked this conversation as resolved.
Show resolved Hide resolved
finally:
if spark is not None:
try:
Expand Down
Loading