nebu 0.1.77__py3-none-any.whl → 0.1.79__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.
nebu/errors.py ADDED
@@ -0,0 +1,5 @@
1
+ # Add this near the top with other imports/definitions
2
+ class RetriableError(Exception):
3
+ """Custom exception for failures during Training resource setup."""
4
+
5
+ pass
@@ -16,6 +16,8 @@ import redis
16
16
  import socks
17
17
  from redis import ConnectionError, ResponseError
18
18
 
19
+ from nebu.errors import RetriableError
20
+
19
21
  # Define TypeVar for generic models
20
22
  T = TypeVar("T")
21
23
 
@@ -433,6 +435,13 @@ def process_message(message_id: str, message_data: Dict[str, str]) -> None:
433
435
  f"Subprocess for {message_id} completed successfully (return code 0)."
434
436
  )
435
437
  # Assume success handling (ack/response) was done by the worker
438
+ elif return_code == 3:
439
+ print(
440
+ f"Subprocess for {message_id} reported a retriable error (exit code 3). Message will not be acknowledged."
441
+ )
442
+ # Optionally send an error response here, though the worker already did.
443
+ # _send_error_response(...)
444
+ # DO NOT Acknowledge the message here, let it be retried.
436
445
  else:
437
446
  print(
438
447
  f"Subprocess for {message_id} failed with exit code {return_code}."
@@ -550,6 +559,16 @@ def process_message(message_id: str, message_data: Dict[str, str]) -> None:
550
559
  None,
551
560
  None,
552
561
  ) # Pass None for user_id if unavailable here
562
+ # Acknowledge message with code load failure to prevent reprocessing loop
563
+ try:
564
+ assert isinstance(REDIS_STREAM, str)
565
+ assert isinstance(REDIS_CONSUMER_GROUP, str)
566
+ r.xack(REDIS_STREAM, REDIS_CONSUMER_GROUP, message_id)
567
+ print(f"Acknowledged message {message_id} due to code load failure.")
568
+ except Exception as e_ack:
569
+ print(
570
+ f"CRITICAL: Failed to acknowledge message {message_id} after code load failure: {e_ack}"
571
+ )
553
572
  return # Skip processing
554
573
 
555
574
  return_stream = None
@@ -797,6 +816,15 @@ def process_message(message_id: str, message_data: Dict[str, str]) -> None:
797
816
  assert isinstance(REDIS_CONSUMER_GROUP, str)
798
817
  r.xack(REDIS_STREAM, REDIS_CONSUMER_GROUP, message_id)
799
818
 
819
+ except RetriableError as e:
820
+ print(f"Retriable error processing message {message_id}: {e}")
821
+ traceback.print_exc()
822
+ _send_error_response(
823
+ message_id, str(e), traceback.format_exc(), return_stream, user_id
824
+ )
825
+ # DO NOT Acknowledge the message for retriable errors
826
+ print(f"Message {message_id} will be retried later.")
827
+
800
828
  except Exception as e:
801
829
  print(f"Error processing message {message_id}: {e}")
802
830
  traceback.print_exc()
@@ -14,6 +14,8 @@ from typing import Any, Callable, Dict, List, Optional, Tuple, TypeVar, cast
14
14
  import redis
15
15
  import socks
16
16
 
17
+ from nebu.errors import RetriableError
18
+
17
19
  # from redis import ConnectionError, ResponseError # Removed unused imports
18
20
 
19
21
  # Define TypeVar for generic models
@@ -640,8 +642,24 @@ if __name__ == "__main__":
640
642
  print("[Worker] Exiting with status 0.")
641
643
  sys.exit(0)
642
644
 
645
+ except RetriableError as e:
646
+ # --- Handle Retriable Processing Error ---
647
+ print(f"[Worker] Retriable error processing message {message_id}: {e}")
648
+ tb = traceback.format_exc()
649
+ print(tb)
650
+ # Assert message_id is str before sending error
651
+ assert isinstance(message_id, str)
652
+ # Send error response (optional, consider suppressing later if too noisy)
653
+ _send_error_response(message_id, str(e), tb, return_stream, user_id)
654
+
655
+ # DO NOT Acknowledge the message for retriable errors
656
+
657
+ # --- 9. Exit with specific code for retriable failure ---
658
+ print("[Worker] Exiting with status 3 due to retriable error.")
659
+ sys.exit(3)
660
+
643
661
  except Exception as e:
644
- # --- Handle Processing Error ---
662
+ # --- Handle Non-Retriable Processing Error ---
645
663
  print(f"[Worker] Error processing message {message_id}: {e}")
646
664
  tb = traceback.format_exc()
647
665
  print(tb)
@@ -390,7 +390,8 @@ def processor(
390
390
  ports: Optional[List[V1PortRequest]] = None,
391
391
  proxy_port: Optional[int] = None,
392
392
  health_check: Optional[V1ContainerHealthCheck] = None,
393
- execution_mode: str = "inline", # Added parameter
393
+ execution_mode: str = "inline",
394
+ config: Optional[GlobalConfig] = None,
394
395
  ):
