|
1 | 1 | # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
2 | 2 | # SPDX-License-Identifier: Apache-2.0 |
3 | 3 |
|
| 4 | +from datetime import datetime |
4 | 5 | import json |
| 6 | +from unittest.mock import patch |
5 | 7 |
|
6 | 8 | import pandas as pd |
7 | 9 | from pyarrow import ArrowNotImplementedError |
@@ -213,3 +215,22 @@ def test_artifact_storage_batch_numbering(stub_artifact_storage, batch_number): |
213 | 215 | path = stub_artifact_storage.create_batch_file_path(batch_number, BatchStage.FINAL_RESULT) |
214 | 216 | expected_name = f"batch_{batch_number:05d}.parquet" |
215 | 217 | assert path.name == expected_name |
| 218 | + |
| 219 | + |
| 220 | +@patch("data_designer.engine.dataset_builders.artifact_storage.datetime") |
| 221 | +def test_artifact_storage_resolved_dataset_name(mock_datetime, tmp_path): |
| 222 | + mock_datetime.now.return_value = datetime(2025, 1, 1, 12, 3, 4) |
| 223 | + |
| 224 | + # dataset path does not exist yet |
| 225 | + assert ArtifactStorage(artifact_path=tmp_path).resolved_dataset_name == "dataset" |
| 226 | + |
| 227 | + # dataset path exists but is empty |
| 228 | + af_storage = ArtifactStorage(artifact_path=tmp_path) |
| 229 | + (af_storage.artifact_path / af_storage.dataset_name).mkdir() |
| 230 | + assert af_storage.resolved_dataset_name == "dataset" |
| 231 | + |
| 232 | + # dataset path exists and is not empty |
| 233 | + af_storage = ArtifactStorage(artifact_path=tmp_path) |
| 234 | + (af_storage.artifact_path / af_storage.dataset_name / "stub_file.txt").touch() |
| 235 | + print(af_storage.resolved_dataset_name) |
| 236 | + assert af_storage.resolved_dataset_name == "dataset_01-01-2025_120304" |
0 commit comments