decentriq_util 0.1.0.dev9__tar.gz → 0.1.0.dev11__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: decentriq_util
3
- Version: 0.1.0.dev9
3
+ Version: 0.1.0.dev11
4
4
  Summary: Utility functions for Python code run in Decentriq workers
5
5
  Author: hafenr
6
6
  Author-email: robin.hafen@gmail.com
@@ -0,0 +1,9 @@
1
+ import logging
2
+
3
+
4
+ logger = logging.getLogger("decentriq_util")
5
+ ch = logging.StreamHandler()
6
+ ch.setLevel(logging.INFO)
7
+ formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
8
+ ch.setFormatter(formatter)
9
+ logger.addHandler(ch)
@@ -4,8 +4,8 @@ from contextlib import contextmanager
4
4
  import multiprocessing
5
5
  import math
6
6
  import os
7
- import shutil
8
7
  import psutil
8
+ from ..logger import logger
9
9
 
10
10
  import pyarrow.parquet as pq
11
11
  from pyspark.sql import SparkSession
@@ -36,7 +36,7 @@ def _get_cgroup_memory() -> int:
36
36
  if max_memory is not None:
37
37
  return max_memory
38
38
  else:
39
- print("Unable to determine available memory from cgroup, assuming 4G")
39
+ logger.info("Unable to determine available memory from cgroup, assuming 4G")
40
40
  return 4 * 1024 * 1024 * 1024
41
41
 
42
42
 
@@ -118,9 +118,9 @@ def _get_num_partitions(
118
118
  break
119
119
  target_partition_size = target_partition_size / 2
120
120
 
121
- print(f"File size: {file_size}")
122
- print(f"Max target partition size: {max_target_partition_size}")
123
- print(f"Target partition size: {target_partition_size}")
121
+ logger.info(f"File size: {file_size}")
122
+ logger.info(f"Max target partition size: {max_target_partition_size}")
123
+ logger.info(f"Target partition size: {target_partition_size}")
124
124
 
125
125
  num_partitions = int(math.ceil(file_size / target_partition_size))
126
126
 
@@ -148,7 +148,6 @@ def _determine_optimal_spark_settings(
148
148
  ("spark.driver.cores", str(cpu_count)),
149
149
  ("spark.driver.memory", str(spark_memory_4096)),
150
150
  ]
151
- print("Spark settings:\n" + f"\n".join([str(x) for x in settings]))
152
151
 
153
152
  return settings
154
153
 
@@ -192,6 +191,9 @@ def _create_spark_session(
192
191
  )
193
192
  for (key, value) in config:
194
193
  ss = ss.config(key, value)
194
+
195
+ logger.info("Spark settings:\n" + f"\n".join([str(x) for x in config]))
196
+
195
197
  return ss.getOrCreate()
196
198
 
197
199
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "decentriq_util"
3
- version = "0.1.0-dev9"
3
+ version = "0.1.0-dev11"
4
4
  description = "Utility functions for Python code run in Decentriq workers"
5
5
  authors = ["hafenr <robin.hafen@gmail.com>"]
6
6