|
34 | 34 | from xcube.util.assertions import assert_given |
35 | 35 | from xcube.util.assertions import assert_in |
36 | 36 | from xcube.util.assertions import assert_instance |
| 37 | +from xcube.util.assertions import assert_true |
37 | 38 | from xcube.util.extension import Extension |
38 | 39 | from xcube.util.jsonschema import JsonBooleanSchema |
39 | 40 | from xcube.util.jsonschema import JsonIntegerSchema |
40 | 41 | from xcube.util.jsonschema import JsonObjectSchema |
41 | 42 | from xcube.util.jsonschema import JsonStringSchema |
42 | | -from .accessor import STORAGE_OPTIONS_PARAM_NAME |
43 | 43 | from .accessor import FsAccessor |
| 44 | +from .accessor import STORAGE_OPTIONS_PARAM_NAME |
44 | 45 | from .helpers import is_local_fs |
45 | 46 | from .helpers import normalize_path |
46 | 47 | from ..accessor import DataOpener |
@@ -296,11 +297,22 @@ def write_data(self, |
296 | 297 | data_id = self._ensure_valid_data_id(writer_id, data_id=data_id) |
297 | 298 | fs_path = self._convert_data_id_into_fs_path(data_id) |
298 | 299 | self.fs.makedirs(self.root, exist_ok=True) |
299 | | - writer.write_data(data, |
300 | | - fs_path, |
301 | | - replace=replace, |
302 | | - fs=self.fs, |
303 | | - **write_params) |
| 300 | + written_fs_path = writer.write_data(data, |
| 301 | + fs_path, |
| 302 | + replace=replace, |
| 303 | + fs=self.fs, |
| 304 | + **write_params) |
| 305 | + # Verify, accessors fulfill their write_data() contract |
| 306 | + assert_true(fs_path == written_fs_path, |
| 307 | + message='FsDataAccessor implementations must ' |
| 308 | + 'return the data_id passed in.') |
| 309 | + # Return original data_id (which is a relative path). |
| 310 | + # Note: it would be cleaner to return written_fs_path |
| 311 | + # here, but it is an absolute path. |
| 312 | + # --> Possible solution: FsDataAccessor implementations |
| 313 | + # should be responsible for resolving their data_id into a |
| 314 | + # filesystem path by providing them both with fs and root |
| 315 | + # arguments. |
304 | 316 | return data_id |
305 | 317 |
|
306 | 318 | def get_delete_data_params_schema(self, data_id: str = None) \ |
|
0 commit comments