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
Changes from 1 commit
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
Next Next commit
printing stacktrace in case of exception
manu-sj committed Sep 16, 2024
commit 4b00b0b1932a7ba67a5c01d731f4eb1b05203882
13 changes: 13 additions & 0 deletions utils/java/src/main/java/com/logicalclocks/utils/MainClass.java
Original file line number Diff line number Diff line change
@@ -121,6 +121,9 @@ 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 {
@@ -130,8 +133,18 @@ 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);
}
}
}
4 changes: 4 additions & 0 deletions utils/python/hsfs_utils.py
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
import json
from datetime import datetime
from typing import Any, Dict
import traceback

import fsspec.implementations.arrow as pfs

@@ -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: