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

fix: prevent exiting the loop when one package dep_credit is too small #55

Merged
merged 3 commits into from
Jan 20, 2025

Conversation

hykelvinlee42
Copy link
Contributor

@hykelvinlee42 hykelvinlee42 commented Jan 20, 2025

This PR fixes #54.

Currently when processing a dependency list file, if a package with a dep_credit below min_credit has higher precedence over the other packages in the list, the code logic would exit the loop and prevent looking into the dependencies of the rest of the packages in the list.

Consider a requirements.txt file with two dependencies, pandas and requests, if pandas, which has a dep_credit smaller than the default min_credit (0.01), is put on higher precedence over requests, the code would not generate dependencies for requests, which has a dep_credit bigger than 0.01.

pandas
requests
# Software Credit

<!--citelang start-->
|Manager|Name|Credit|
|-------|----|------|
|requirements.txt|python-lib|0.5|
|pypi|[pandas](https://pandas.pydata.org)|0.25|
|pypi|[requests](https://pypi.org/project/requests)|0.25|


> Note that credit values are rounded and expanded (so shared dependencies are represented as one record) and may not add to 1.0. Rounded values that hit zero are removed.

<!--citelang end-->

- Generated by [CiteLang](https://github.com/vsoch/citelang)

The code should continue looking into the dependencies of requests despite pandas having a small dep_credit. The code should also generate the same dependency output regardless of the order of packages in the dependency list.

# Software Credit

<!--citelang start-->
|Manager|Name|Credit|
|-------|----|------|
|requirements.txt|python-lib|0.5|
|pypi|[pandas](https://pandas.pydata.org)|0.25|
|pypi|[requests](https://requests.readthedocs.io)|0.12|
|pypi|[charset-normalizer](https://pypi.org/project/charset-normalizer)|0.02|
|pypi|[idna](https://pypi.org/project/idna)|0.02|
|pypi|[urllib3](https://pypi.org/project/urllib3)|0.02|
|pypi|[certifi](https://pypi.org/project/certifi)|0.02|
|pypi|[PySocks](https://pypi.org/project/PySocks)|0.02|
|pypi|[chardet](https://pypi.org/project/chardet)|0.02|


> Note that credit values are rounded and expanded (so shared dependencies are represented as one record) and may not add to 1.0. Rounded values that hit zero are removed.

<!--citelang end-->

- Generated by [CiteLang](https://github.com/vsoch/citelang)

This PR changes the logic, instead of exiting the loop, the code will jump to look into dependencies of the rest of the packages in next_nodes. It also fixes type errors when parsing --max-depth and --max-deps arguments by adding type converters for the arguments in the command line.

@vsoch
Copy link
Owner

vsoch commented Jan 20, 2025

Excellent work! Could you please:

  1. Show the (now fixed) output from your original requirements.txt and requirements-1.txt in the description here
  2. Bump the version in citelang/version.py and add a corresponding note to the CHANGELOG.md

@vsoch
Copy link
Owner

vsoch commented Jan 20, 2025

The output generates equivalently now regardless of order?

@hykelvinlee42
Copy link
Contributor Author

Yes, the outputs generated are now consistent regardless of order (I should've mentioned it).

Whether it's,

pandas
requests

or

requests
pandas

@vsoch vsoch merged commit bbd8618 into vsoch:main Jan 20, 2025
2 checks passed
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

Successfully merging this pull request may close these issues.

Generating incomplete/discrepant credits when using requirements.txt
2 participants