Skip to content

Commit 94cb3fc

Browse files
Prints for frontend, deps for Docker; [skip ci]
Added some prints for the frontend to show the user where the artifacts are being saved. Updated requirements.txt, since Docker needed it. Updated docker-compose.yml to have the used directories as volumes. Some of them were missing earlier.
1 parent d161ce3 commit 94cb3fc

17 files changed

Lines changed: 83 additions & 20 deletions

File tree

docker-compose.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ services:
1919
- ./experiments:/app/experiments
2020
- ./failure_management:/app/failure_management
2121
- ./orchestration_logs:/app/orchestration_logs
22+
- ./model_registry:/app/model_registry
23+
- ./predictions:/app/predictions
24+
- ./monitoring:/app/monitoring
25+
- ./docs:/app/docs
26+
- ./assets:/app/assets
2227
ports:
2328
- "8000:8000"
2429
- "8050:8050"

ml/data/utils/persistence/save_data.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ def save_data(df: pd.DataFrame, *, config: InterimConfig | ProcessedConfig, data
4040
try:
4141
if save_func == pd.DataFrame.to_parquet:
4242
save_func(df, data_path, compression=compression)
43+
msg = f"Data saved successfully at {data_path} in parquet format with compression {compression}."
44+
logger.info(msg)
45+
print(msg)
4346
return data_path
4447
except Exception as e:
4548
msg = f"Error saving data to {data_path} with format {config.data.output.format} and compression {compression}. "

ml/feature_freezing/freeze_strategies/tabular/persistence.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ def persist_feature_snapshot(
6767
compression=config.storage.compression
6868
)
6969

70+
msg = f"Persisted feature set snapshot to {data_path} using format {config.storage.format}"
71+
logger.info(msg)
72+
print(msg)
73+
7074
return path, data_path
7175

7276
def save_input_schema(path: Path, features: pd.DataFrame):
@@ -93,7 +97,9 @@ def save_input_schema(path: Path, features: pd.DataFrame):
9397
})
9498

9599
schema.to_csv(schema_path, index=False)
96-
logger.info(f"Input schema saved to {schema_path}")
100+
msg = f"Input schema saved to {schema_path}"
101+
logger.info(msg)
102+
print(msg)
97103

