Skip to content

Commit 4eecdf7

Browse files
authored
Refine ux 2 (#155)
* Adjusting for users with no git clone * Add warning for missing git repository in journal appending * black
1 parent a3491da commit 4eecdf7

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

src/agentlab/analyze/agent_xray.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,10 @@ def run_gradio(results_dir: Path):
501501
demo.queue()
502502

503503
do_share = os.getenv("AGENTXRAY_SHARE_GRADIO", "false").lower() == "true"
504-
demo.launch(server_port=int(os.getenv("AGENTXRAY_APP_PORT", "7899")), share=do_share)
504+
port = os.getenv("AGENTXRAY_APP_PORT", None)
505+
if isinstance(port, str):
506+
port = int(port)
507+
demo.launch(server_port=port, share=do_share)
505508

506509

507510
def tab_select(evt: gr.SelectData):

src/agentlab/experiments/reproducibility_util.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from git.config import GitConfigParser
1313

1414
import agentlab
15+
from agentlab.experiments.exp_utils import RESULTS_DIR
1516

1617

1718
def _get_repo(module):
@@ -193,8 +194,13 @@ def get_reproducibility_info(
193194
if isinstance(agent_names, str):
194195
agent_names = [agent_names]
195196

197+
try:
198+
repo = _get_repo(agentlab)
199+
except InvalidGitRepositoryError:
200+
repo = None
201+
196202
info = {
197-
"git_user": _get_git_username(_get_repo(agentlab)),
203+
"git_user": _get_git_username(repo),
198204
"agent_names": agent_names,
199205
"benchmark": benchmark.name,
200206
"study_id": study_id,
@@ -313,7 +319,19 @@ def append_to_journal(
313319
):
314320
"""Append the info and results to the reproducibility journal."""
315321
if journal_path is None:
316-
journal_path = Path(agentlab.__file__).parent.parent.parent / "reproducibility_journal.csv"
322+
try:
323+
_get_repo(agentlab) # if not based on git clone, this will raise an error
324+
journal_path = (
325+
Path(agentlab.__file__).parent.parent.parent / "reproducibility_journal.csv"
326+
)
327+
except InvalidGitRepositoryError:
328+
logging.warning(
329+
"Could not find a git repository. Saving the journal to the results directory."
330+
"To add to the journal, git clone agentlab and use `pip install -e .`"
331+
)
332+
journal_path = RESULTS_DIR / "reproducibility_journal.csv"
333+
334+
logging.info(f"Appending to journal {journal_path}")
317335

318336
if len(report_df) != len(info["agent_names"]):
319337
raise ValueError(

0 commit comments

Comments
 (0)