From 8f52efd81f5eefb21193692b117a398d4a2a670e Mon Sep 17 00:00:00 2001 From: recursix Date: Mon, 25 Nov 2024 15:53:52 -0500 Subject: [PATCH 1/3] Adjusting for users with no git clone --- src/agentlab/analyze/agent_xray.py | 5 ++++- src/agentlab/experiments/reproducibility_util.py | 16 ++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/agentlab/analyze/agent_xray.py b/src/agentlab/analyze/agent_xray.py index c4946850..9764898c 100644 --- a/src/agentlab/analyze/agent_xray.py +++ b/src/agentlab/analyze/agent_xray.py @@ -501,7 +501,10 @@ def run_gradio(results_dir: Path): demo.queue() do_share = os.getenv("AGENTXRAY_SHARE_GRADIO", "false").lower() == "true" - demo.launch(server_port=int(os.getenv("AGENTXRAY_APP_PORT", "7899")), share=do_share) + port = os.getenv("AGENTXRAY_APP_PORT", None) + if isinstance(port, str): + port = int(port) + demo.launch(server_port=port, share=do_share) def tab_select(evt: gr.SelectData): diff --git a/src/agentlab/experiments/reproducibility_util.py b/src/agentlab/experiments/reproducibility_util.py index 52e4e62a..4125b905 100644 --- a/src/agentlab/experiments/reproducibility_util.py +++ b/src/agentlab/experiments/reproducibility_util.py @@ -12,6 +12,7 @@ from git.config import GitConfigParser import agentlab +from agentlab.experiments.exp_utils import RESULTS_DIR def _get_repo(module): @@ -193,8 +194,13 @@ def get_reproducibility_info( if isinstance(agent_names, str): agent_names = [agent_names] + try: + repo = _get_repo(agentlab) + except InvalidGitRepositoryError: + repo = None + info = { - "git_user": _get_git_username(_get_repo(agentlab)), + "git_user": _get_git_username(repo), "agent_names": agent_names, "benchmark": benchmark.name, "study_id": study_id, @@ -313,7 +319,13 @@ def append_to_journal( ): """Append the info and results to the reproducibility journal.""" if journal_path is None: - journal_path = Path(agentlab.__file__).parent.parent.parent / "reproducibility_journal.csv" + try: + _get_repo(agentlab) # if not based on git clone, this will raise an error + journal_path = Path(agentlab.__file__).parent.parent.parent / "reproducibility_journal.csv" + except InvalidGitRepositoryError: + journal_path = RESULTS_DIR / "reproducibility_journal.csv" + + logging.info(f"Appending to journal {journal_path}") if len(report_df) != len(info["agent_names"]): raise ValueError( From 6f6588af4ceb390d87562c2b94c2b67fb1df835e Mon Sep 17 00:00:00 2001 From: recursix Date: Mon, 25 Nov 2024 15:56:59 -0500 Subject: [PATCH 2/3] Add warning for missing git repository in journal appending --- src/agentlab/experiments/reproducibility_util.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/agentlab/experiments/reproducibility_util.py b/src/agentlab/experiments/reproducibility_util.py index 4125b905..3ffb5af0 100644 --- a/src/agentlab/experiments/reproducibility_util.py +++ b/src/agentlab/experiments/reproducibility_util.py @@ -323,6 +323,8 @@ def append_to_journal( _get_repo(agentlab) # if not based on git clone, this will raise an error journal_path = Path(agentlab.__file__).parent.parent.parent / "reproducibility_journal.csv" except InvalidGitRepositoryError: + logging.warning("Could not find a git repository. Saving the journal to the results directory." + "To add to the journal, git clone agentlab and use `pip install -e .`") journal_path = RESULTS_DIR / "reproducibility_journal.csv" logging.info(f"Appending to journal {journal_path}") From 2e4b44ae750244db2dc78639a37b96b3f0f077c6 Mon Sep 17 00:00:00 2001 From: recursix Date: Mon, 25 Nov 2024 15:58:15 -0500 Subject: [PATCH 3/3] black --- src/agentlab/experiments/reproducibility_util.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/agentlab/experiments/reproducibility_util.py b/src/agentlab/experiments/reproducibility_util.py index 3ffb5af0..b2c529ff 100644 --- a/src/agentlab/experiments/reproducibility_util.py +++ b/src/agentlab/experiments/reproducibility_util.py @@ -195,7 +195,7 @@ def get_reproducibility_info( agent_names = [agent_names] try: - repo = _get_repo(agentlab) + repo = _get_repo(agentlab) except InvalidGitRepositoryError: repo = None @@ -320,11 +320,15 @@ def append_to_journal( """Append the info and results to the reproducibility journal.""" if journal_path is None: try: - _get_repo(agentlab) # if not based on git clone, this will raise an error - journal_path = Path(agentlab.__file__).parent.parent.parent / "reproducibility_journal.csv" + _get_repo(agentlab) # if not based on git clone, this will raise an error + journal_path = ( + Path(agentlab.__file__).parent.parent.parent / "reproducibility_journal.csv" + ) except InvalidGitRepositoryError: - logging.warning("Could not find a git repository. Saving the journal to the results directory." - "To add to the journal, git clone agentlab and use `pip install -e .`") + logging.warning( + "Could not find a git repository. Saving the journal to the results directory." + "To add to the journal, git clone agentlab and use `pip install -e .`" + ) journal_path = RESULTS_DIR / "reproducibility_journal.csv" logging.info(f"Appending to journal {journal_path}")