|
31 | 31 | # TODO:
|
32 | 32 | # - inherit from storage class
|
33 | 33 | # - export methods
|
| 34 | +# - caching / memoization of both datasets & dataset clients |
34 | 35 |
|
35 | 36 | # Dataset
|
36 | 37 | # - properties:
|
@@ -116,30 +117,25 @@ async def open(
|
116 | 117 | id: str | None = None,
|
117 | 118 | name: str | None = None,
|
118 | 119 | purge_on_start: bool | None = None,
|
| 120 | + storage_dir: Path | None = None, |
119 | 121 | configuration: Configuration | None = None,
|
120 | 122 | storage_client: StorageClient | None = None,
|
121 | 123 | ) -> Dataset:
|
122 | 124 | if id and name:
|
123 | 125 | raise ValueError('Only one of "id" or "name" can be specified, not both.')
|
124 | 126 |
|
125 |
| - configuration = configuration or service_locator.get_configuration() |
126 |
| - storage_client = storage_client or service_locator.get_storage_client() |
| 127 | + configuration = service_locator.get_configuration() if configuration is None else configuration |
| 128 | + storage_client = service_locator.get_storage_client() if storage_client is None else storage_client |
127 | 129 | purge_on_start = configuration.purge_on_start if purge_on_start is None else purge_on_start
|
| 130 | + storage_dir = Path(configuration.storage_dir) if storage_dir is None else storage_dir |
128 | 131 |
|
129 |
| - dataset_client = await storage_client.dataset_client_class.open( |
| 132 | + dataset_client = await storage_client.open_dataset_client( |
130 | 133 | id=id,
|
131 | 134 | name=name,
|
132 |
| - storage_dir=Path(configuration.storage_dir), |
| 135 | + purge_on_start=purge_on_start, |
| 136 | + storage_dir=storage_dir, |
133 | 137 | )
|
134 | 138 |
|
135 |
| - if purge_on_start: |
136 |
| - await dataset_client.drop() |
137 |
| - dataset_client = await storage_client.dataset_client_class.open( |
138 |
| - id=id, |
139 |
| - name=name, |
140 |
| - storage_dir=Path(configuration.storage_dir), |
141 |
| - ) |
142 |
| - |
143 | 139 | return cls(dataset_client)
|
144 | 140 |
|
145 | 141 | async def drop(self) -> None:
|
|
0 commit comments