abc-classroom
abc-classroom copied to clipboard
Update ABC-classroom to use pygithub rather than github3.py
pygithub is more active and has many more users. github3 hasn't been updated in over a year.
Let's consider moving to pygithub
Below is some quick code that creates a repo in the earth analytics edu org! The one thing that i couldn't find examples for was authenticating and creating a token which does exist now via abc-init. but it seems like this should be doable via subprocess if need be altho i did see an authenticator in pygithub just no good examples of calling it.
from github import Github
# using username and password
g = Github(gh_username, password )
g = Github("token-string-here")
organization = g.get_organization("earth-analytics-edu")
# Get all repos and print them out for the earth analytics edu org
for repo in organization.get_repos():
print(repo.name)
organization.create_repo(
name="test-template",
allow_rebase_merge=True,
auto_init=False,
description="yaas done from the API",
has_issues=True,
has_projects=False,
has_wiki=False,
private=True,
)
This can then be used to
- authenticate
- create token with github
- create a new repo.
We can potentially use other parts of jed's scripts OR abc-classroom to create and initialize the local repo. there is an init function here in abc-classroom.
Just a note here that we are getting a warning about github3's import of collections (when running our tests) that will become an error with python 3.9. This is fixed on their master branch, but they haven't done a release since 2018. It does look like there has been some recent activity on the github3 project, so maybe it is getting going again?
/usr/local/miniconda3/envs/abc/lib/python3.8/site-packages/github3/structs.py:11
/usr/local/miniconda3/envs/abc/lib/python3.8/site-packages/github3/structs.py:11: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.9 it will stop working
class GitHubIterator(models.GitHubCore, collections.Iterator):
oooh. could be worth opening an issue just to check that they plan to update accordingly??
@kcranston @nkorinek i just checked. A release for github3 was pushed to pypi and conda-forge in 2021. it fixes that error. I think we should decide whether we want to use it vs subprocess or pygithub before we really dig into tests as it will impact how we collect responses. in some cases the returned information could be formatted differently between packages for example.
karen, let me know what you think. the last commit to github3.py was 2 days ago. i just haven't taken the time to compare the two packages. we should make a decision and then close this issue and focus on tests!
i'm adding this to the tests for git operations milestone
Given the small number of API calls, I don't think we need a dependency on a github library at all. I suggest we get rid of github3 and simply call the APIs using requests.
@kcranston @nkorinek this can be closed when you submit the change we talked about today with updating dependencies. please reference this issue 72 when you submit so we can close it