batch-analytics 0.3.1__tar.gz → 0.3.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {batch_analytics-0.3.1 → batch_analytics-0.3.2}/PKG-INFO +1 -1
- {batch_analytics-0.3.1 → batch_analytics-0.3.2}/pyproject.toml +1 -1
- {batch_analytics-0.3.1 → batch_analytics-0.3.2}/src/batch_analytics/job_runner.py +25 -13
- {batch_analytics-0.3.1 → batch_analytics-0.3.2}/src/batch_analytics.egg-info/PKG-INFO +1 -1
- {batch_analytics-0.3.1 → batch_analytics-0.3.2}/README.md +0 -0
- {batch_analytics-0.3.1 → batch_analytics-0.3.2}/setup.cfg +0 -0
- {batch_analytics-0.3.1 → batch_analytics-0.3.2}/src/batch_analytics/__init__.py +0 -0
- {batch_analytics-0.3.1 → batch_analytics-0.3.2}/src/batch_analytics/__main__.py +0 -0
- {batch_analytics-0.3.1 → batch_analytics-0.3.2}/src/batch_analytics/analytics/__init__.py +0 -0
- {batch_analytics-0.3.1 → batch_analytics-0.3.2}/src/batch_analytics/analytics/correlation.py +0 -0
- {batch_analytics-0.3.1 → batch_analytics-0.3.2}/src/batch_analytics/analytics/linear_regression.py +0 -0
- {batch_analytics-0.3.1 → batch_analytics-0.3.2}/src/batch_analytics/analytics/pca_clustering.py +0 -0
- {batch_analytics-0.3.1 → batch_analytics-0.3.2}/src/batch_analytics/analytics/t_test.py +0 -0
- {batch_analytics-0.3.1 → batch_analytics-0.3.2}/src/batch_analytics/config.py +0 -0
- {batch_analytics-0.3.1 → batch_analytics-0.3.2}/src/batch_analytics/extract.py +0 -0
- {batch_analytics-0.3.1 → batch_analytics-0.3.2}/src/batch_analytics/log.py +0 -0
- {batch_analytics-0.3.1 → batch_analytics-0.3.2}/src/batch_analytics/modules.py +0 -0
- {batch_analytics-0.3.1 → batch_analytics-0.3.2}/src/batch_analytics/output/__init__.py +0 -0
- {batch_analytics-0.3.1 → batch_analytics-0.3.2}/src/batch_analytics/output/base.py +0 -0
- {batch_analytics-0.3.1 → batch_analytics-0.3.2}/src/batch_analytics/output/clickhouse.py +0 -0
- {batch_analytics-0.3.1 → batch_analytics-0.3.2}/src/batch_analytics/output/local.py +0 -0
- {batch_analytics-0.3.1 → batch_analytics-0.3.2}/src/batch_analytics/output/s3.py +0 -0
- {batch_analytics-0.3.1 → batch_analytics-0.3.2}/src/batch_analytics/transform.py +0 -0
- {batch_analytics-0.3.1 → batch_analytics-0.3.2}/src/batch_analytics.egg-info/SOURCES.txt +0 -0
- {batch_analytics-0.3.1 → batch_analytics-0.3.2}/src/batch_analytics.egg-info/dependency_links.txt +0 -0
- {batch_analytics-0.3.1 → batch_analytics-0.3.2}/src/batch_analytics.egg-info/entry_points.txt +0 -0
- {batch_analytics-0.3.1 → batch_analytics-0.3.2}/src/batch_analytics.egg-info/requires.txt +0 -0
- {batch_analytics-0.3.1 → batch_analytics-0.3.2}/src/batch_analytics.egg-info/top_level.txt +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "batch-analytics"
|
|
7
|
-
version = "0.3.
|
|
7
|
+
version = "0.3.2"
|
|
8
8
|
description = "PySpark batch analytics: Extract, Transform, Stage, and analytical modules (linear regression, correlation, PCA, t-test)."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.8"
|
|
@@ -10,6 +10,7 @@ import sys
|
|
|
10
10
|
import uuid
|
|
11
11
|
from pathlib import Path
|
|
12
12
|
from typing import Dict, List, Optional
|
|
13
|
+
from urllib.parse import urlparse
|
|
13
14
|
|
|
14
15
|
from pyspark.sql import SparkSession
|
|
15
16
|
|
|
@@ -27,6 +28,17 @@ logging.basicConfig(
|
|
|
27
28
|
logger = logging.getLogger(__name__)
|
|
28
29
|
|
|
29
30
|
|
|
31
|
+
def _local_jar_path_for_match(p: str) -> str:
|
|
32
|
+
"""Normalize file:/path or /path for prefix checks."""
|
|
33
|
+
p = p.strip()
|
|
34
|
+
if not p:
|
|
35
|
+
return p
|
|
36
|
+
if p.startswith("file:"):
|
|
37
|
+
parsed = urlparse(p)
|
|
38
|
+
return parsed.path if parsed.path else p[5:]
|
|
39
|
+
return p
|
|
40
|
+
|
|
41
|
+
|
|
30
42
|
def _omit_spark_distrib_jars(jar_list: List[str]) -> List[str]:
|
|
31
43
|
"""
|
|
32
44
|
Drop paths under $SPARK_HOME/jars from spark.jars.
|
|
@@ -34,23 +46,27 @@ def _omit_spark_distrib_jars(jar_list: List[str]) -> List[str]:
|
|
|
34
46
|
Those JARs are already on the driver and executor JVM classpath (Spark launch scripts add
|
|
35
47
|
$SPARK_HOME/jars/*). Listing them again in spark.jars makes Spark distribute them to executors
|
|
36
48
|
as ./basename.jar and breaks Kubernetes executors.
|
|
49
|
+
|
|
50
|
+
SPARK_HOME may be unset or empty in some pods; always treat /opt/spark/jars/ as Spark distro
|
|
51
|
+
(apache/spark images).
|
|
37
52
|
"""
|
|
38
|
-
spark_home = os.environ.get("SPARK_HOME"
|
|
39
|
-
|
|
53
|
+
spark_home = (os.environ.get("SPARK_HOME") or "/opt/spark").rstrip("/")
|
|
54
|
+
prefixes = (f"{spark_home}/jars/", "/opt/spark/jars/")
|
|
40
55
|
out: List[str] = []
|
|
41
56
|
skipped: List[str] = []
|
|
42
57
|
for p in jar_list:
|
|
43
58
|
p = p.strip()
|
|
44
59
|
if not p:
|
|
45
60
|
continue
|
|
46
|
-
|
|
61
|
+
norm = _local_jar_path_for_match(p)
|
|
62
|
+
if norm.endswith(".jar") and any(norm.startswith(pref) for pref in prefixes):
|
|
47
63
|
skipped.append(p)
|
|
48
64
|
else:
|
|
49
65
|
out.append(p)
|
|
50
66
|
if skipped:
|
|
51
67
|
logger.info(
|
|
52
68
|
"Omitting spark.jars for JARs already on Spark classpath (%s): %s",
|
|
53
|
-
|
|
69
|
+
prefixes[0],
|
|
54
70
|
",".join(skipped),
|
|
55
71
|
)
|
|
56
72
|
return out
|
|
@@ -202,16 +218,12 @@ def run_pipeline(
|
|
|
202
218
|
# Native format("clickhouse") needs clickhouse-spark-runtime; JDBC needs shaded clickhouse-jdbc (*-all),
|
|
203
219
|
# not the thin Maven artifact: thin JAR lacks HttpClient 5 (ClassicHttpRequest).
|
|
204
220
|
# Override: BATCH_SPARK_CLICKHOUSE_PACKAGES=maven coords / https jar URLs (comma-sep) or "" for SPARK_JARS only.
|
|
221
|
+
# Empty/unset: rely on $SPARK_HOME/jars (analytics-runner image). Do not add spark.jars /
|
|
222
|
+
# spark.jars.packages for ClickHouse here — that breaks K8s executors (./basename.jar).
|
|
223
|
+
# For ad-hoc runs without the image, set e.g.
|
|
224
|
+
# BATCH_SPARK_CLICKHOUSE_PACKAGES=com.clickhouse.spark:clickhouse-spark-runtime-3.5_2.12:0.8.0,https://repo1.maven.org/maven2/com/clickhouse/clickhouse-jdbc/0.9.8/clickhouse-jdbc-0.9.8-all.jar
|
|
205
225
|
_raw_ch = os.environ.get("BATCH_SPARK_CLICKHOUSE_PACKAGES")
|
|
206
|
-
if _raw_ch is None:
|
|
207
|
-
# Shaded *-all.jar; pin matches Docker image / SPARK_JARS (0.9.x; no 0.10.x on Central for this artifact).
|
|
208
|
-
_ch_jdbc = os.environ.get("BATCH_CLICKHOUSE_JDBC_VERSION", "0.9.8").strip()
|
|
209
|
-
ch_pkgs = (
|
|
210
|
-
"com.clickhouse.spark:clickhouse-spark-runtime-3.5_2.12:0.8.0,"
|
|
211
|
-
f"https://repo1.maven.org/maven2/com/clickhouse/clickhouse-jdbc/{_ch_jdbc}/"
|
|
212
|
-
f"clickhouse-jdbc-{_ch_jdbc}-all.jar"
|
|
213
|
-
)
|
|
214
|
-
elif not _raw_ch.strip():
|
|
226
|
+
if _raw_ch is None or not _raw_ch.strip():
|
|
215
227
|
ch_pkgs = None
|
|
216
228
|
else:
|
|
217
229
|
ch_pkgs = _raw_ch.strip()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{batch_analytics-0.3.1 → batch_analytics-0.3.2}/src/batch_analytics/analytics/correlation.py
RENAMED
|
File without changes
|
{batch_analytics-0.3.1 → batch_analytics-0.3.2}/src/batch_analytics/analytics/linear_regression.py
RENAMED
|
File without changes
|
{batch_analytics-0.3.1 → batch_analytics-0.3.2}/src/batch_analytics/analytics/pca_clustering.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{batch_analytics-0.3.1 → batch_analytics-0.3.2}/src/batch_analytics.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{batch_analytics-0.3.1 → batch_analytics-0.3.2}/src/batch_analytics.egg-info/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|