|
| 1 | +import os |
1 | 2 | import uuid
|
2 | 3 | from datetime import datetime
|
3 | 4 | from pathlib import Path
|
|
11 | 12 | import pytz
|
12 | 13 | from pydantic.typing import Literal
|
13 | 14 |
|
14 |
| -from feast import FileSource, OnDemandFeatureView |
15 | 15 | from feast.data_source import DataSource
|
16 |
| -from feast.errors import FeastJoinKeysDuringMaterialization |
| 16 | +from feast.errors import ( |
| 17 | + FeastJoinKeysDuringMaterialization, |
| 18 | + SavedDatasetLocationAlreadyExists, |
| 19 | +) |
17 | 20 | from feast.feature_logging import LoggingConfig, LoggingSource
|
18 | 21 | from feast.feature_view import DUMMY_ENTITY_ID, DUMMY_ENTITY_VAL, FeatureView
|
19 | 22 | from feast.infra.offline_stores.file_source import (
|
20 | 23 | FileLoggingDestination,
|
| 24 | + FileSource, |
21 | 25 | SavedDatasetFileStorage,
|
22 | 26 | )
|
23 | 27 | from feast.infra.offline_stores.offline_store import (
|
|
30 | 34 | get_pyarrow_schema_from_batch_source,
|
31 | 35 | )
|
32 | 36 | from feast.infra.registry.base_registry import BaseRegistry
|
| 37 | +from feast.on_demand_feature_view import OnDemandFeatureView |
33 | 38 | from feast.repo_config import FeastConfigBaseModel, RepoConfig
|
34 | 39 | from feast.saved_dataset import SavedDatasetStorage
|
35 | 40 | from feast.usage import log_exceptions_and_usage
|
@@ -85,6 +90,11 @@ def _to_arrow_internal(self):
|
85 | 90 |
|
86 | 91 | def persist(self, storage: SavedDatasetStorage):
|
87 | 92 | assert isinstance(storage, SavedDatasetFileStorage)
|
| 93 | + |
| 94 | + # Check if the specified location already exists. |
| 95 | + if os.path.exists(storage.file_options.uri): |
| 96 | + raise SavedDatasetLocationAlreadyExists(location=storage.file_options.uri) |
| 97 | + |
88 | 98 | filesystem, path = FileSource.create_filesystem_and_path(
|
89 | 99 | storage.file_options.uri,
|
90 | 100 | storage.file_options.s3_endpoint_override,
|
|
0 commit comments