proteobench.github.gh module#
This module provides the GithubProteobotRepo class to interact with GitHub repositories related to Proteobot and Proteobench. It allows cloning repositories, reading JSON result files, creating branches, committing changes, and creating pull requests.
- class proteobench.github.gh.GithubProteobotRepo(token: str | None = None, clone_dir: str = None, clone_dir_pr: str = None, proteobench_repo_name: str = 'Proteobench/Results_quant_ion_DDA', proteobot_repo_name: str = 'Proteobot/Results_quant_ion_DDA', username: str = 'Proteobot', branch: str | None = None)[source]#
Bases:
objectA class to interact with GitHub repositories related to Proteobot and Proteobench, allowing cloning, committing, and creating pull requests.
- Parameters:
token (str | None, optional) – GitHub access token for authenticated access. Defaults to None.
clone_dir (str) – Directory where the repository will be cloned.
clone_dir_pr (str) – Directory for cloning pull request repositories.
proteobench_repo_name (str, optional) – Name of the Proteobench repository. Defaults to “Proteobench/Results_quant_ion_DDA”.
proteobot_repo_name (str, optional) – Name of the Proteobot repository. Defaults to “Proteobot/Results_quant_ion_DDA”.
username (str, optional) – GitHub username for authentication. Defaults to “Proteobot”.
- static clone(remote_url: str, clone_dir: str) Repo[source]#
Clone the repository from the given remote URL to the specified directory.
- Parameters:
- Returns:
The local repository object.
- Return type:
Repo
- Raises:
exc.NoSuchPathError – If the specified directory does not exist.
exc.InvalidGitRepositoryError – If the directory is not a valid Git repository.
- clone_repo() Repo[source]#
Clone the Proteobench repository using either an anonymous or authenticated GitHub access token.
If token is provided, it will use authenticated access; otherwise, it will clone anonymously.
When
self.branchis set, the repository is cloned from the Proteobot repository and the specified branch is checked out. If the directory already exists, the method fetches and checks out the requested branch to ensure the correct revision is used.- Returns:
The local repository object.
- Return type:
Repo
- clone_repo_anonymous() Repo[source]#
Clone the Proteobench repository anonymously with a shallow clone (without authentication).
If
self.branchis set, the repository is cloned from the Proteobot repository (not Proteobench) and the specified branch is checked out. This allows reading JSON files from a PR branch that has not yet been merged into Proteobench (for testing purposes). When the clone directory already exists, the method fetches and checks out the requested branch to ensure the correct revision is used.- Returns:
The cloned repository object.
- Return type:
Repo
- clone_repo_pr() Repo[source]#
Clone the Proteobot repository (for pull request management) using either an anonymous or authenticated GitHub access token.
If token is provided, it will use authenticated access; otherwise, it will clone anonymously.
- Returns:
The local repository object for the pull request.
- Return type:
Repo
- commit(commit_name: str, commit_message: str) None[source]#
Stage all changes, commits them with the given commit name and message, and pushes the changes to the remote repository.
- create_branch(branch_name: str) <property object at 0x746ba83f6c00>[source]#
Create a new branch and checks it out.
- Parameters:
branch_name (str) – The name of the new branch to be created.
- Returns:
The newly created branch object.
- Return type:
Repo.head
- create_pull_request(commit_name: str, commit_message: str, submission_source: str = 'unknown') int[source]#
Create a pull request on GitHub using the PyGithub API.
- Parameters:
- Returns:
The pull request number assigned by GitHub.
- Return type:
- get_remote_url_anon() str[source]#
Return the remote URL of the repository to be cloned anonymously (public access).
- Returns:
The public GitHub URL of the Proteobench repository.
- Return type:
- read_results_json_repo() DataFrame[source]#
Read all JSON result files from the cloned Proteobench repository.
- Returns:
A Pandas DataFrame containing aggregated results from multiple JSON files.
- Return type:
pd.DataFrame