xref: /aosp_15_r20/external/pytorch/torch/_logging/scribe.py (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1from typing import Callable, List, Union
2from typing_extensions import TypeAlias
3
4
5try:
6    from fbscribelogger import make_scribe_logger  # type: ignore[import-untyped]
7except ImportError:
8    TAtom: TypeAlias = Union[int, float, bool, str]
9    TField: TypeAlias = Union[TAtom, List[TAtom]]
10    TLazyField: TypeAlias = Union[TField, Callable[[], TField]]
11
12    def make_scribe_logger(name: str, thrift_src: str) -> Callable[..., None]:
13        def inner(**kwargs: TLazyField) -> None:
14            pass
15
16        return inner
17
18
19open_source_signpost = make_scribe_logger(
20    "TorchOpenSourceSignpost",
21    """
22struct TorchOpenSourceSignpostLogEntry {
23
24  # The commit SHA that triggered the workflow, e.g., 02a6b1d30f338206a71d0b75bfa09d85fac0028a. Derived from GITHUB_SHA.
25  4: optional string commit_sha;
26
27  # Commit date (not author date) of the commit in commit_sha as timestamp, e.g., 1724208105.  Increasing if merge bot is used, though not monotonic; duplicates occur when stack is landed.
28  5: optional i64 commit_date;
29
30  # The fully-formed ref of the branch or tag that triggered the workflow run, e.g., refs/pull/133891/merge or refs/heads/main. Derived from GITHUB_REF.
31  6: optional string github_ref;
32
33  # Indicates if branch protections or rulesets are configured for the ref that triggered the workflow run. Derived from GITHUB_REF_PROTECTED.
34  7: optional bool github_ref_protected;
35
36  # A unique number for each attempt of a particular workflow run in a repository, e.g., 1. Derived from GITHUB_RUN_ATTEMPT.
37  8: optional string github_run_attempt;
38
39  # A unique number for each workflow run within a repository, e.g., 19471190684. Derived from GITHUB_RUN_ID.
40  9: optional string github_run_id;
41
42  # A unique number for each run of a particular workflow in a repository, e.g., 238742. Derived from GITHUB_RUN_NUMBER.
43  10: optional string github_run_number_str;
44
45  # The name of the current job. Derived from JOB_NAME, e.g., linux-jammy-py3.8-gcc11 / test (default, 3, 4, amz2023.linux.2xlarge).
46  11: optional string job_name;
47
48  # The GitHub user who triggered the job.  Derived from GITHUB_TRIGGERING_ACTOR.
49  12: optional string github_triggering_actor;
50  13: optional string name; # Event name
51  14: optional string parameters; # Parameters (JSON data)
52  16: optional string subsystem; # Subsystem the event is associated with
53
54  # The unit timestamp in second for the Scuba Time Column override
55  17: optional i64 time;
56
57  # The weight of the record according to current sampling rate
58  18: optional i64 weight;
59}
60""",  # noqa: B950
61)
62