This message was deleted.
# general
s
This message was deleted.
đź‘€ 1
d
You should use
py
instead of
jar
for Python functions to specify the artifact name. The Pulsar function framework uses that field to decide which runtime environment is needed to run the function. jar = java, py = python
o
@David K the Pulsar Function Im using is a Java function, hence the jar file path.
The REST method Im calling from a different python script. The Java function JAR is already present on the Pulsar Broker pod. And I am able to successfully run it using
pulsar-admin
CLI
I’d really appreciate help here @Ming
m
You need to provide a file path for the actual function’s jar. An example would be like this one
Copy code
# File path
file_path = "/Users/mingluo/function.jar"

# Make the request
response = requests.post(
    url,
    headers=headers,
    files={'data': open(file_path, 'rb')},
    data={'functionConfig': json.dumps(function_config)}
)
o
@Ming isnt that provided in the
jar
field in the functionConfig?
@Ming since my jar file already resides within the Pulsar broker pod, it doesn’t make sense to send the JAR file with the POST request. Is there some register command that Im missing that I need to run for my JAR file residing in the
/tmp
folder of the broker, before I run the create post request?
s
@David K
m
You need to provide a path to upload the jar from a http client to the http server (namely the function worker). Pulsar function uses multi-part upload that requires the
data
part. There is a built-in function which you don’t need upload a function. I am not sure if you refer to the built-in function. sorry, this is from a curl working example I have that I convert to Python. It looks like the same path may need to provide twice. can you try?
o
@Ming apologies, I might not be understanding this correctly. My Python script (HTTP Client) which creates the REST request to create a function resides in a separate container, and my JAR file for the Pulsar Function already resides within the broker pod/container. So I can not send the JAR file as part of the request from the Client. I did come across this, and I was wondering if I have to maybe “upload” the JAR file to the function and then run my REST request. I did try this out and it did not work for me. Getting the same error as before, i.e.
Function package is not provided
m
Have you tried to get a curl command work first? Then convert the curl to a python call
o
I haven’t, let me try that out. Would I still need to pass the jar as part of the file even if it already resides in the server?
m
You do
o
but the path would be the path of the JAR within the broker container?
👍 1
d
Yes, it would be the full path name of the jar file
o
@Ming RE: Conversation above, I am trying to use a builtin function now called
generic-stream-function
. I am unclear on how to use this without having to upload the function. Having to upload the function would defeat the purpose. Can you share the structure of the REST call for this or guide me to the documentation covering this?