|
12 | 12 | from git.config import GitConfigParser |
13 | 13 |
|
14 | 14 | import agentlab |
| 15 | +from agentlab.experiments.exp_utils import RESULTS_DIR |
15 | 16 |
|
16 | 17 |
|
17 | 18 | def _get_repo(module): |
@@ -193,8 +194,13 @@ def get_reproducibility_info( |
193 | 194 | if isinstance(agent_names, str): |
194 | 195 | agent_names = [agent_names] |
195 | 196 |
|
| 197 | + try: |
| 198 | + repo = _get_repo(agentlab) |
| 199 | + except InvalidGitRepositoryError: |
| 200 | + repo = None |
| 201 | + |
196 | 202 | info = { |
197 | | - "git_user": _get_git_username(_get_repo(agentlab)), |
| 203 | + "git_user": _get_git_username(repo), |
198 | 204 | "agent_names": agent_names, |
199 | 205 | "benchmark": benchmark.name, |
200 | 206 | "study_id": study_id, |
@@ -313,7 +319,19 @@ def append_to_journal( |
313 | 319 | ): |
314 | 320 | """Append the info and results to the reproducibility journal.""" |
315 | 321 | 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}") |
317 | 335 |
|
318 | 336 | if len(report_df) != len(info["agent_names"]): |
319 | 337 | raise ValueError( |
|
0 commit comments