-
Notifications
You must be signed in to change notification settings - Fork 2
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 on-the-fly rewrite (no more file writes) #11
Conversation
I also really like this package and I like this PR. I think that avoiding the file write could help with the fact that currently, you cannot split and organise the files in
Using this setup tests failed on Julia versions ┌ Warning: Error requiring `MPI` from `CounterfactualExplanations`
│ exception =
│ LoadError: SystemError: opening file "/home/runner/work/CounterfactualExplanations.jl/CounterfactualExplanations.jl/ext_compat/MPIExt/utils.jl": No such file or directory
│ Stacktrace:
[...] Eventually, I moved all code into single files
and all tests passed, but the previous folder structure was more organised. |
@dhanak Thanks for the PR. This is actually how an early version (pre v1) of the package worked, but the 2-argument version of So there are a few options:
I'd like to avoid 3 since it's more code to support and test - and might introduce subtle differences in behaviour between versions. Arguably option 2 is ok since Julia 1.6 is LTS. It would be informative to look at the Julia bound in packages using PackageExtensionCompat. |
@pat-alt Your issue is that only the root file for each extension gets rewritten currently. It would be straightforward to copy all the ext code over - could you make a separate issue for that please? |
Yes, now I can see from the tests that the two parameter include doesn't work before Julia 1.5. My mistake, but still a pity. Perhaps this on-the-fly variant of the WDYT? |
Yeah I considered that option, but I don't think it's really any different from option 3 above (branch on the Julia version) - the end result is the same and the amount of code to support is about the same. Personally I'd prefer option 3 - since then at least all the code is in one place. A disadvantage of your option 4 is that somebody may reasonably put a compat bound Is there any real objection to the status quo other than that icky feeling you get from rewriting code to disk just to immediately read it in again? |
A slight benefit would be that the code itself would be clearer in either variant, but you have a fair point.
This is all hypothesizing, but IMHO, if one were to maintain backward compatibility with Julia 1.0, one would surely check the package versions installed by Julia 1.0, where it would be immediately clear that PackageExtensionCompat v1 is being used.
For one, you need to add So overall, I don't really mind if everything stays as is, and it's your call to make, anyhow. |
That being said, I came up with a workaround that makes the parsing solution viable also for pre 1.5 versions. See the updated PR, please. |
IIUC this PR now implements the 3-arg version of |
I think you're right, this particular objection would be caught by proper testing.
How about this package also writes out a
I'm leaning this way - the current approach is nice and simple. I'd certainly prefer doing the transformation in-memory but without the 2-arg |
The `_include` and `rewrite` functions needed a bit of tweaking to handle inner includes and extension submodules correctly. Also added two tests for these scenarios.
You are perfectly right. It doesn't take care of inner includes, just as the current version, as you point it out. But this can be taken care of. While fixing this, I also noticed that neither implementation works well if the extension has a submodule and makes use of the dependent package from there. The I fixed all these in the PR, please see the updates. |
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.
Thanks for adding tests for submodules and includes. I'm now quite in favour of this PR. There's a few comments to address.
Also add some explanatory comments.
The API hasn't changed, so minor version doesn't need to change, either.
Welcome to Codecov 🎉Once merged to your default branch, Codecov will compare your coverage reports and display the results in this comment. Thanks for integrating Codecov - We've got you covered ☂️ |
Thanks very much for this! |
I really like this package, but IMHO the rewriting of the extension packages could be done without writing to the file system, providing a more robust approach. Here's my take on it.