nebu 0.1.37__py3-none-any.whl → 0.1.38__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.
@@ -28,9 +28,9 @@ try:
28
28
  return_type_name = os.environ.get("RETURN_TYPE_NAME")
29
29
  content_type_name = os.environ.get("CONTENT_TYPE_NAME")
30
30
 
31
- # Get before_func source if provided
32
- before_func_source = os.environ.get("BEFORE_FUNC_SOURCE")
33
- before_func_name = os.environ.get("BEFORE_FUNC_NAME")
31
+ # Get init_func source if provided
32
+ init_func_source = os.environ.get("INIT_FUNC_SOURCE")
33
+ init_func_name = os.environ.get("INIT_FUNC_NAME")
34
34
 
35
35
  # Check for generic type arguments
36
36
  input_model_args = []
@@ -215,19 +215,19 @@ try:
215
215
  traceback.print_exc()
216
216
  sys.exit(1)
217
217
 
218
- # Execute before_func if provided
219
- if before_func_source and before_func_name:
220
- print(f"Executing before_func: {before_func_name}...")
218
+ # Execute init_func if provided
219
+ if init_func_source and init_func_name:
220
+ print(f"Executing init_func: {init_func_name}...")
221
221
  try:
222
- exec(before_func_source, local_namespace)
223
- before_function = local_namespace[before_func_name]
224
- before_function() # Call the function
225
- print(f"Successfully executed before_func: {before_func_name}")
222
+ exec(init_func_source, local_namespace)
223
+ init_function = local_namespace[init_func_name]
224
+ init_function() # Call the function
225
+ print(f"Successfully executed init_func: {init_func_name}")
226
226
  except Exception as e:
227
- print(f"Error executing before_func '{before_func_name}': {e}")
227
+ print(f"Error executing init_func '{init_func_name}': {e}")
228
228
  traceback.print_exc()
229
229
  # Decide if failure is critical. For now, let's exit.
230
- print("Exiting due to before_func failure.")
230
+ print("Exiting due to init_func failure.")
231
231
  sys.exit(1)
232
232
 
233
233
  except Exception as e:
@@ -352,7 +352,7 @@ def processor(
352
352
  python_cmd: str = "python",
353
353
  no_delete: bool = False,
354
354
  include: Optional[List[Any]] = None,
355
- before_func: Optional[Callable[[], None]] = None,
355
+ init_func: Optional[Callable[[], None]] = None,
356
356
  ):
