buildgrid 0.3.2__py3-none-any.whl → 0.3.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1907,6 +1907,7 @@ class Scheduler:
1907
1907
 
1908
1908
  def _publish_job_duration(
1909
1909
  self,
1910
+ instance_name: str,
1910
1911
  start: Timestamp | None,
1911
1912
  end: Timestamp | None,
1912
1913
  state: str,
@@ -1920,6 +1921,7 @@ class Scheduler:
1920
1921
  publish_timer_metric(
1921
1922
  METRIC.JOB.DURATION,
1922
1923
  end.ToDatetime() - start.ToDatetime(), # type: ignore[union-attr]
1924
+ instanceName=instance_name,
1923
1925
  state=state,
1924
1926
  propertyLabel=property_label,
1925
1927
  schedulerName=assigner_name or "none",
@@ -1965,6 +1967,7 @@ class Scheduler:
1965
1967
  now_timestamp = Timestamp()
1966
1968
  now_timestamp.FromDatetime(datetime.utcnow())
1967
1969
  self._publish_job_duration(
1970
+ next_job.instance_name,
1968
1971
  start_timestamp,
1969
1972
  now_timestamp,
1970
1973
  "Queued",
@@ -2227,6 +2230,7 @@ class Scheduler:
2227
2230
  now_timestamp = Timestamp()
2228
2231
  now_timestamp.FromDatetime(datetime.utcnow())
2229
2232
  self._publish_job_duration(
2233
+ job.instance_name,
2230
2234
  start_timestamp,
2231
2235
  now_timestamp,
2232
2236
  "Queued",
@@ -2460,14 +2464,16 @@ class Scheduler:
2460
2464
  action_result.execution_metadata.worker_completed_timestamp.FromDatetime(job.worker_completed_timestamp or now)
2461
2465
  response = ExecuteResponse(result=action_result, cached_result=False, status=status)
2462
2466
 
2463
- job.result = digest_to_string(self.storage.put_message(response))
2467
+ with instance_context(job.instance_name):
2468
+ job.result = digest_to_string(self.storage.put_message(response))
2464
2469
 
2465
2470
  self._update_job_timestamps(session, job, action_result.execution_metadata)
2466
2471
 
2467
2472
  if self.action_cache and result and not job.do_not_cache:
2468
2473
  action_digest = string_to_digest(job.action_digest)
2469
2474
  try:
2470
- self.action_cache.update_action_result(action_digest, action_result)
2475
+ with instance_context(job.instance_name):
2476
+ self.action_cache.update_action_result(action_digest, action_result)
2471
2477
  LOGGER.debug(
2472
2478
  "Stored action result in ActionCache.",
2473
2479
  tags=dict(action_result=action_result, digest=action_digest),
@@ -2527,7 +2533,12 @@ class Scheduler:
2527
2533
  )
2528
2534
  )
2529
2535
  self._publish_execution_stats(
2530
- session, job.name, action_result.execution_metadata, job.property_label, job.assigner_name
2536
+ session,
2537
+ job.name,
2538
+ job.instance_name,
2539
+ action_result.execution_metadata,
2540
+ job.property_label,
2541
+ job.assigner_name,
2531
2542
  )
2532
2543
 
2533
2544
  def get_bot_status_metrics(self) -> BotMetrics:
@@ -2653,7 +2664,9 @@ class Scheduler:
2653
2664
  return metadata
2654
2665
 
2655
2666
  def _fetch_execution_stats(
2656
- self, auxiliary_metadata: RepeatedCompositeFieldContainer[ProtoAny]
2667
+ self,
2668
+ auxiliary_metadata: RepeatedCompositeFieldContainer[ProtoAny],
2669
+ instance_name: str,
2657
2670
  ) -> ExecutionStatistics | None:
2658
2671
  """Fetch ExecutionStatistics from Storage
2659
2672
  ProtoAny[Digest] -> ProtoAny[ExecutionStatistics]
@@ -2666,7 +2679,8 @@ class Scheduler:
2666
2679
  try:
2667
2680
  aux_metadata_any.Unpack(aux_metadata_digest)
2668
2681
  # Get the blob from CAS
2669
- execution_stats_any = self.storage.get_message(aux_metadata_digest, ProtoAny)
2682
+ with instance_context(instance_name):
2683
+ execution_stats_any = self.storage.get_message(aux_metadata_digest, ProtoAny)
2670
2684
  # Get the wrapped ExecutionStatistics
2671
2685
  if execution_stats_any and execution_stats_any.Is(ExecutionStatistics.DESCRIPTOR):
2672
2686
  execution_stats = ExecutionStatistics()
@@ -2684,17 +2698,21 @@ class Scheduler:
2684
2698
  def publish_execution_stats(
2685
2699
  self,
2686
2700
  job_name: str,
2701
+ instance_name: str,
2687
2702
  execution_metadata: ExecutedActionMetadata,
2688
2703
  property_label: str = "unknown",
2689
2704
  assigner_name: str | None = None,
2690
2705
  ) -> None:
2691
2706
  with self._sql_ro.session(expire_on_commit=False) as session:
2692
- self._publish_execution_stats(session, job_name, execution_metadata, property_label, assigner_name)
2707
+ self._publish_execution_stats(
2708
+ session, job_name, instance_name, execution_metadata, property_label, assigner_name
2709
+ )
2693
2710
 
2694
2711
  def _publish_execution_stats(
2695
2712
  self,
2696
2713
  session: Session,
2697
2714
  job_name: str,
2715
+ instance_name: str,
2698
2716
  execution_metadata: ExecutedActionMetadata,
2699
2717
  property_label: str,
2700
2718
  assigner_name: str | None,
@@ -2710,17 +2728,23 @@ class Scheduler:
2710
2728
  upload_start = execution_metadata.output_upload_start_timestamp
2711
2729
  upload_completed = execution_metadata.output_upload_completed_timestamp
2712
2730
 
2713
- self._publish_job_duration(queued, worker_completed, "Total", property_label, assigner_name)
2731
+ self._publish_job_duration(instance_name, queued, worker_completed, "Total", property_label, assigner_name)
2714
2732
  # The Queued time is missing here as it's posted as soon as worker has accepted the job.
2715
- self._publish_job_duration(worker_start, worker_completed, "Worker", property_label, assigner_name)
2716
- self._publish_job_duration(fetch_start, fetch_completed, "Fetch", property_label, assigner_name)
2717
- self._publish_job_duration(execution_start, execution_completed, "Execution", property_label, assigner_name)
2718
- self._publish_job_duration(upload_start, upload_completed, "Upload", property_label, assigner_name)
2733
+ self._publish_job_duration(
2734
+ instance_name, worker_start, worker_completed, "Worker", property_label, assigner_name
2735
+ )
2736
+ self._publish_job_duration(instance_name, fetch_start, fetch_completed, "Fetch", property_label, assigner_name)
2737
+ self._publish_job_duration(
2738
+ instance_name, execution_start, execution_completed, "Execution", property_label, assigner_name
2739
+ )
2740
+ self._publish_job_duration(
2741
+ instance_name, upload_start, upload_completed, "Upload", property_label, assigner_name
2742
+ )
2719
2743
 
2720
2744
  if self.metering_client is None or len(execution_metadata.auxiliary_metadata) == 0:
2721
2745
  return
2722
2746
 
2723
- execution_stats = self._fetch_execution_stats(execution_metadata.auxiliary_metadata)
2747
+ execution_stats = self._fetch_execution_stats(execution_metadata.auxiliary_metadata, instance_name)
2724
2748
  if execution_stats is None:
2725
2749
  return
2726
2750
  usage = Usage(
@@ -2790,7 +2814,8 @@ class Scheduler:
2790
2814
  try:
2791
2815
  # BuildGrid doesn't store action_result in CAS, but if we push it as an asset
2792
2816
  # we need it to be accessible
2793
- digest = self.storage.put_message(action_result)
2817
+ with instance_context(instance_name):
2818
+ digest = self.storage.put_message(action_result)
2794
2819
 
2795
2820
  uri = DIGEST_URI_TEMPLATE.format(digest_hash=digest.hash)
2796
2821
  qualifier = {"resource_type": PROTOBUF_MEDIA_TYPE}
@@ -13,4 +13,4 @@
13
13
  # limitations under the License.
14
14
 
15
15
 
16
- __version__ = "0.3.2"
16
+ __version__ = "0.3.4"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: buildgrid
3
- Version: 0.3.2
3
+ Version: 0.3.4
4
4
  Summary: A remote execution service
5
5
  License: Apache License, Version 2.0
6
6
  Project-URL: Homepage, https://buildgrid.build
@@ -208,7 +208,7 @@ buildgrid/server/servicer.py,sha256=oqU9MaSxxHTDmSxobFTo9YmJctaUCklE2Dj-vfYWKkc,
208
208
  buildgrid/server/settings.py,sha256=I1UK-g4_GwkX0nGC3hdGS3Cc0Rh1HTYDv2aHU2sq_eU,5604
209
209
  buildgrid/server/threading.py,sha256=4QKQYev2KoO2Q-S_OyaoR9qpWyDTVzGMWVe9o2a1yIU,4743
210
210
  buildgrid/server/types.py,sha256=xG3bx64pbWMuEwXLuI0o8c2unt2rU2C4zsmUfmMT12c,1323
211
- buildgrid/server/version.py,sha256=9hszMRmtGUkZbKKAfeEActwnrXaZkxNudCeHQb8v_8o,603
211
+ buildgrid/server/version.py,sha256=4k5OkV-7Atvya4h3lD2iv9J9jKDYco6vdVsLmuievhM,603
212
212
  buildgrid/server/actioncache/__init__.py,sha256=g9lb8Sn7NY5KOjkMr9GQoJovCVDEg_Fxz_EhdDbhP1I,579
213
213
  buildgrid/server/actioncache/instance.py,sha256=UCR7ZGkv4fJOXjeIILMAdTSFWcGgBSYlBg8fMaPJpaI,3139
214
214
  buildgrid/server/actioncache/service.py,sha256=WcikJAzFYOYX-tgiOfGGcOnPoubrCd4yP-EhKCHEW0c,2021
@@ -331,7 +331,7 @@ buildgrid/server/scheduler/__init__.py,sha256=arCg8LWFATeX1tj-s0keVYP8p3wwrrUlCV
331
331
  buildgrid/server/scheduler/assigner.py,sha256=wHPAhyiQxYABZJXaUc2g5yFzM78Z0U5nvGV3X9h5pCM,10512
332
332
  buildgrid/server/scheduler/cohorts.py,sha256=L_5YZRiVOwPPGStfqnnQXknO5Ja-SC0vq0xjw4XgP-I,1426
333
333
  buildgrid/server/scheduler/events.py,sha256=cM7Z7Htr2pYKhltJxfg1YRo0q524yZaGm8yXvRehivk,1453
334
- buildgrid/server/scheduler/impl.py,sha256=NsZwiSQcQAdWgqh-Y6G0BPhtwJgbEbBa8UnmllsyFWE,135759
334
+ buildgrid/server/scheduler/impl.py,sha256=BOeR89gJfZ1L9BPzaUoxCUmWqvJGBYauIbphMprrs3U,136516
335
335
  buildgrid/server/scheduler/notifier.py,sha256=22ZsKwyf2oQirAjrwROkvgvr4C_TMUNyhOmtro4uM4I,7121
336
336
  buildgrid/server/scheduler/properties.py,sha256=2GydX8KUy9MFv1_JznIkGfWE_wOS0m_XapSv6Gp4pCM,11260
337
337
  buildgrid/server/sql/__init__.py,sha256=zbeeRP9BEeDzR-Mx2Ip6SUr49J8eeXsuREgljJTrHkk,579
@@ -366,9 +366,9 @@ buildgrid/server/utils/async_lru_cache.py,sha256=iLKeRPoZtZb1wC5AtcyQm8Wt0Bx-KZm
366
366
  buildgrid/server/utils/bots.py,sha256=c8hn7tbCecru-m2wicRmtKU5v5rSZPGlk97Yc6eUHgQ,1729
367
367
  buildgrid/server/utils/cancellation.py,sha256=pNETzKNoXg0AsXOXKCcLWlFl7SVKdkKinlqWl7MesRA,1703
368
368
  buildgrid/server/utils/digests.py,sha256=YNrWeHdbNp7OVTcsInjs30C33z_t9GQ_noMd14bpqPQ,2424
369
- buildgrid-0.3.2.dist-info/licenses/LICENSE,sha256=swa3Vs7GgALaG9p-e05M-WLkhd_U9QknacNkyVZ85xA,11338
370
- buildgrid-0.3.2.dist-info/METADATA,sha256=ZbSgvpI9ItnWHDwTIWVew6XYP-4OnV42Y9NFBo9slhE,7086
371
- buildgrid-0.3.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
372
- buildgrid-0.3.2.dist-info/entry_points.txt,sha256=uyFAXiR9d6EDfSA5vWT8xskz6xalt4PdTuRruT6Q8rk,49
373
- buildgrid-0.3.2.dist-info/top_level.txt,sha256=T6TYhI_k6NTm2871tIxGCyBIqzlKxylgF9KDLU0Hi7o,10
374
- buildgrid-0.3.2.dist-info/RECORD,,
369
+ buildgrid-0.3.4.dist-info/licenses/LICENSE,sha256=swa3Vs7GgALaG9p-e05M-WLkhd_U9QknacNkyVZ85xA,11338
370
+ buildgrid-0.3.4.dist-info/METADATA,sha256=YkM4cIQyoDCPVLbBqsCh5DdB6shR2WJ1863d2XZUtwQ,7086
371
+ buildgrid-0.3.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
372
+ buildgrid-0.3.4.dist-info/entry_points.txt,sha256=uyFAXiR9d6EDfSA5vWT8xskz6xalt4PdTuRruT6Q8rk,49
373
+ buildgrid-0.3.4.dist-info/top_level.txt,sha256=T6TYhI_k6NTm2871tIxGCyBIqzlKxylgF9KDLU0Hi7o,10
374
+ buildgrid-0.3.4.dist-info/RECORD,,