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 1 commit
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
12 changes: 10 additions & 2 deletions modyn/supervisor/internal/pipeline_executor/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@
from typing import Any, Callable, Literal, Optional, Union, cast

import pandas as pd
from pydantic import BaseModel, Field, model_serializer, model_validator
from typing_extensions import override

from modyn.config.schema.pipeline import ModynPipelineConfig
from modyn.config.schema.system.config import ModynConfig
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 pydantic import BaseModel, Field, model_serializer, model_validator
from typing_extensions import override
from modyn.supervisor.internal.utils.git_utils import get_head_sha

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -472,6 +474,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 +519,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 525 in modyn/supervisor/internal/pipeline_executor/models.py

View check run for this annotation

Codecov / codecov/patch

modyn/supervisor/internal/pipeline_executor/models.py#L522-L525

Added lines #L522 - L525 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
9 changes: 9 additions & 0 deletions modyn/supervisor/internal/utils/git_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import subprocess


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

result = subprocess.run(["git", "rev-parse", "HEAD"], capture_output=True, text=True, check=True)
MaxiBoether marked this conversation as resolved.
Show resolved Hide resolved
assert result.returncode == 0, f"Failed to get HEAD SHA: {result.stderr}, {result.stdout}"
return result.stdout.strip()

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

View check run for this annotation

Codecov / codecov/patch

modyn/supervisor/internal/utils/git_utils.py#L7-L9

Added lines #L7 - L9 were not covered by tests
Loading