Hi folks, I’m running a test with bentoml 1.2.4 on...
# ask-for-help
d
Hi folks, I’m running a test with bentoml 1.2.4 on Spark. But I got
'APIMethod' object has no attribute 'output'
from run_in_spark when I ran
bentoml.batch.run_in_spark(bento, df, spark)
. Stacktrace:
Copy code
results = bentoml.batch.run_in_spark(bento, df, spark)
  File "/usr/local/lib/python3.8/site-packages/bentoml/_internal/batch/spark.py", line 169, in run_in_spark
    output_schema = api.output.spark_schema()
AttributeError: 'APIMethod' object has no attribute 'output'
I checked the APIMethod implementation and did not see an “output” or an “input” attribute. Is this expected? Anybody else ran into issues running bentos on Spark? Thanks!
👀 1
c
Hi, the spark guide is a bit outdated right now for BentoML 1.2, this api unfortunately only work with 1.1.x using DataFrame as input and output. We are building out a more generic solution for spark batch inference at the moment
d
Thanks @Chaoyu! I switched to version 1.1.11 and now I don’t get the same error anymore, but now I have a new question: I want my server to take in an numpy array of shape Nx1 and return an numpy array of shape NxM, where batch size N is unknown since we rely on the spark batch inference to decide how big a batch is. If I don’t define a shape in my NumpyNdarray descriptor, I get error
Cannot perform batch inference with a numpy output without a known shape; please provide a shape
, but I don’t know how to define the shape since I don’t know the batch size… What should I do if I want to use Spark batch inference and expect the output to be an NxM numpy array?
Basically what I want to achieve is to use
bentoml.batch.run_in_spark
to run inferences, where input of each inference is one string and output of each inference is a list or an N-D array. I’ve tried different ways but always gets the error stated above or
pyarrow.lib.ArrowInvalid: only handle 1-dimensional arrays
.
@Chaoyu could you help with this question too?