-
-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use pathlib in spiceypy for furnsh, etc #292
Comments
I searched for |
Actually every time you have a string that represents a path, e.g. when you open DAS/DSK files ( |
Sure, my question though was where a string "COULD" represent a path, as I was surprised to see only one function using Here are the functions that need pathlib support:
Currently, these different identifiers are used for filepaths:
Maybe these should be consolidated as well in a PR. |
This might be obvious but I put that down here. This change also affects tests, e.g. |
made the changes and all 631 tests passed 🥳 |
I’m actually not sure if we want to return pathlib.Paths as that can potentially break a lot of people’s code. I was thinking as a first step we only ingest pathlib.Paths transparently, so that nobody would even notice a difference. For returning pathlib.Paths I could imagine a config setting where the user could switch to either get strings or pathlib.Paths back with the default on strings? That way we could introduce returning pathlib without breaking anyone’s code. @andrew what do you think? |
I had a busy day so I'm catching up here, but for sure it is important to not change any return types to Also the 2nd point about different identifiers I strongly disagree with, although all the parameters are positional (for the most part) the names are consistent with the CSPICE docs. Changing the positional parameter names is not something I am willing to do. I am sure there may be counter examples in the code, but most likely those are typos from CSPICE that were corrected or typos in spiceypy itself. Currently the PR #436 is not acceptable. Casting path's to strings naively negates the benefits of the Pathlib API. For this feature I was envisioning a new helper method within support_types that would attempt to resolve the absolute paths etc for the Path objects, then convert to strings, likely with some logging additions to make it clear why the user supplied path does not match the path the Spice error system reports if an error is raised. I may have an early attempt of this locally that I can dig up (or is it already pushed?), but it isn't as trivial as casting things to strings. |
Considering that I so far have only seen one function ( Unless I'm looking somewhere wrong? A few examples of mismatches of the name for a path parameter, there seems to be a consistent replacement of
Do you want PRs to make it consistent? Or not worth to bother? Possibly the latter. |
Okay @AndrewAnnex & @michaelaye, your points make lot of sense. About the logging additional info at error, it's a little bit unclear, SPICE will tell that the path does not exist and so? |
@michaelaye I'll need to think about that, I'd say it is better to be consistent so maybe in all places we could use @GregoireHENRY no I am thinking a whole new function is necessary, along the lines of As for the logging I would need to think about it more, but potentially a new decorator could be written to keep track of what path the user provided and what path Pathlib found for the file, but I am not sure yet if that is the best solution at the moment. |
feels like a good addition, but should be universal ie all file paths should be converted to pathlib Paths
The text was updated successfully, but these errors were encountered: