-
Notifications
You must be signed in to change notification settings - Fork 175
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
Only make existing paths relative #3014
Conversation
Not sure to like this. Here, this patch is detecting if file existst or not but this notion is not related to differentiate system path and intra hdf5 path. |
We currently don't have a better way to tell which paths are real paths and which paths are not. The other option would be to remove path from the argument, but I think that those are good names. |
We should have an explicit way to declare some kwargs as system path and we should convert to relative only theses ones. Or the reverse skip some kwargs from this relative mechanism. |
What do you suggest? we could have a class attribute |
This is an interesting one. I agree with @samuelgarcia that the patch is too far away from the bug which is undesirable. My take on the origin of the problem is that the criteria that we use to decide which paths we modify is to loose: spikeinterface/src/spikeinterface/core/core_tools.py Lines 193 to 194 in 17ee785
That is, we are using "path" in the name of the argument as a criteria to decide if something is a path and I think this is not precise enough and will cause problems My proposal:
I think this proposal has the advantage of fixing this and not changing a lot. I would start with that. That said, long term what I would really like to see is for the criteria to be that we only modify to relative or absolute kwargs that are of Path type. Right now we are casting Paths to strings in most places but I don't think this is necessary. Both json and pickle can handle paths so we don't really need to keep them as strings internally, do we? If we do this, then the criteria to modify something becomes even more straighforward: modify kwargs that are of type Path. This is marked and controlled at the level of the extractor by storing something on the kwargs as a Path type or not. So it is both clear and controllable. The problem with the second proposal is that is more disruptive and will take us a while on discussing the details (and maybe finding bugs) so I think the first solution is better. |
@h-mayorquin I tried to implement this at the recursive path modifier level and it works, but it requires an additional IMO, this is good to go! @h-mayorquin tell me what you think! I also modified tests so they actually create existing and non existing test paths |
I did not think about that problem, the thing is that you don't have the relative folder until you apply the function. So I understand that we need But maybe we can get rid of the second keyword by just checking before and after? path_before_function = Path(v)
result = func(v)
path_after_function = Path(result)
if path_before_function.exists() or path_after_function.exists():
dc[k] = result I really would prefer not to leak path checking implementation details outside of this function. |
Great idea! I'll do that :) I agree that we should minimize the extra kwargs |
@h-mayorquin done! |
@h-mayorquin unfortunately I think we have to revert to the previous logic, here's why: Some functions, like this one use the |
Mmm I think those functions that are using |
@alejoe91 check out the appraoach in #3089. I am afraid of |
Close in favor of #3089 |
Fixes #3013