Analysis mode is now also derived from non-str sources#44
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
🚀 New features to boost your workflow:
|
konstntokas
left a comment
There was a problem hiding this comment.
Everything looks good to me.
Please consider my suggestions below — it would be helpful if you could elaborate on my comments. That said, they’re all minor, so I'm happy to approve with suggestions.
| product_type: Optional product type name, such as `"MSIL1C"`. | ||
| Only used if `op_mode="analysis"`. You should not need | ||
| pass this argument, if the filename inherent to `filename_or_obj` | ||
| adheres to EOPF naming conventions. |
There was a problem hiding this comment.
| product_type: Optional product type name, such as `"MSIL1C"`. | |
| Only used if `op_mode="analysis"`. You should not need | |
| pass this argument, if the filename inherent to `filename_or_obj` | |
| adheres to EOPF naming conventions. | |
| product_type: Optional product type name, such as `"MSIL1C"`. | |
| Only used if `op_mode="analysis"`; typically not required if | |
| `filename_or_obj` follows EOPF naming conventions. |
There was a problem hiding this comment.
I prefer staying with my version as filename_or_obj may be some other object which cannot directly follow a naming convention, however its path or root attribute can.
But I like the semicolon.
| product_type: Optional product type name, such as `"MSIL1C"`. | ||
| Only used if `op_mode="analysis"`. You should not need | ||
| pass this argument, if the filename inherent to `filename_or_obj` | ||
| adheres to EOPF naming conventions. |
There was a problem hiding this comment.
| product_type: Optional product type name, such as `"MSIL1C"`. | |
| Only used if `op_mode="analysis"`. You should not need | |
| pass this argument, if the filename inherent to `filename_or_obj` | |
| adheres to EOPF naming conventions. | |
| product_type: Optional product type name, such as `"MSIL1C"`. | |
| Only used if `op_mode="analysis"`; typically not required if | |
| `filename_or_obj` follows EOPF naming conventions. |
| self.assertIsInstance(AnalysisMode.guess("TEST.zarr"), TestMode) | ||
| self.assertIsInstance(AnalysisMode.guess({}, product_type="TEST"), TestMode) | ||
| self.assertIsInstance( | ||
| AnalysisMode.guess("TEST.zarr", product_type="REST"), TestMode |
There was a problem hiding this comment.
This behavior isn't intuitive to me. It first tries to guess the analysis mode from the product type "REST", which fails, and then proceeds to derive it from "TEST.zarr". I would have expected it to fail outright if the first guess didn't succeed.
That said, perhaps there's a reason you chose to implement it using two separate if statements instead of an if–elif structure?
There was a problem hiding this comment.
I agree. If product_type is provided, it should be used and fail if it does not succeed. Will change this. Thanks!
| fsspec.filesystem("local").get_mapper("test3.zarr") | ||
| ) | ||
| self.assertIsInstance(path, str) | ||
| self.assertEqual("test3.zarr", Path(path).name) |
There was a problem hiding this comment.
| self.assertEqual("test3.zarr", Path(path).name) | |
| self.assertEqual("test3.zarr", path) |
Or am I missing something?
There was a problem hiding this comment.
Nope, it was correct! Path(path).name gets the filename of an absolute path.
| # From zarr.storage.DirectoryStore | ||
| path = AnalysisMode._source_to_path(zarr.storage.DirectoryStore("test4.zarr")) | ||
| self.assertIsInstance(path, str) | ||
| self.assertEqual("test4.zarr", Path(path).name) |
There was a problem hiding this comment.
| self.assertEqual("test4.zarr", Path(path).name) | |
| self.assertEqual("test4.zarr", path) |
See comment above
There was a problem hiding this comment.
Same here, it is correct.
Co-authored-by: Konstantin Ntokas <38956538+konstntokas@users.noreply.github.com>
Co-authored-by: Konstantin Ntokas <38956538+konstntokas@users.noreply.github.com>
Co-authored-by: Konstantin Ntokas <38956538+konstntokas@users.noreply.github.com>
Co-authored-by: Konstantin Ntokas <38956538+konstntokas@users.noreply.github.com>
Analysis mode is now also derived from non-str sources.
Closes #40