Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Log commit sha #537

Merged
merged 2 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions modyn/supervisor/internal/pipeline_executor/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from modyn.supervisor.internal.eval.handler import EvalRequest
from modyn.supervisor.internal.grpc.enums import PipelineStage
from modyn.supervisor.internal.utils.evaluation_status_reporter import EvaluationStatusReporter
from modyn.supervisor.internal.utils.git_utils import get_head_sha
from pydantic import BaseModel, Field, model_serializer, model_validator
from typing_extensions import override

Expand Down Expand Up @@ -472,6 +473,7 @@
# static logs

pipeline_id: int
commit_sha: str | None = Field(None, description="The commit SHA that the pipeline was executed on.")
pipeline_stages: dict[str, tuple[int, list[str]]]
"""List of all pipeline stages, their execution order index, and their parent stages."""

Expand Down Expand Up @@ -516,6 +518,11 @@
# output logs

if mode == "initial":
try:
self.commit_sha = get_head_sha()
except Exception as e: # pylint: disable=broad-except
logger.warning(f"Failed to get commit SHA: {e}")

Check warning on line 524 in modyn/supervisor/internal/pipeline_executor/models.py

View check run for this annotation

Codecov / codecov/patch

modyn/supervisor/internal/pipeline_executor/models.py#L521-L524

Added lines #L521 - L524 were not covered by tests

with open(pipeline_logdir / "pipeline.part.log", "w", encoding="utf-8") as logfile:
logfile.write(self.model_dump_json(indent=2, exclude={"supervisor", "partial_idx"}, by_alias=True))
return
Expand Down
12 changes: 12 additions & 0 deletions modyn/supervisor/internal/utils/git_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import subprocess
from pathlib import Path


def get_head_sha() -> str:
"""When launched in a git repository, return the SHA of the current HEAD."""

result = subprocess.run(

Check warning on line 8 in modyn/supervisor/internal/utils/git_utils.py

View check run for this annotation

Codecov / codecov/patch

modyn/supervisor/internal/utils/git_utils.py#L8

Added line #L8 was not covered by tests
["git", "rev-parse", "HEAD"], capture_output=True, text=True, check=True, cwd=Path(__file__).parent
)
assert result.returncode == 0, f"Failed to get HEAD SHA: {result.stderr}, {result.stdout}"
return result.stdout.strip()

Check warning on line 12 in modyn/supervisor/internal/utils/git_utils.py

View check run for this annotation

Codecov / codecov/patch

modyn/supervisor/internal/utils/git_utils.py#L11-L12

Added lines #L11 - L12 were not covered by tests
Loading