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..b2c529ff 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,19 @@ 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: + 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}") if len(report_df) != len(info["agent_names"]): raise ValueError(