-
Notifications
You must be signed in to change notification settings - Fork 8
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
Fix @cachable decorator for windows. #9
Conversation
For windows paths, this returned e.g. "C" (for paths like "C:\Temp\vresutils\") which is an invalid input for `os.stat`. IMHO: How could this ever have worked?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to use cachable on windows, you have to take out or at least make all of the permission handling optional; ie.
https://github.com/FRESNA/vresutils/blob/master/vresutils/decorators.py#L70-L75
should be skipped on windows, as well as
vresutils/vresutils/decorators.py
Lines 157 to 158 in c8ed491
if gid: os.fchown(f.fileno(), -1, gid) | |
if mode: os.fchmod(f.fileno(), mode) |
|
||
if enable: | ||
st = os.stat(cache_dir[0]) | ||
st = os.stat(root_dir(cache_dir)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
st = os.stat(root_dir(cache_dir)) | |
st = os.stat(cache_dir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code in the if enable
clause was supposed to get the unix permissions of the cache directory, so that later on we can set the same permissions on the cache files.
I mistakenly introduced the [0]
back when I added the fallback_cache_dirs
(80c9997). In some intermediate state cache_dir
was a list of cache directories and then you wanted the first one from the list.
TBH I did not time looking into what this function does nor did I use it intentionally. My snakemake workflow in pypsa-eur just failed because of this during some work on my windows machine and I needed a quick fix. If I understand you correctly, this code shouldn't have been called on my windows machine? |
The default should have been to just shut up, if the If you don't have any |
I was expecting it to work out-of-the-box as you describe it.
Mea culpa. Somehow somewhen I created this file causing the problem. Thanks a lot for the hint. From my side we can close w/o merge. |
For windows paths, this returned e.g. "C" (for paths like "C:\Temp\vresutils") which is an invalid input for
os.stat
.IMHO: How could this ever have worked?