tvalentyn opened a new issue, #40644:
URL: https://github.com/apache/beam/issues/40644

   ### What happened?
   
   Repro (LLM generated):
   
   ```
   """Repro: max_batch_weight on a RunInference ModelHandler raises TypeError.
   
   ModelHandler.__init__ accepts max_batch_weight and returns it from
   batch_elements_kwargs(), but RunInference.expand passes those kwargs to
   beam.BatchElements, which has no max_batch_weight parameter. The pipeline
   fails at construction time, before any model is loaded or any data is
   processed.
   
   Run from sdks/python on a checkout without the fix:
     PYTHONPATH=. python3 repro_max_batch_weight.py
   """
   import apache_beam as beam
   from apache_beam.ml.inference import base
   from apache_beam.ml.inference.sklearn_inference import 
SklearnModelHandlerNumpy
   
   
   class MinimalHandler(base.ModelHandler):
     def load_model(self):
       return None
   
     def run_inference(self, batch, model, inference_args=None):
       return batch
   
   
   def build(name, handler):
     print(f'--- {name} ---')
     print('batch_elements_kwargs():', handler.batch_elements_kwargs())
     try:
       p = beam.Pipeline()
       # Only constructs the pipeline: RunInference.expand runs here, the model
       # is never loaded and the pipeline is never run.
       _ = p | beam.Create(['a', 'bb']) | base.RunInference(handler)
       print('OK: pipeline constructed')
     except TypeError as e:
       print(f'TypeError: {e}')
   
   
   print('apache_beam', beam.__version__, 'from', beam.__file__)
   
   # 1. Minimal custom handler: the base ModelHandler.__init__ argument.
   build(
       'custom ModelHandler',
       MinimalHandler(max_batch_weight=10, element_size_fn=len))
   
   # 2. Built-in handler: max_batch_weight is a documented constructor argument
   #    of every built-in handler. The model URI is never read.
   build(
       'SklearnModelHandlerNumpy',
       SklearnModelHandlerNumpy(
           model_uri='gs://unused/model.pkl',
           max_batch_weight=10,
           element_size_fn=len))
   
   # 3. Control: the same handler without max_batch_weight constructs fine.
   build('control (no max_batch_weight)', MinimalHandler(element_size_fn=len))
   
   ```
   
   ### Issue Priority
   
   Priority: 2 (default / most bugs should be filed as P2)
   
   ### Issue Components
   
   - [ ] Component: Python SDK
   - [ ] Component: Java SDK
   - [ ] Component: Go SDK
   - [ ] Component: Typescript SDK
   - [ ] Component: IO connector
   - [ ] Component: Beam YAML
   - [ ] Component: Beam examples
   - [ ] Component: Beam playground
   - [ ] Component: Beam katas
   - [ ] Component: Website
   - [ ] Component: Infrastructure
   - [ ] Component: Spark Runner
   - [ ] Component: Flink Runner
   - [ ] Component: Prism Runner
   - [ ] Component: Twister2 Runner
   - [ ] Component: Hazelcast Jet Runner
   - [ ] Component: Google Cloud Dataflow Runner


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to