Skip to content

Commit

Permalink
better handling when no git repo is present
Browse files Browse the repository at this point in the history
  • Loading branch information
damonbayer committed Dec 16, 2024
1 parent f6cb497 commit 673b8f6
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pipelines/forecast_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,15 @@

def record_git_info(model_run_dir: Path):
metadata_file = Path(model_run_dir, "metadata.yaml")
repo = Repository(os.getcwd())
branch_name = os.environ.get("GIT_BRANCH_NAME", Path(repo.head.name).stem)
commit_sha = os.environ.get("GIT_COMMIT_SHA", str(repo.head.target))
try:
repo = Repository(os.getcwd())
branch_name = os.environ.get(

Check warning on line 26 in pipelines/forecast_state.py

View check run for this annotation

Codecov / codecov/patch

pipelines/forecast_state.py#L22-L26

Added lines #L22 - L26 were not covered by tests
"GIT_BRANCH_NAME", Path(repo.head.name).stem
)
commit_sha = os.environ.get("GIT_COMMIT_SHA", str(repo.head.target))
except:
branch_name = os.environ.get("GIT_BRANCH_NAME", "unknown")
commit_sha = os.environ.get("GIT_COMMIT_SHA", "unknown")

Check warning on line 32 in pipelines/forecast_state.py

View check run for this annotation

Codecov / codecov/patch

pipelines/forecast_state.py#L29-L32

Added lines #L29 - L32 were not covered by tests

metadata = {

Check warning on line 34 in pipelines/forecast_state.py

View check run for this annotation

Codecov / codecov/patch

pipelines/forecast_state.py#L34

Added line #L34 was not covered by tests
"branch_name": branch_name,
Expand Down

0 comments on commit 673b8f6

Please sign in to comment.