Skip to content

Commit

Permalink
Changes to gh individual json
Browse files Browse the repository at this point in the history
  • Loading branch information
RobbinBouwmeester committed Jan 26, 2025
1 parent 4172243 commit 2c74619
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion proteobench/github/gh.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,42 @@ def clone_repo_anonymous(self) -> Repo:
repo = self.clone(remote_url, self.clone_dir)
return repo

def read_results_json_repo(self) -> pd.DataFrame:
def read_results_json_repo_single_file(self) -> pd.DataFrame:
"""
Reads the `results.json` file from the cloned Proteobench repository and returns the data as a DataFrame.
Returns:
pd.DataFrame: A Pandas DataFrame containing the results from `results.json`.
"""
f_name = os.path.join(self.clone_dir, "results.json")

if not os.path.exists(f_name):
raise FileNotFoundError(f"File '{f_name}' does not exist.")

all_datapoints = pd.read_json(f_name)
return all_datapoints

def read_results_json_repo(self) -> pd.DataFrame:
"""
Reads all JSON result files from the cloned Proteobench repository.
Returns:
pd.DataFrame: A Pandas DataFrame containing aggregated results from multiple JSON files.
"""
data = []
if not os.path.exists(self.clone_dir):
raise FileNotFoundError(f"Clone directory '{self.clone_dir}' does not exist.")

for file in os.listdir(self.clone_dir):
if file.endswith(".json") and file != "results.json":
file_path = os.path.join(self.clone_dir, file)
with open(file_path, "r") as f:
data.append(pd.read_json(f, typ="series"))
if not data:
raise ValueError("No valid JSON data found in the repository.")

return pd.DataFrame(data)

def clone_repo(self) -> Repo:
"""
Clones the Proteobench repository using either an anonymous or authenticated GitHub access token.
Expand Down

0 comments on commit 2c74619

Please sign in to comment.