395
396
  def decorator(
396
397
  func: Callable[[Any], Any],
@@ -410,6 +411,9 @@ def processor(
410
411
  processor_name = func.__name__
411
412
  all_volumes = volumes or [] # Initialize volumes list
412
413
 
414
+ # Use a local variable for config resolution
415
+ effective_config = config
416
+
413
417
  # --- Get Decorated Function File Path and Directory ---
414
418
  print("[DEBUG Decorator] Getting source file path for decorated function...")
415
419
  func_file_path: Optional[str] = None
@@ -445,9 +449,9 @@ def processor(
445
449
  # --- Get API Key ---
446
450
  print("[DEBUG Decorator] Loading Nebu configuration...")
447
451
  try:
448
- pass
449
- config = GlobalConfig.read()
450
- current_server = config.get_current_server_config()
452
+ if not effective_config:
453
+ effective_config = GlobalConfig.read()
454
+ current_server = effective_config.get_current_server_config()
451
455
  if not current_server or not current_server.api_key:
452
456
  raise ValueError("Nebu server configuration or API key not found.")
453
457
  api_key = current_server.api_key
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nebu
3
- Version: 0.1.77
3
+ Version: 0.1.79
4
4
  Summary: A globally distributed container runtime
5
5
  Requires-Python: >=3.10.14
6
6
  Description-Content-Type: text/markdown
@@ -3,6 +3,7 @@ nebu/auth.py,sha256=N_v6SPFD9HU_UoRDTaouH03g2Hmo9C-xxqInE1FweXE,1471
3
3
  nebu/cache.py,sha256=jmluqvWnE9N8uNq6nppXSxEJK7DKWaB79GicaGg9KmY,4718
4
4
  nebu/config.py,sha256=C5Jt9Bd0i0HrgzBSVNJ-Ml3KwX_gaYbYYZEtNL2gvJg,7031
5
5
  nebu/data.py,sha256=X0aAJYuHNVcTCRHpIDDm546HwMqIZpv40lGrozlL41A,39797
6
+ nebu/errors.py,sha256=bBnK5YQ6qZg4OMY81AN2k03ppefg89FUwF_SHEMlqCA,170
6
7
  nebu/meta.py,sha256=CzFHMND9seuewzq9zNNx9WTr6JvrCBExe7BLqDSr7lM,745
7
8
  nebu/orign.py,sha256=SkVfHgpadwik58KCZCrjdV5EHY0dhpEhDvijzLxY11Y,2052
8
9
  nebu/builders/builder.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -13,17 +14,17 @@ nebu/containers/models.py,sha256=0j6NGy4yto-enRDh_4JH_ZTbHrLdSpuMOqNQPnIrwC4,681
13
14
  nebu/containers/server.py,sha256=yFa2Y9PzBn59E1HftKiv0iapPonli2rbGAiU6r-wwe0,2513
14
15
  nebu/namespaces/models.py,sha256=EqUOpzhVBhvJw2P92ONDUbIgC31M9jMmcaG5vyOrsWg,497
15
16
  nebu/namespaces/namespace.py,sha256=Q_EDH7BgQrTkaDh_l4tbo22qpq-uARfIk8ZPBLjITGY,4967
16
- nebu/processors/consumer.py,sha256=N1olarPEHHqisxuM6gkar_LHG9CUbGhGvrIz-tmsPT4,42267
17
- nebu/processors/consumer_process_worker.py,sha256=l5_BSMfqy-n2yK_UC3sm_pimzelaASeMdPxRE97HFwc,30959
18
- nebu/processors/decorate.py,sha256=mu1o05BjNcbJ4M1so4Xvt7UbslX--B4dsYLgs5h8bEg,54610
17
+ nebu/processors/consumer.py,sha256=nWJmlTwJxfadMEQQwzwOJNPCAkcxqIzOpshMMbnfa-o,43617
18
+ nebu/processors/consumer_process_worker.py,sha256=tF5KU3Rnmzfc3Y0cM8J5nwGg1cJMe-ry0FmMSgGvXrY,31765
19
+ nebu/processors/decorate.py,sha256=U-NjFszyfKD6ACEyPJogFCbOPsfRYJUgGobLzfaHwD8,54766
19
20
  nebu/processors/default.py,sha256=W4slJenG59rvyTlJ7gRp58eFfXcNOTT2Hfi6zzJAobI,365
20
21
  nebu/processors/models.py,sha256=y40HoW-MEzDWB2dm_tsYlUy3Nf3s6eiLC0iGO9BoNog,3956
21
22
  nebu/processors/processor.py,sha256=OgEK8Fz0ehSe_VFiNsxweVKZIckhgVvQQ11NNffYZqA,15848
22
23
  nebu/processors/remote.py,sha256=TeAIPGEMqnDIb7H1iett26IEZrBlcbPB_-DSm6jcH1E,1285
23
24
  nebu/redis/models.py,sha256=coPovAcVXnOU1Xh_fpJL4PO3QctgK9nBe5QYoqEcnxg,1230
24
25
  nebu/services/service.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
- nebu-0.1.77.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
26
- nebu-0.1.77.dist-info/METADATA,sha256=6zdRYrPRNGO6NnN30EV26EVc5drWDvJKJbAhirgj2sQ,1731
27
- nebu-0.1.77.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
28
- nebu-0.1.77.dist-info/top_level.txt,sha256=uLIbEKJeGSHWOAJN5S0i5XBGwybALlF9bYoB1UhdEgQ,5
29
- nebu-0.1.77.dist-info/RECORD,,
26
+ nebu-0.1.79.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
27
+ nebu-0.1.79.dist-info/METADATA,sha256=CGL9pnRUrW4gx4A6tIaOgxgC3WRlxUSANUHJcBuhLPc,1731
28
+ nebu-0.1.79.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
29
+ nebu-0.1.79.dist-info/top_level.txt,sha256=uLIbEKJeGSHWOAJN5S0i5XBGwybALlF9bYoB1UhdEgQ,5
30
+ nebu-0.1.79.dist-info/RECORD,,
File without changes