Skip to content
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

batch files cannot be used cross-platform #209

Open
kushalkolar opened this issue Jun 14, 2023 · 5 comments
Open

batch files cannot be used cross-platform #209

kushalkolar opened this issue Jun 14, 2023 · 5 comments

Comments

@kushalkolar
Copy link
Collaborator

I think it's because the current batch path is stored in DataFrame.attrs

def set_batch_path(self, path: Union[str, Path]):
self._data.attrs["batch_path"] = Path(path)

should just store this as a string and have a @batch_path property on the extension class which returns a Path instead of str to use within the extension functions.

@ethanbb
Copy link
Collaborator

ethanbb commented Jun 5, 2024

Hey, I just ran into this issue as well.

I was thinking, your solution would avoid the error, but it's still not very useful to have the string representation of a path that's not usable on your current system. The batch path gets overwritten when loading a batch anyway right after un-pickling:

df = pd.read_pickle(Path(path))
df.paths.set_batch_path(path)

Thus how about this attribute just gets cleared before saving? Each df.to_pickle call would have to be replaced with a custom save function. If that sounds OK, I can take a stab at it.

@ethanbb
Copy link
Collaborator

ethanbb commented Jun 5, 2024

By the way, how do you quote specific lines with the line numbers and link to file? I've been wishing there was a feature like that.

@kushalkolar
Copy link
Collaborator Author

not very useful to have the string representation of a path that's not usable on your current system. The batch path gets overwritten when loading a batch anyway right after un-pickling:

Ah yes you're right 😆 nice to have fresh eyes take a look at this

By the way, how do you quote specific lines with the line numbers and link to file? I've been wishing there was a feature like that.

https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-a-permanent-link-to-a-code-snippet

@ethanbb
Copy link
Collaborator

ethanbb commented Jun 6, 2024

I just realized that the outputs are also saved as Paths, e.g.:

https://github.com/nel-lab/mesmerize-core/blob/38f6ebebf6dc38bc5f9312751f2848952711807e/mesmerize_core/algorithms/cnmf.py#L118C9-L134C10

Since I believe these are all relative paths, which should be cross-platform if they use forward slashes, I think the solution is to convert the relative paths to PurePosixPaths and then strings before saving.

Edit: or just save as PurePosixPath, that should also be fine.

@kushalkolar
Copy link
Collaborator Author

That's a good idea! Posix path and then string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants