nebu 0.1.37__py3-none-any.whl → 0.1.39__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/cache.py +3 -1
- nebu/processors/consumer.py +15 -12
- nebu/processors/decorate.py +33 -35
- {nebu-0.1.37.dist-info → nebu-0.1.39.dist-info}/METADATA +1 -1
- {nebu-0.1.37.dist-info → nebu-0.1.39.dist-info}/RECORD +8 -8
- {nebu-0.1.37.dist-info → nebu-0.1.39.dist-info}/WHEEL +0 -0
- {nebu-0.1.37.dist-info → nebu-0.1.39.dist-info}/licenses/LICENSE +0 -0
- {nebu-0.1.37.dist-info → nebu-0.1.39.dist-info}/top_level.txt +0 -0
nebu/cache.py
CHANGED
@@ -28,10 +28,11 @@ class Cache:
|
|
28
28
|
Also checks for REDIS_URL and prefers that if set.
|
29
29
|
"""
|
30
30
|
redis_url = os.environ.get("REDIS_URL")
|
31
|
+
print("REDIS_URL: ", redis_url)
|
31
32
|
namespace = os.environ.get("NEBU_NAMESPACE")
|
32
33
|
if not namespace:
|
33
34
|
raise ValueError("NEBU_NAMESPACE environment variable is not set")
|
34
|
-
|
35
|
+
print("NAMESPACE: ", namespace)
|
35
36
|
self.redis_client = None
|
36
37
|
connection_info = ""
|
37
38
|
|
@@ -57,6 +58,7 @@ class Cache:
|
|
57
58
|
print(f"Successfully connected to Redis using {connection_info}")
|
58
59
|
|
59
60
|
self.prefix = f"cache:{namespace}"
|
61
|
+
print("using prefix", self.prefix)
|
60
62
|
except Exception as e:
|
61
63
|
print(f"Error connecting to Redis: {e}")
|
62
64
|
# Ensure client is None if connection fails at any point
|
nebu/processors/consumer.py
CHANGED
@@ -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
|
32
|
-
|
33
|
-
|
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,22 @@ try:
|
|
215
215
|
traceback.print_exc()
|
216
216
|
sys.exit(1)
|
217
217
|
|
218
|
-
# Execute
|
219
|
-
if
|
220
|
-
print(f"Executing
|
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(
|
223
|
-
|
224
|
-
|
225
|
-
|
222
|
+
exec(init_func_source, local_namespace)
|
223
|
+
init_function = local_namespace[init_func_name]
|
224
|
+
print(
|
225
|
+
f"[Consumer] Environment before calling init_func {init_func_name}: {os.environ}"
|
226
|
+
)
|
227
|
+
init_function() # Call the function
|
228
|
+
print(f"Successfully executed init_func: {init_func_name}")
|
226
229
|
except Exception as e:
|
227
|
-
print(f"Error executing
|
230
|
+
print(f"Error executing init_func '{init_func_name}': {e}")
|
228
231
|
traceback.print_exc()
|
229
232
|
# Decide if failure is critical. For now, let's exit.
|
230
|
-
print("Exiting due to
|
233
|
+
print("Exiting due to init_func failure.")
|
231
234
|
sys.exit(1)
|
232
235
|
|
233
236
|
except Exception as e:
|
nebu/processors/decorate.py
CHANGED
@@ -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
|
-
|
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
|
-
|
640
|
-
|
641
|
-
if
|
642
|
-
print(f"[DEBUG Decorator] Processing
|
643
|
-
|
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(
|
645
|
+
before_sig = inspect.signature(init_func)
|
646
646
|
if len(before_sig.parameters) != 0:
|
647
647
|
raise TypeError(
|
648
|
-
f"
|
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
|
-
|
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
|
657
|
+
f"[DEBUG Decorator] Using explicit source (@include) for init_func {init_func_name}"
|
658
658
|
)
|
659
|
-
|
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
|
662
|
+
f"[DEBUG Decorator] Attempting notebook history extraction for init_func '{init_func_name}'..."
|
663
663
|
)
|
664
|
-
|
665
|
-
notebook_code,
|
664
|
+
init_func_source = extract_definition_source_from_string(
|
665
|
+
notebook_code, init_func_name, ast.FunctionDef
|
666
666
|
)
|
667
|
-
if
|
667
|
+
if init_func_source:
|
668
668
|
print(
|
669
|
-
f"[DEBUG Decorator] Found
|
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
|
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
|
676
|
+
if init_func_source is None:
|
677
677
|
print(
|
678
|
-
f"[DEBUG Decorator] Using dill fallback for
|
678
|
+
f"[DEBUG Decorator] Using dill fallback for init_func '{init_func_name}'..."
|
679
679
|
)
|
680
680
|
try:
|
681
|
-
|
682
|
-
|
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 '{
|
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 '{
|
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
|
692
|
+
f"Could not retrieve source for init_func '{init_func_name}': {e}"
|
693
693
|
) from e
|
694
694
|
|
695
|
-
if
|
695
|
+
if init_func_source is None: # Final check
|
696
696
|
raise ValueError(
|
697
|
-
f"Failed to obtain source code for
|
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
|
700
|
+
f"[DEBUG Decorator] Final init_func source obtained for '{init_func_name}'."
|
701
701
|
)
|
702
702
|
else:
|
703
|
-
print("[DEBUG Decorator] No
|
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
|
819
|
-
if
|
820
|
-
print(
|
821
|
-
|
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,7 +1,7 @@
|
|
1
1
|
nebu/__init__.py,sha256=5sepbzdAdoA_8TIxws60S4ugFY1apQd_savzn20a4cY,465
|
2
2
|
nebu/adapter.py,sha256=X9Lc0-pm4U6v7UDgOd_RuxJqENqAO8Si4jrwGYTsMGI,418
|
3
3
|
nebu/auth.py,sha256=N_v6SPFD9HU_UoRDTaouH03g2Hmo9C-xxqInE1FweXE,1471
|
4
|
-
nebu/cache.py,sha256=
|
4
|
+
nebu/cache.py,sha256=nKssfJ4mqkxkzoU776cr7RjOSbKoueqNvmHvQ0Ufj70,3929
|
5
5
|
nebu/config.py,sha256=aZzQltkobtOLHFCGcIkpKoE3ITn3Z11Dp0E72w84TA0,5769
|
6
6
|
nebu/data.py,sha256=kIH9-JJ1-iO7P2t28bku6Gn0Y5tgQszGeTW_rpmO03A,38725
|
7
7
|
nebu/meta.py,sha256=CzFHMND9seuewzq9zNNx9WTr6JvrCBExe7BLqDSr7lM,745
|
@@ -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=
|
15
|
-
nebu/processors/decorate.py,sha256=
|
14
|
+
nebu/processors/consumer.py,sha256=vVbA6PdgkTKI5iqCDSnHO0dtbyFPiK7_1ys3ph7xPrk,20786
|
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.
|
23
|
-
nebu-0.1.
|
24
|
-
nebu-0.1.
|
25
|
-
nebu-0.1.
|
26
|
-
nebu-0.1.
|
22
|
+
nebu-0.1.39.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
23
|
+
nebu-0.1.39.dist-info/METADATA,sha256=aAJh9bd6ya9FoUBkqpxnAsk6T6Vwtwtz6g5hhMl28PY,1786
|
24
|
+
nebu-0.1.39.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
25
|
+
nebu-0.1.39.dist-info/top_level.txt,sha256=uLIbEKJeGSHWOAJN5S0i5XBGwybALlF9bYoB1UhdEgQ,5
|
26
|
+
nebu-0.1.39.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|