-
-
Notifications
You must be signed in to change notification settings - Fork 615
refactor: migrate citations.py from pybtex to bibtexparser #4974
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
base: develop
Are you sure you want to change the base?
Conversation
Thanks for starting this, @gurukiran7! To fix the tests, you'll need to add |
…ject.toml to enhance citation handling and testing.
@agriyakhetarpal I've updated the tests to align with the new citations.py implementation. At the moment, only a few tests are passing I'm still working on the rest. I want your feedback on the implementation so far |
I think the implementation is looking good, so far. Thanks! One important thing here will be to retain the same output from |
It looks like a stable release for |
done |
@agriyakhetarpal The test_citations test seems to be failing because read_citations() isn't populating _all_citations, so keys like "Sulzer2021" are missing during assertions. I suspect this might be due to the CITATIONS.bib file not loading correctly in the test environment. Could you please take a look and let me know if I’m missing something? |
🤔 The CI logs report a different error: |
Actually the current error I'm seeing is an AssertionError, not an ImportError. It's happening because _all_citations is empty, so the test fails when it checks for "Sulzer2021". |
Yes, that's alright, but the CI logs still don't reflect it – it is hence difficult to see all the failures. I pulled your branch to my machine, and I see the same error: https://github.com/search?q=repo:sciunto-org/python-bibtexparser+%22bibdatabase%22&type=code also reports no results, so I'm not sure where you're getting that attribute from. It's not in the documentation either: https://bibtexparser.readthedocs.io/en/main/search.html?q=bibdatabase |
…r v2 compatibility
Thanks for pointing that out! the ImportError stems from my use of BibDatabase, which was part of bibtexparser v1 but has been removed in v2. I mistakenly mixed v1-style imports with the newer v2 API. I’ve now updated the code to use Entry from bibtexparser.model instead and removed all references to BibDatabase. That should fix the import issue I’ll push the changes shortly. |
Hi @agriyakhetarpal , I've pushed the updated code, and most methods and their tests are passing as expected However, there's an issue with the register method, causing tests like test_citations and test_overwrite_citation to fail. Despite debugging, I couldn't resolve the issue, as it seems related to how citations are added to _all_citations and _papers_to_cite. |
Hi Gurukiran, I've triggered the workflows and I'm still not sure – the CI logs show otherwise? The tests are failing to load:
May I know the steps you're performing to run them locally, so that I can take a look at the Also, I'd like to note that we shouldn't use bibtexparser v1 here. The README at https://github.com/sciunto-org/python-bibtexparser#python-bibtexparser-v2 states:
which is code-speak to say that bibtexparser v1 will be deprecated in the near future in favour of bibtexparser v2. This is a problem for three reasons:
|
… v1 to bibtexparser==2.0.0b8 as per project requirements
I switched back to bibtexparser==2.0.0b8, I have pushed the updated code. |
Thanks! Could you please run the whole test suite using Also, you would need to fix the |
@agriyakhetarpal I've pushed the latest updated code addressing most of the test failures and feedback Refactored the register method and _add_citation to support bibtexparser v2+ |
@agriyakhetarpal , @kratman , I've pushed the latest code please review when you get a chance |
Description
This PR refactors
pybamm/citations.py
to fully remove the legacypybtex
dependency and migrate all citation management tobibtexparser
(v2). The new implementation:register
method to handle both known keys and raw BibTeX stringsFixes #3648
Important checks:
Please confirm the following before marking the PR as ready for review:
nox -s pre-commit
nox -s tests
nox -s doctests