decentriq_util 0.1.0.dev8__tar.gz → 0.1.0.dev10__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.
- {decentriq_util-0.1.0.dev8 → decentriq_util-0.1.0.dev10}/PKG-INFO +1 -1
- {decentriq_util-0.1.0.dev8 → decentriq_util-0.1.0.dev10}/decentriq_util/spark/__init__.py +13 -5
- {decentriq_util-0.1.0.dev8 → decentriq_util-0.1.0.dev10}/pyproject.toml +1 -1
- {decentriq_util-0.1.0.dev8 → decentriq_util-0.1.0.dev10}/decentriq_util/__init__.py +0 -0
- {decentriq_util-0.1.0.dev8 → decentriq_util-0.1.0.dev10}/decentriq_util/error.py +0 -0
- {decentriq_util-0.1.0.dev8 → decentriq_util-0.1.0.dev10}/decentriq_util/proto/__init__.py +0 -0
- {decentriq_util-0.1.0.dev8 → decentriq_util-0.1.0.dev10}/decentriq_util/python/__init__.py +0 -0
- {decentriq_util-0.1.0.dev8 → decentriq_util-0.1.0.dev10}/decentriq_util/sql/__init__.py +0 -0
- {decentriq_util-0.1.0.dev8 → decentriq_util-0.1.0.dev10}/decentriq_util/sql/proto/__init__.py +0 -0
- {decentriq_util-0.1.0.dev8 → decentriq_util-0.1.0.dev10}/decentriq_util/sql/proto/compute_sql_pb2.py +0 -0
- {decentriq_util-0.1.0.dev8 → decentriq_util-0.1.0.dev10}/decentriq_util/sql/proto/compute_sql_pb2.pyi +0 -0
|
@@ -11,6 +11,9 @@ import pyarrow.parquet as pq
|
|
|
11
11
|
from pyspark.sql import SparkSession
|
|
12
12
|
|
|
13
13
|
|
|
14
|
+
_DEFAULT_HEAP_SIZE_EXTRA_ROOM = 2 * 512 * 1024 * 1024
|
|
15
|
+
|
|
16
|
+
|
|
14
17
|
def _get_cgroup_memory() -> int:
|
|
15
18
|
max_memory_str = None
|
|
16
19
|
if os.path.isfile("/sys/fs/cgroup/memory.max"):
|
|
@@ -126,12 +129,12 @@ def _get_num_partitions(
|
|
|
126
129
|
|
|
127
130
|
def _determine_optimal_spark_settings(
|
|
128
131
|
files: list[str],
|
|
129
|
-
heap_size_extra_room
|
|
132
|
+
heap_size_extra_room = _DEFAULT_HEAP_SIZE_EXTRA_ROOM
|
|
130
133
|
) -> list[Tuple[str, str]]:
|
|
131
134
|
def get_spark_memory() -> int:
|
|
132
135
|
"""Determine the amount of memory available to spark"""
|
|
133
136
|
cgroup_memory = _get_cgroup_memory()
|
|
134
|
-
spark_memory = cgroup_memory -
|
|
137
|
+
spark_memory = cgroup_memory - heap_size_extra_room
|
|
135
138
|
return spark_memory
|
|
136
139
|
|
|
137
140
|
cpu_count = multiprocessing.cpu_count()
|
|
@@ -145,7 +148,6 @@ def _determine_optimal_spark_settings(
|
|
|
145
148
|
("spark.driver.cores", str(cpu_count)),
|
|
146
149
|
("spark.driver.memory", str(spark_memory_4096)),
|
|
147
150
|
]
|
|
148
|
-
print("Spark settings:\n" + f"\n".join([str(x) for x in settings]))
|
|
149
151
|
|
|
150
152
|
return settings
|
|
151
153
|
|
|
@@ -154,7 +156,7 @@ def _create_spark_session(
|
|
|
154
156
|
name: str = "local_spark_session",
|
|
155
157
|
parallelism: int = 8,
|
|
156
158
|
heap_size: Optional[int] = None,
|
|
157
|
-
heap_size_extra_room: int =
|
|
159
|
+
heap_size_extra_room: int = _DEFAULT_HEAP_SIZE_EXTRA_ROOM,
|
|
158
160
|
config: list[Tuple[str, Any]] = [],
|
|
159
161
|
java_tmp_dir = "/output",
|
|
160
162
|
) -> SparkSession:
|
|
@@ -189,6 +191,9 @@ def _create_spark_session(
|
|
|
189
191
|
)
|
|
190
192
|
for (key, value) in config:
|
|
191
193
|
ss = ss.config(key, value)
|
|
194
|
+
|
|
195
|
+
print("Spark settings:\n" + f"\n".join([str(x) for x in config]))
|
|
196
|
+
|
|
192
197
|
return ss.getOrCreate()
|
|
193
198
|
|
|
194
199
|
|
|
@@ -231,7 +236,10 @@ def spark_session(temp_dir: str = "/scratch", input_files: list[str] = None, **k
|
|
|
231
236
|
config_dict = dict(config)
|
|
232
237
|
if input_files is not None and input_files:
|
|
233
238
|
optimal_settings = _determine_optimal_spark_settings(
|
|
234
|
-
input_files,
|
|
239
|
+
input_files,
|
|
240
|
+
heap_size_extra_room=kwargs.get(
|
|
241
|
+
"heap_size_extra_room", _DEFAULT_HEAP_SIZE_EXTRA_ROOM
|
|
242
|
+
)
|
|
235
243
|
)
|
|
236
244
|
for key, value in optimal_settings:
|
|
237
245
|
if key not in config_dict:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{decentriq_util-0.1.0.dev8 → decentriq_util-0.1.0.dev10}/decentriq_util/sql/proto/__init__.py
RENAMED
|
File without changes
|
{decentriq_util-0.1.0.dev8 → decentriq_util-0.1.0.dev10}/decentriq_util/sql/proto/compute_sql_pb2.py
RENAMED
|
File without changes
|
|
File without changes
|