357
357
  def decorator(
358
358
  func: Callable[[Any], Any],
@@ -636,71 +636,71 @@ def processor(
636
636
  # --- End Function Source ---
637
637
 
638
638
  # --- Get Before Function Source (if provided) ---
639
- before_func_source = None
640
- before_func_name = None
641
- if before_func:
642
- print(f"[DEBUG Decorator] Processing before_func: {before_func.__name__}")
643
- before_func_name = before_func.__name__
639
+ init_func_source = None
640
+ init_func_name = None
641
+ if init_func:
642
+ print(f"[DEBUG Decorator] Processing init_func: {init_func.__name__}")
643
+ init_func_name = init_func.__name__
644
644
  # Validate signature (must take no arguments)
645
- before_sig = inspect.signature(before_func)
645
+ before_sig = inspect.signature(init_func)
646
646
  if len(before_sig.parameters) != 0:
647
647
  raise TypeError(
648
- f"before_func '{before_func_name}' must take zero parameters"
648
+ f"init_func '{init_func_name}' must take zero parameters"
649
649
  )
650
650
 
651
651
  # Try to get source using similar logic as the main function
652
652
  before_explicit_source = getattr(
653
- before_func, _NEBU_EXPLICIT_SOURCE_ATTR, None
653
+ init_func, _NEBU_EXPLICIT_SOURCE_ATTR, None
654
654
  )
655
655
  if before_explicit_source:
656
656
  print(
657
- f"[DEBUG Decorator] Using explicit source (@include) for before_func {before_func_name}"
657
+ f"[DEBUG Decorator] Using explicit source (@include) for init_func {init_func_name}"
658
658
  )
659
- before_func_source = before_explicit_source
659
+ init_func_source = before_explicit_source
660
660
  elif in_jupyter and notebook_code:
661
661
  print(
662
- f"[DEBUG Decorator] Attempting notebook history extraction for before_func '{before_func_name}'..."
662
+ f"[DEBUG Decorator] Attempting notebook history extraction for init_func '{init_func_name}'..."
663
663
  )
664
- before_func_source = extract_definition_source_from_string(
665
- notebook_code, before_func_name, ast.FunctionDef
664
+ init_func_source = extract_definition_source_from_string(
665
+ notebook_code, init_func_name, ast.FunctionDef
666
666
  )
667
- if before_func_source:
667
+ if init_func_source:
668
668
  print(
669
- f"[DEBUG Decorator] Found before_func '{before_func_name}' source in notebook history."
669
+ f"[DEBUG Decorator] Found init_func '{init_func_name}' source in notebook history."
670
670
  )
671
671
  else:
672
672
  print(
673
- f"[DEBUG Decorator] Failed to find before_func '{before_func_name}' in notebook history, falling back to dill."
673
+ f"[DEBUG Decorator] Failed to find init_func '{init_func_name}' in notebook history, falling back to dill."
674
674
  )
675
675
 
676
- if before_func_source is None:
676
+ if init_func_source is None:
677
677
  print(
678
- f"[DEBUG Decorator] Using dill fallback for before_func '{before_func_name}'..."
678
+ f"[DEBUG Decorator] Using dill fallback for init_func '{init_func_name}'..."
679
679
  )
680
680
  try:
681
- raw_before_func_source = dill.source.getsource(before_func)
682
- before_func_source = textwrap.dedent(raw_before_func_source)
681
+ raw_init_func_source = dill.source.getsource(init_func)
682
+ init_func_source = textwrap.dedent(raw_init_func_source)
683
683
  print(
684
- f"[DEBUG Decorator] Successfully got source via dill for '{before_func_name}'."
684
+ f"[DEBUG Decorator] Successfully got source via dill for '{init_func_name}'."
685
685
  )
686
686
  except (IOError, TypeError, OSError) as e:
687
687
  print(
688
- f"[DEBUG Decorator] Dill fallback failed for '{before_func_name}': {e}"
688
+ f"[DEBUG Decorator] Dill fallback failed for '{init_func_name}': {e}"
689
689
  )
690
690
  # Raise error if we couldn't get the source by any means
691
691
  raise ValueError(
692
- f"Could not retrieve source for before_func '{before_func_name}': {e}"
692
+ f"Could not retrieve source for init_func '{init_func_name}': {e}"
693
693
  ) from e
694
694
 
695
- if before_func_source is None: # Final check
695
+ if init_func_source is None: # Final check
696
696
  raise ValueError(
697
- f"Failed to obtain source code for before_func '{before_func_name}' using any method."
697
+ f"Failed to obtain source code for init_func '{init_func_name}' using any method."
698
698
  )
699
699
  print(
700
- f"[DEBUG Decorator] Final before_func source obtained for '{before_func_name}'."
700
+ f"[DEBUG Decorator] Final init_func source obtained for '{init_func_name}'."
701
701
  )
702
702
  else:
703
- print("[DEBUG Decorator] No before_func provided.")
703
+ print("[DEBUG Decorator] No init_func provided.")
704
704
  # --- End Before Function Source ---
705
705
 
706
706
  # --- Get Model Sources ---
@@ -815,13 +815,11 @@ def processor(
815
815
  add_source_to_env("CONTENT_TYPE", content_type_source)
816
816
  add_source_to_env("STREAM_MESSAGE", stream_message_source)
817
817
 
818
- # Add before_func source if available
819
- if before_func_source and before_func_name:
820
- print(
821
- f"[DEBUG Decorator] Adding BEFORE_FUNC env vars for {before_func_name}"
822
- )
823
- all_env.append(V1EnvVar(key="BEFORE_FUNC_SOURCE", value=before_func_source))
824
- all_env.append(V1EnvVar(key="BEFORE_FUNC_NAME", value=before_func_name))
818
+ # Add init_func source if available
819
+ if init_func_source and init_func_name:
820
+ print(f"[DEBUG Decorator] Adding INIT_FUNC env vars for {init_func_name}")
821
+ all_env.append(V1EnvVar(key="INIT_FUNC_SOURCE", value=init_func_source))
822
+ all_env.append(V1EnvVar(key="INIT_FUNC_NAME", value=init_func_name))
825
823
 
826
824
  print("[DEBUG Decorator] Adding type info env vars...")
827
825
  all_env.append(V1EnvVar(key="PARAM_TYPE_STR", value=param_type_str_repr))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nebu
3
- Version: 0.1.37
3
+ Version: 0.1.38
4
4
  Summary: A globally distributed container runtime
5
5
  Requires-Python: >=3.10.14
6
6
  Description-Content-Type: text/markdown
@@ -11,16 +11,16 @@ nebu/containers/container.py,sha256=yb7KaPTVXnEEAlrpdlUi4HNqF6P7z9bmwAILGlq6iqU,
11
11
  nebu/containers/decorator.py,sha256=uFtzlAXRHYZECJ-NPusY7oN9GXvdHrHDd_JNrIGr8aQ,3244
12
12
  nebu/containers/models.py,sha256=0j6NGy4yto-enRDh_4JH_ZTbHrLdSpuMOqNQPnIrwC4,6815
13
13
  nebu/containers/server.py,sha256=yFa2Y9PzBn59E1HftKiv0iapPonli2rbGAiU6r-wwe0,2513
14
- nebu/processors/consumer.py,sha256=GxU-IM-U7B9Tq6eTwW2lBVe7jm-JfK0ux4ZR2HN3sfU,20693
15
- nebu/processors/decorate.py,sha256=Jn7rJfhJFDlbFGxLDNJzL_GOthX_MWDl1rtktl1kYFM,38286
14
+ nebu/processors/consumer.py,sha256=cRYf8j7nwjQTzUT6Rtrsvso7SqzItkV9F104OqGAsPQ,20655
15
+ nebu/processors/decorate.py,sha256=KZ43vOPzl3HVPB9P3QX6U94yTBnVi7ISoXQhUuEMO7g,38156
16
16
  nebu/processors/default.py,sha256=W4slJenG59rvyTlJ7gRp58eFfXcNOTT2Hfi6zzJAobI,365
17
17
  nebu/processors/models.py,sha256=y40HoW-MEzDWB2dm_tsYlUy3Nf3s6eiLC0iGO9BoNog,3956
18
18
  nebu/processors/processor.py,sha256=068hLQKapWabNlhb_DtzqAJ7N7MGdr5UcjfZrb_MkFo,9732
19
19
  nebu/processors/remote.py,sha256=TeAIPGEMqnDIb7H1iett26IEZrBlcbPB_-DSm6jcH1E,1285
20
20
  nebu/redis/models.py,sha256=coPovAcVXnOU1Xh_fpJL4PO3QctgK9nBe5QYoqEcnxg,1230
21
21
  nebu/services/service.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
- nebu-0.1.37.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
23
- nebu-0.1.37.dist-info/METADATA,sha256=gcjQbyKOX5ZvQuZ1QnJEtSEugrQIXiUuDjH4e4PJKPI,1786
24
- nebu-0.1.37.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
25
- nebu-0.1.37.dist-info/top_level.txt,sha256=uLIbEKJeGSHWOAJN5S0i5XBGwybALlF9bYoB1UhdEgQ,5
26
- nebu-0.1.37.dist-info/RECORD,,
22
+ nebu-0.1.38.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
23
+ nebu-0.1.38.dist-info/METADATA,sha256=8UJuoJ3UEfjvP9pmdyP_BmYRP-zHPNnei3tr3eUkPlE,1786
24
+ nebu-0.1.38.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
25
+ nebu-0.1.38.dist-info/top_level.txt,sha256=uLIbEKJeGSHWOAJN5S0i5XBGwybALlF9bYoB1UhdEgQ,5
26
+ nebu-0.1.38.dist-info/RECORD,,
File without changes