scribe.py 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. from collections.abc import Callable
  2. from typing import TypeAlias, Union
  3. try:
  4. from fbscribelogger import ( # type: ignore[import-untyped, import-not-found]
  5. make_scribe_logger,
  6. )
  7. except ImportError:
  8. TAtom: TypeAlias = Union[int, float, bool, str]
  9. TField: TypeAlias = Union[TAtom, list[TAtom]]
  10. TLazyField: TypeAlias = Union[TField, Callable[[], TField]]
  11. def make_scribe_logger(name: str, thrift_src: str) -> Callable[..., None]:
  12. def inner(**kwargs: TLazyField) -> None:
  13. pass
  14. return inner
  15. open_source_signpost = make_scribe_logger(
  16. "TorchOpenSourceSignpost",
  17. """
  18. struct TorchOpenSourceSignpostLogEntry {
  19. # The commit SHA that triggered the workflow, e.g., 02a6b1d30f338206a71d0b75bfa09d85fac0028a. Derived from GITHUB_SHA.
  20. 4: optional string commit_sha;
  21. # 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.
  22. 5: optional i64 commit_date;
  23. # 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.
  24. 6: optional string github_ref;
  25. # Indicates if branch protections or rulesets are configured for the ref that triggered the workflow run. Derived from GITHUB_REF_PROTECTED.
  26. 7: optional bool github_ref_protected;
  27. # A unique number for each attempt of a particular workflow run in a repository, e.g., 1. Derived from GITHUB_RUN_ATTEMPT.
  28. 8: optional string github_run_attempt;
  29. # A unique number for each workflow run within a repository, e.g., 19471190684. Derived from GITHUB_RUN_ID.
  30. 9: optional string github_run_id;
  31. # A unique number for each run of a particular workflow in a repository, e.g., 238742. Derived from GITHUB_RUN_NUMBER.
  32. 10: optional string github_run_number_str;
  33. # The name of the current job. Derived from JOB_NAME, e.g., linux-jammy-py3.8-gcc11 / test (default, 3, 4, linux.2xlarge).
  34. 11: optional string job_name;
  35. # The GitHub user who triggered the job. Derived from GITHUB_TRIGGERING_ACTOR.
  36. 12: optional string github_triggering_actor;
  37. 13: optional string name; # Event name
  38. 14: optional string parameters; # Parameters (JSON data)
  39. 16: optional string subsystem; # Subsystem the event is associated with
  40. # The unit timestamp in second for the Scuba Time Column override
  41. 17: optional i64 time;
  42. # The weight of the record according to current sampling rate
  43. 18: optional i64 weight;
  44. }
  45. """, # noqa: B950
  46. )