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')[source]#

Bases: object

A 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:
  • remote_url (str) – The URL of the remote GitHub repository.

  • clone_dir (str) – The directory where the repository will be cloned.

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.

Returns:

The local repository object.

Return type:

Repo

clone_repo_anonymous() Repo[source]#

Clone the Proteobench repository anonymously with a shallow clone (without authentication).

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.

Parameters:
  • commit_name (str) – The name of the commit.

  • commit_message (str) – The commit message.

create_branch(branch_name: str) <property object at 0x768ca9d2e8e0>[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) int[source]#

Create a pull request on GitHub using the PyGithub API.

Parameters:
  • commit_name (str) – The title of the pull request.

  • commit_message (str) – The body of the pull request.

Returns:

The pull request number assigned by GitHub.

Return type:

int

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:

str

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

read_results_json_repo_single_file() DataFrame[source]#

Read the results.json file from the cloned Proteobench repository and returns the data as a DataFrame.

Returns:

A Pandas DataFrame containing the results from results.json.

Return type:

pd.DataFrame

static shallow_clone(remote_url: str, clone_dir: str) Repo[source]#

Perform a shallow clone of the repository (only the latest commit).

Parameters:
  • remote_url (str) – The repository URL.

  • clone_dir (str) – The target directory for cloning.

Returns:

The cloned repository object.

Return type:

Repo