nebu 0.1.22__py3-none-any.whl → 0.1.24__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.
@@ -138,9 +138,9 @@ try:
138
138
  if stream_message_source:
139
139
  try:
140
140
  exec(stream_message_source, local_namespace)
141
- print("Successfully defined V1StreamMessage class")
141
+ print("Successfully defined Message class")
142
142
  except Exception as e:
143
- print(f"Error defining V1StreamMessage: {e}")
143
+ print(f"Error defining Message: {e}")
144
144
  traceback.print_exc()
145
145
 
146
146
  # Define content type if available
@@ -340,14 +340,14 @@ def process_message(message_id: str, message_data: Dict[str, str]) -> None:
340
340
  print(f"Content: {content}")
341
341
 
342
342
  # For StreamMessage, construct the proper input object
343
- if is_stream_message and "V1StreamMessage" in local_namespace:
343
+ if is_stream_message and "Message" in local_namespace:
344
344
  # If we have a content type, try to construct it
345
345
  if content_type_name and content_type_name in local_namespace:
346
346
  # Try to create the content type model first
347
347
  try:
348
348
  content_model = local_namespace[content_type_name](**content)
349
349
  print(f"Content model: {content_model}")
350
- input_obj = local_namespace["V1StreamMessage"](
350
+ input_obj = local_namespace["Message"](
351
351
  kind=kind,
352
352
  id=msg_id,
353
353
  content=content_model,
@@ -361,7 +361,7 @@ def process_message(message_id: str, message_data: Dict[str, str]) -> None:
361
361
  except Exception as e:
362
362
  print(f"Error creating content type model: {e}")
363
363
  # Fallback to using raw content
364
- input_obj = local_namespace["V1StreamMessage"](
364
+ input_obj = local_namespace["Message"](
365
365
  kind=kind,
366
366
  id=msg_id,
367
367
  content=content,
@@ -375,7 +375,7 @@ def process_message(message_id: str, message_data: Dict[str, str]) -> None:
375
375
  else:
376
376
  # Just use the raw content
377
377
  print(f"Using raw content")
378
- input_obj = local_namespace["V1StreamMessage"](
378
+ input_obj = local_namespace["Message"](
379
379
  kind=kind,
380
380
  id=msg_id,
381
381
  content=content,
@@ -390,13 +390,14 @@ def process_message(message_id: str, message_data: Dict[str, str]) -> None:
390
390
  # Otherwise use the param type directly
391
391
  try:
392
392
  if param_type_name in local_namespace:
393
- input_obj = local_namespace[param_type_name](**content)
393
+ print(f"Validating content against {param_type_name}")
394
+ input_obj = local_namespace[param_type_name].model_validate(content)
394
395
  else:
395
396
  # If we can't find the exact type, just pass the content directly
396
397
  input_obj = content
397
398
  except Exception as e:
398
399
  print(f"Error creating input model: {e}, using raw content")
399
- input_obj = content
400
+ raise e
400
401
 
401
402
  print(f"Input object: {input_obj}")
402
403
 
@@ -27,8 +27,8 @@ from nebu.containers.models import (
27
27
  )
28
28
  from nebu.meta import V1ResourceMetaRequest
29
29
  from nebu.processors.models import (
30
+ Message,
30
31
  V1Scale,
31
- V1StreamMessage,
32
32
  )
33
33
  from nebu.processors.processor import Processor
34
34
 
@@ -455,14 +455,12 @@ def processor(
455
455
  content_type = None
456
456
 
457
457
  # Check 1: Standard introspection
458
- if origin is V1StreamMessage or (
458
+ if origin is Message or (
459
459
  origin is not None
460
- and origin.__name__ == V1StreamMessage.__name__
461
- and origin.__module__ == V1StreamMessage.__module__
460
+ and origin.__name__ == Message.__name__
461
+ and origin.__module__ == Message.__module__
462
462
  ):
463
- print(
464
- "[DEBUG Decorator] Input type identified as V1StreamMessage via get_origin."
465
- )
463
+ print("[DEBUG Decorator] Input type identified as Message via get_origin.")
466
464
  is_stream_message = True
467
465
  if args:
468
466
  content_type = args[0]
@@ -471,13 +469,11 @@ def processor(
471
469
  )
472
470
  else:
473
471
  print(
474
- "[DEBUG Decorator] V1StreamMessage detected, but no generic arguments found via get_args."
472
+ "[DEBUG Decorator] Message detected, but no generic arguments found via get_args."
475
473
  )
476
474
  # Check 2: Direct type check
477
- elif isinstance(param_type, type) and param_type is V1StreamMessage:
478
- print(
479
- "[DEBUG Decorator] Input type identified as direct V1StreamMessage type."
480
- )
475
+ elif isinstance(param_type, type) and param_type is Message:
476
+ print("[DEBUG Decorator] Input type identified as direct Message type.")
481
477
  is_stream_message = True
482
478
  # Check 3: Regex fallback on string representation
483
479
  elif origin is None:
@@ -486,13 +482,11 @@ def processor(
486
482
  )
487
483
  # Use param_type_str_repr in match calls
488
484
  generic_match = re.match(
489
- r"^<class '(?:[a-zA-Z0-9_.]+\.)?V1StreamMessage\[(.+?)\]'>$",
485
+ r"^<class '(?:[a-zA-Z0-9_.]+\.)?Message\[(.+?)\]'>$",
490
486
  param_type_str_repr,
491
487
  )
492
488
  if generic_match:
493
- print(
494
- "[DEBUG Decorator] Regex matched generic V1StreamMessage pattern!"
495
- )
489
+ print("[DEBUG Decorator] Regex matched generic Message pattern!")
496
490
  is_stream_message = True
497
491
  content_type_name_str = generic_match.group(1).strip()
498
492
  print(
@@ -517,21 +511,21 @@ def processor(
517
511
  else:
518
512
  # Use param_type_str_repr in match calls
519
513
  simple_match = re.match(
520
- r"^<class '(?:[a-zA-Z0-9_.]+\.)?V1StreamMessage'>$",
514
+ r"^<class '(?:[a-zA-Z0-9_.]+\.)?Message'>$",
521
515
  param_type_str_repr,
522
516
  )
523
517
  if simple_match:
524
518
  print(
525
- "[DEBUG Decorator] Regex identified direct V1StreamMessage (no generic) from string."
519
+ "[DEBUG Decorator] Regex identified direct Message (no generic) from string."
526
520
  )
527
521
  is_stream_message = True
528
522
  else:
529
523
  print(
530
- f"[DEBUG Decorator] Regex did not match V1StreamMessage pattern for string '{param_type_str_repr}'. Assuming not StreamMessage."
524
+ f"[DEBUG Decorator] Regex did not match Message pattern for string '{param_type_str_repr}'. Assuming not StreamMessage."
531
525
  )
532
526
  else:
533
527
  print(
534
- f"[DEBUG Decorator] Input parameter '{param_name}' type ({param_type_str_repr}) identified as non-StreamMessage type (origin was not None and not V1StreamMessage)."
528
+ f"[DEBUG Decorator] Input parameter '{param_name}' type ({param_type_str_repr}) identified as non-StreamMessage type (origin was not None and not Message)."
535
529
  )
536
530
 
537
531
  print(
@@ -645,8 +639,8 @@ def processor(
645
639
  input_model_source = None
646
640
  output_model_source = None
647
641
  content_type_source = None
648
- print("[DEBUG Decorator] Getting base V1StreamMessage source...")
649
- stream_message_source = get_type_source(V1StreamMessage, notebook_code)
642
+ print("[DEBUG Decorator] Getting base Message source...")
643
+ stream_message_source = get_type_source(Message, notebook_code)
650
644
 
651
645
  if is_stream_message:
652
646
  print(
nebu/processors/models.py CHANGED
@@ -94,6 +94,18 @@ class V1StreamData(BaseModel):
94
94
  wait: Optional[bool] = None
95
95
 
96
96
 
97
+ class Message(BaseModel, Generic[T]):
98
+ kind: str = "Message"
99
+ id: str
100
+ content: Optional[T] = None
101
+ created_at: int
102
+ return_stream: Optional[str] = None
103
+ user_id: Optional[str] = None
104
+ orgs: Optional[Any] = None
105
+ handle: Optional[str] = None
106
+ adapter: Optional[str] = None
107
+
108
+
97
109
  class V1StreamMessage(BaseModel, Generic[T]):
98
110
  kind: str = "StreamMessage"
99
111
  id: str
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nebu
3
- Version: 0.1.22
3
+ Version: 0.1.24
4
4
  Summary: A globally distributed container runtime
5
5
  Requires-Python: >=3.10.14
6
6
  Description-Content-Type: text/markdown
@@ -6,15 +6,15 @@ nebu/containers/container.py,sha256=yb7KaPTVXnEEAlrpdlUi4HNqF6P7z9bmwAILGlq6iqU,
6
6
  nebu/containers/decorator.py,sha256=uFtzlAXRHYZECJ-NPusY7oN9GXvdHrHDd_JNrIGr8aQ,3244
7
7
  nebu/containers/models.py,sha256=0j6NGy4yto-enRDh_4JH_ZTbHrLdSpuMOqNQPnIrwC4,6815
8
8
  nebu/containers/server.py,sha256=yFa2Y9PzBn59E1HftKiv0iapPonli2rbGAiU6r-wwe0,2513
9
- nebu/processors/consumer.py,sha256=qQQWNAZnY7A7Af6SNMYVXN3NOG_9dNK5iE_0us-o2Po,19659
10
- nebu/processors/decorate.py,sha256=AeG1c1n8JtcexxAEf2sF2L2eKwVDaNQ5gvPs6EpazKo,34789
9
+ nebu/processors/consumer.py,sha256=ejGgYhOMn86aEvJxQorWp7ybHVcvmo4T3nyiv7gTnhM,19687
10
+ nebu/processors/decorate.py,sha256=B2qK1B2Jm1SzO5IN9pWk32sS0z5WLqXPdJtP-y-iSO4,34563
11
11
  nebu/processors/default.py,sha256=W4slJenG59rvyTlJ7gRp58eFfXcNOTT2Hfi6zzJAobI,365
12
- nebu/processors/models.py,sha256=GvnI8UJrQSjHo2snP07cPfisCH90cEGTY-PZV5_AtXI,3654
12
+ nebu/processors/models.py,sha256=y40HoW-MEzDWB2dm_tsYlUy3Nf3s6eiLC0iGO9BoNog,3956
13
13
  nebu/processors/processor.py,sha256=oy2YdI-cy6qQWxrZhpZahJV46oWZlu_Im-jm811R_oo,9667
14
14
  nebu/redis/models.py,sha256=coPovAcVXnOU1Xh_fpJL4PO3QctgK9nBe5QYoqEcnxg,1230
15
15
  nebu/services/service.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
- nebu-0.1.22.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
17
- nebu-0.1.22.dist-info/METADATA,sha256=5knaeQTz1sBQEH2za1s6-499HYkNfNxLZgxvpRUEO6Y,1678
18
- nebu-0.1.22.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
19
- nebu-0.1.22.dist-info/top_level.txt,sha256=uLIbEKJeGSHWOAJN5S0i5XBGwybALlF9bYoB1UhdEgQ,5
20
- nebu-0.1.22.dist-info/RECORD,,
16
+ nebu-0.1.24.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
17
+ nebu-0.1.24.dist-info/METADATA,sha256=8O-NbvrAFRRuGr3QLz2DzM08CJnbpfXi3fAIABOSho4,1678
18
+ nebu-0.1.24.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
19
+ nebu-0.1.24.dist-info/top_level.txt,sha256=uLIbEKJeGSHWOAJN5S0i5XBGwybALlF9bYoB1UhdEgQ,5
20
+ nebu-0.1.24.dist-info/RECORD,,
File without changes