Python wrapper for the GitHub API
APACHE-2.0 License
This project uses GitHub API to fetch information from GitHub using a Python wrapper.
You can find the exhaustive list of supported features in the documentation. For instance, you can retrieve basic information about your pull request as follows:
from ghapi.pulls import Repository, PullRequest
pr = PullRequest(Repository("frgfm", "torch-cam"), 187)
# Get the PR information
pr.get_info()
{'title': 'fix: Fixed zero division for weight computation in gradient based methods',
'created_at': '2022-09-18T17:08:50Z',
'description': 'This PR introduces an `eps` to all divisions in gradient methods to avoid NaNs.\r\n\r\nCloses #186',
'labels': [{'id': 1929545961,
'node_id': 'MDU6TGFiZWwxOTI5NTQ1OTYx',
'url': 'https://api.github.com/repos/frgfm/torch-cam/labels/type:%20bug',
'name': 'type: bug',
'color': 'd73a4a',
'default': False,
'description': "Something isn't working"},
{'id': 1929975543,
'node_id': 'MDU6TGFiZWwxOTI5OTc1NTQz',
'url': 'https://api.github.com/repos/frgfm/torch-cam/labels/ext:%20tests',
'name': 'ext: tests',
'color': 'f7e101',
'default': False,
'description': 'Related to test'},
{'id': 1929975788,
'node_id': 'MDU6TGFiZWwxOTI5OTc1Nzg4',
'url': 'https://api.github.com/repos/frgfm/torch-cam/labels/module:%20methods',
'name': 'module: methods',
'color': 'f7e101',
'default': False,
'description': 'Related to torchcam.methods'}],
'user': 'frgfm',
'mergeable': None,
'changed_files': 3,
'additions': 15,
'deletions': 8,
'base': {'branch': 'main', 'sha': '0a5e06051440e27de6027ec382517a2c71686298'},
'head': {'repo': 'frgfm/torch-cam',
'branch': 'grad-nans',
'sha': 'd49f4a3d847e130e99c3d20311e1450f074fd29f'}}
If you're interested in reviewing the pull request, you might be interested in the code diff:
# Retrieve the code diff
full_diff = pr.get_diff()
# Print the first diff section
print(full_diff["torchcam/methods/gradient.py"][0]["text"])
which yields:
- def _get_weights(self, class_idx: Union[int, List[int]], scores: Tensor, **kwargs: Any) -> List[Tensor]:
+ def _get_weights(
+ self, class_idx: Union[int, List[int]], scores: Tensor, eps: float = 1e-8, **kwargs: Any
+ ) -> List[Tensor]:
Python 3.6 (or higher) and pip/conda are required to install ghapi
.
You can install the last stable release of the package using pypi as follows:
pip install ghapi-client
or using conda:
conda install -c frgfm ghapi-client
Alternatively, if you wish to use the latest features of the project that haven't made their way to a release yet, you can install the package from source:
git clone https://github.com/frgfm/ghapi.git
pip install -e ghapi/.
The full package documentation is available here for detailed specifications.
Feeling like extending the range of supported API feature? Or perhaps submitting a new feature idea? Any sort of contribution is greatly appreciated!
You can find a short guide in CONTRIBUTING
to help grow this project!
Distributed under the Apache 2.0 License. See LICENSE
for more information.