-
Notifications
You must be signed in to change notification settings - Fork 153
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
Read gzipped graphml files #1315
base: main
Are you sure you want to change the base?
Conversation
Thanks for submitting this. I think this is a very welcoming addition. However, I don’t think we should have a new mehod to support compressed files. I’d refactor the existing method to try to decompress the file based on the file extension. And perhaps an optional argument like “force_decompression” to decompress anyway even if the file extension is not what we expect |
Ok I have now included everything in a single function, with the optional argument |
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.
Awesome this is looking good. I left a minor comment.
Lastly, check CONTRIBUTING.md for how to update the type stubs now that you added a new argument to an existing function. Our CI should fail you in the “Stubs” section until you update
pub fn read_graphml(py: Python, path: &str) -> PyResult<Vec<PyObject>> { | ||
let graphml = GraphML::from_file(path)?; | ||
#[pyo3(signature=(path, compression=""),text_signature = "(path, compression=\"\", /)")] | ||
pub fn read_graphml(py: Python, path: &str, compression: &str) -> PyResult<Vec<PyObject>> { |
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.
Prefer Option<&str>
over an empty string. For Python the default would become None
which gets converted to None
in Rust as well
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.
Yeah I thought about that too, but apparently it's being phased out:
https://pyo3.rs/main/function/signature#trailing-optional-arguments
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.
Yeah I thought about that too, but apparently it's being phased out: https://pyo3.rs/main/function/signature#trailing-optional-arguments
You just need to specify the None in the signature like you specified the empty string. We still use that in lots of places. What is deprecated is None being inserted by default without declaration
Create python function to load a graphml file that has been compressed with gzip without necessarily unzipping it before.
This makes reading large graphs in graphml much faster, and they can use less space
cargo clippy
and it suggests no changes