98104
def save_derived_schema(
99105
path: Path,
@@ -137,7 +143,9 @@ def save_derived_schema(
137143

138144
derived_schema = pd.DataFrame(derived_features)
139145
derived_schema.to_csv(schema_path, index=False)
140-
logger.info(f"Derived schema saved to {schema_path}")
146+
msg = f"Derived schema saved to {schema_path}"
147+
logger.info(msg)
148+
print(msg)
141149

142150
def create_metadata(
143151
*,

ml/io/persistence/save_metadata.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def save_metadata(
4040
"""
4141

4242
metadata_file = target_dir / "metadata.json"
43+
metadata_file = Path(metadata_file.as_posix())
4344

4445
metadata_file.parent.mkdir(parents=True, exist_ok=True)
4546

@@ -66,14 +67,17 @@ def save_metadata(
6667
os.fsync(tmp_file.fileno())
6768

6869
os.replace(temp_path, metadata_file)
69-
logger.info(f"Metadata successfully saved to {metadata_file}.")
70+
71+
msg = f"Metadata successfully saved to {metadata_file.as_posix()}."
72+
logger.info(msg)
73+
print(msg)
7074
except Exception as e:
7175
if temp_path and Path(temp_path).exists():
7276
try:
7377
Path(temp_path).unlink()
7478
except OSError:
7579
logger.warning("Failed to clean up temporary metadata file: %s", temp_path)
7680

77-
msg = f"Failed to save metadata to {metadata_file}"
81+
msg = f"Failed to save metadata to {metadata_file.as_posix()}"
7882
logger.exception(msg)
7983
raise PersistenceError(msg) from e

ml/post_promotion/inference/persistence/store_predictions.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ def store_predictions(
8888
pq.write_table(pa.Table.from_pandas(df), tmp_path)
8989
tmp_path.rename(file_path)
9090

91-
logger.info(f"Stored predictions at {file_path}")
91+
msg = f"Predictions successfully stored at {file_path} with columns: {cols}"
92+
logger.info(msg)
93+
print(msg)
9294

9395
return PredictionStoringReturn(
9496
file_path=file_path,

ml/promotion/persistence/registry.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ def update_registry_and_archive(
7777
yaml.safe_dump(new_registry, f, sort_keys=False)
7878
os.replace(temp_registry_path, registry_path)
7979

80+
msg = f"Model registry successfully updated at {registry_path}."
81+
if new_archive is not None:
82+
msg += f" Previous production model archived at {archive_path}."
83+
logger.info(msg)
84+
print(msg)
85+
8086
return new_registry
8187
except Exception as e:
8288
msg = f"Failed to update model registry and archive. Run info: {run_info}"
@@ -108,6 +114,9 @@ def persist_registry_diff(
108114
try:
109115
with open(diff_path, "w", encoding="utf-8") as f:
110116
yaml.safe_dump(diff, f, sort_keys=False)
117+
msg = f"Registry diff successfully saved to {diff_path}."
118+
logger.info(msg)
119+
print(msg)
111120
except Exception as e:
112121
msg = f"Failed to persist registry diff to {diff_path}"
113122
logger.exception(msg)

ml/runners/evaluation/persistence/save_predictions.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,23 @@ def save_predictions(prediction_dfs: PredictionArtifacts, target_dir: Path) -> P
5757
try:
5858
train_path = target_dir / "predictions_train.parquet"
5959
_write_parquet_atomic(prediction_dfs.train, train_path)
60-
logger.info(f"Saved predictions for the train split to {train_path}")
60+
msg = f"Saved predictions for the train split to {train_path}"
61+
logger.info(msg)
62+
print(msg)
6163
paths_raw["train_predictions_path"] = train_path.as_posix()
6264

6365
val_path = target_dir / "predictions_val.parquet"
6466
_write_parquet_atomic(prediction_dfs.val, val_path)
65-
logger.info(f"Saved predictions for the validation split to {val_path}")
67+
msg = f"Saved predictions for the validation split to {val_path}"
68+
logger.info(msg)
69+
print(msg)
6670
paths_raw["val_predictions_path"] = val_path.as_posix()
6771

6872
test_path = target_dir / "predictions_test.parquet"
6973
_write_parquet_atomic(prediction_dfs.test, test_path)
70-
logger.info(f"Saved predictions for the test split to {test_path}")
74+
msg = f"Saved predictions for the test split to {test_path}"
75+
logger.info(msg)
76+
print(msg)
7177
paths_raw["test_predictions_path"] = test_path.as_posix()
7278

7379
paths = PredictionsPaths(**paths_raw)

ml/runners/explainability/persistence/save_metrics_csv.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ def save_metrics_csv(
4646
os.fsync(tmp_file.fileno())
4747

4848
os.replace(temp_path, target_file)
49-
logger.info(f'{name} successfully saved to {target_file}.')
49+
50+
msg = f"{name} successfully saved to {target_file}."
51+
logger.info(msg)
52+
print(msg)
5053
except Exception as e:
5154
if temp_path and Path(temp_path).exists():
5255
try:

ml/runners/shared/persistence/save_metrics.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ def save_metrics(metrics: dict[str, float] | dict[str, dict[str, float]], *, mod
6060
os.fsync(tmp_file.fileno())
6161

6262
os.replace(temp_path, metrics_file)
63-
logger.info(f"Metrics successfully saved to {metrics_file}.")
63+
64+
msg = f"Metrics successfully saved to {metrics_file}."
65+
logger.info(msg)
66+
print(msg)
6467
return str(metrics_file)
6568
except Exception as e:
6669
if temp_path and Path(temp_path).exists():

ml/runners/training/persistence/artifacts/save_model.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ def save_model(model, path: Path) -> Path:
3838

3939
joblib.dump(model, temp_path)
4040
os.replace(temp_path, model_file)
41-
logger.info(f"Model successfully saved to {model_file}.")
41+
42+
msg = f"Model successfully saved to {model_file}."
43+
logger.info(msg)
44+
print(msg)
4245
return model_file
4346
except Exception as e:
4447
if temp_path and temp_path.exists():

0 commit comments

Comments
 (0)