Update preprocessing/pipeline_components.py
Browse files
preprocessing/pipeline_components.py
CHANGED
|
@@ -7,10 +7,17 @@ from sklearn.base import BaseEstimator, TransformerMixin
|
|
| 7 |
from scipy.stats import gaussian_kde
|
| 8 |
from sklearn.preprocessing import StandardScaler
|
| 9 |
from sklearn.neighbors import NearestNeighbors
|
| 10 |
-
import pgeocode
|
| 11 |
from datetime import datetime
|
| 12 |
import pgeocode
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
class DataCleaner(BaseEstimator, TransformerMixin):
|
| 16 |
def __init__(self):
|
|
|
|
| 7 |
from scipy.stats import gaussian_kde
|
| 8 |
from sklearn.preprocessing import StandardScaler
|
| 9 |
from sklearn.neighbors import NearestNeighbors
|
|
|
|
| 10 |
from datetime import datetime
|
| 11 |
import pgeocode
|
| 12 |
+
# IMMEDIATELY after importing pgeocode, force its STORAGE_DIR
|
| 13 |
+
# This must be done before any pgeocode.Nominatim() calls
|
| 14 |
+
try:
|
| 15 |
+
pgeocode.STORAGE_DIR = "/tmp/pgeocode"
|
| 16 |
+
# Ensure the directory exists as pgeocode might not create it if overridden this way
|
| 17 |
+
os.makedirs(pgeocode.STORAGE_DIR, exist_ok=True)
|
| 18 |
+
print(f"DEBUG: Successfully forced pgeocode.STORAGE_DIR to '{pgeocode.STORAGE_DIR}' and ensured directory exists.")
|
| 19 |
+
except Exception as e:
|
| 20 |
+
print(f"ERROR: Failed to force pgeocode.STORAGE_DIR or create directory: {e}")
|
| 21 |
|
| 22 |
class DataCleaner(BaseEstimator, TransformerMixin):
|
| 23 |
def __init__(self):
|