-
-
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
Working IDAKLU standalone build and wheels #3
Conversation
If the git history starts from scratch, I will not be upset. We just have to make sure that we get the latest code from pybamm when we make the switch |
@santacodes Have you looked into getting the tests ported over? That is pretty important. Way more important than syncing git history |
I know that we have touched on this before, but only briefly – how about bringing the commit history from PyBaMM before the Your question on StackOverflow: https://stackoverflow.com/questions/78976790/how-do-i-restore-commit-history-for-a-specific-file-that-has-been-renamed does not really provide any details, it might be worth updating so that someone experienced with this can answer it. As for the tests, I guess we should check out the PyBaMM repo in another folder ( |
Lets not make this too complicated. We can link to the PR that does the switch and not worry too much about the history. We just make sure the code is identical on the day we switch and go from there. I don't want to see this held up due to minor issues that won't be important in a years time as the IDAKLU code keeps changing. The whole IDAKLU code went through a large refactor recently, so git blame isn't even that useful anyway. |
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.
I put in a few minor comments, I am testing the build now
Would it be a good idea to add the original authors of the solver signed as authors/co-authors in the commit where all the files of solvers are being added? This commit specifically. I think it would be a simple thing to do and that way we wouldn't have to move all of the history of commits. |
@santacodes Don't worry too much about attribution. This is still a PyBaMM team repo and their work is on PyBaMM. Just forget about that for now and lets focus on getting this working |
Please hold on with this – I spent a bit of time towards getting the commit history thingy working and it is working as intended; I got it done pretty quickly, actually: I now have a new repository locally that contains the history for all the code under the current Now that we know how to do this, I'd recommend trying this out, @santacodes: This is what I did, you may use a similar variation:
git filter-repo --path src/pybamm/solvers --path pybamm/solvers \
--path CMakeLists.txt \
--path pyproject.toml --path setup.py --path MANIFEST.in \
--path vcpkg-configuration.json --path vcpkg.json \
--path LICENSE.txt \
--force i.e., to include all the files that have been relevant to the compiled code in any way over the years. You may run the command in a clone of the PyBaMM repo, and once you are done, you can modify the repo's remote to point to a different GitHub repository, and push the changes there. Please feel free to include or exclude any files in this command that I might have missed including or excluding (for example, the C++ code is only in If there are concerns about how this will be factored into a PR, I recommend that @kratman do this in this repository, re-initialising it with the commit history (or just by creating a new repository if needed since this repository isn't being used at all right now). This is a one-time effort that should not take too long. |
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.
This has problems with its own dependencies. We need to do something about the idaklu_jax.py
and idaklu_solver.py
files requiring pybamm. Either that functionality needs to be migrated here as well, or they need to be removed
description = "Python interface for the IDAKLU solver" | ||
requires-python = ">=3.9" | ||
license = {file = "LICENSE"} | ||
dynamic = ["version", "readme"] | ||
dependencies = [] | ||
dependencies = ["pybamm", "casadi", "jax", "jaxlib"] |
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.
This library cannot depend on pybamm, otherwise it is a circular dependency
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.
Yes, this was a hacky fix to get it working which for some reason works without a circular dependency warning, I think migrating the functionalities here might be tricky though as they are part of different parts of code and are not grouped under a single namespace.
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.
Well here is the problem even if a circular dependency was not a major issue: PyBaMM installs IDAKLU, so how can you be certain that your install is working?
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.
Yes, we'll need to drop PyBaMM as a dependency and adjust the relevant code, even if it means adding a few more things to the Python bindings.
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.
Install pybamm from the branch I put up in the first PR comment, it has no IDAKLU. I made a fresh venv, installed pybamm without idaklu from the branch I mentioned and installed the pybammsolvers wheels in the same venv. That way all the tests pass. If you are still uncertain you could try running this inside a docker container and it would work, I say this because locally I don't install pip packages as system packages globally so there's no pybamm with idaklu available system-wide.
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.
As I mentioned above, a lot of the functionalities belong to different namespaces and classes so migration wouldn't be the best way possible imo. It would be like cherry picking only the specific functionalities of code that solver uses from pybamm and including it here, I'm sure there's a better way.
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.
I'm not sure I follow, but the plan is that we should aim for unvendoring the extension module completely – so that the pybammsolvers
wheel consists of just one shared object and a Python interface to it in the same folder.
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.
That's a great idea, but would that also mean we keep the idaklu_solver.py
and idaklu_jax.py
in the main PyBaMM repo and not move them here?
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.
I think the idea is that this is only for the C++ side. The python code and dependencies should stay with pybamm whenever possible
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.
I agree. As long as we have a reliable way of testing it with the PyBaMM test suite, we would be fine with a wheel that just contains a shared object
Thank you for the suggestion, works! 🎉 |
@santacodes I branched off this PR and I solved the circular dependency issues and a few other topics. I will a new PR after I finish implementing some tests. Mine is based on yours so you will still get credit in the git history |
@santacodes My PR seems to be working, so I am going to close this one now |
Got the
IDAKLU
solver built and working as a separate dependency. However, the restoration of the git commits history still remains a pending task.Installation
To build the wheels -
python -m build --wheel
To install the wheels -
python -m pip install dist/*.whl
Testing with the upstream PyBaMM repo with
pybammsolvers
as a separate dependency.With the same
venv
orconda
environment wherepybammsolvers
was installed with the procedures above, you could run the tests inPyBaMM
by cloning this PyBaMM branch without IDAKLU (Note: This branch is a pure python package and builds withhatch
).Issues with the
git commit history
I am trying to restore the history of commits for all the files that we would be moving from the PyBaMM repo to the pybammsolvers repo, the problem is mostly with git as recently we moved to the src layout in PyBaMM which basically means the files that were previously under
pybamm/solvers
are now undersrc/pybamm/solvers
, implying that the files were removed from the first path and added to the second path so locally trying to filter out commits didn't work as only the commits from after thesrc/
layout move was getting restored, I am not sure why this happens but my best guess would be when you move a file git interprets it as the file was deleted from the original path and a new file was created in the new path. While GitHub shows the previous commit history in a separate hyperlink below the git history page of files, this doesn't happen locally when Igit log -- /src/solvers
. Also, I am prioritising this commit history restoration work because I think we should credit the original authors of the files. Also, we would want the git blame working on the new repository.P.S. I have this issue posted up on StackOverflow. @kratman @agriyakhetarpal I would love to have your input on this as this is kind of the main blockage for me for the past two weeks.