There’s not any such step. Putting that decorator on a server function is enough, as long as the server function has a unique name, different from your uplink functions (if you still have an uplink session running).
Is there an image_1_show method defined for the Form1 class?
No, I have no special image_1_show method. In Form1, there is a line that says self.image_1.source = file, where file is the image file. It used to work when the code was on my laptop JN.
Since my app now flags an error immediately after the image file is uploaded, I suspect an uplink error, too.
I think the Anvil app doesn’t know where to look anymore. I don’t know how to redirect it to the Server. I thought the switch would automatic since the Server code has @anvil.server.callable and has my server_API key.
This means that you once had a method named ‘image_1_show’’ (that’s the default method name generated by the IDE when you click >> for the show event), but you removed that method without removing the binding. You need to delete ‘image_1_show’ from the ‘show’ event binding.
If you have root access to your VPS account, you don’t need any special offering by Dreamhost to run a Jupyter notebook. You can SSH into the command line and pip-install then run whatever you want on your virtual computer, just like you would on a local machine.
There was no binding to image_1_show.
Here’s the code on Form1:
def file_loader_1_change(self, file, **event_args):
"""This method is called when a new file is loaded into this FileLoader"""
result = anvil.server.call('identify_celeb', file)
self.celeb_id.text = result
self.image_1.source = file
An image is uploaded using the Upload component, and then the file is supposed to be sent to identify_celeb function on the Server. The image is just displayed. But I still get the anvil.server.RuntimeUnavailableError: Could not launch server runtime - image build failed error.
What sorts of things would prevent the server runtime from being available? What is an image build failure?
Since I used the server_API key when I was connected remotely to my laptop, do I need to use a new server_API key? Is it permanently associated with my laptop, and is looking for a remote hookup instead of looking at the Anvil server? Do I need to call the Anvil server a different way instead of just anvil.server.call?
As I said, the code worked perfectly when the Python was running on my laptop. Only after I moved the code to Anvil’s servers am I getting these errors.
You weren’t aware there was code assigned to that event, but that situation is how the error you’re receiving is generated. You need to delete that method name from the show event handler, or write code for that method, to eliminate the error.
You’re referring to the uplink key, correct? But you’re eliminating the uplink and moving code to anvil server functions, correct? If you’re moving the code that was on your laptop to the anvil server functions, then you should no longer be trying to connect to your laptop to run code. It sounds like you’re getting errors because you’re still calling uplink functions, and that code is no longer connected via uplink. If you want to move all your code and data to the Anvil environment, then you need to move everything to the anvil environment - that’s not necessarily a simple chore, depending upon how you’ve structured your code and where you’ve saved data on the laptop (we have no idea how you’ve set up any of that because we’ve never seen any of the structure of your app). If you move every bit of your app to the anvil environment, and you have your laptop shut down / disconnected from uplink, then you should no longer have an uplink running in the app.
Well I changed result = anvil.server.call('identify_celeb', file)
to just result = identify_celeb(file)
and removed all the anvil.server.connect calls, but it doesn’t recognize the identify_celeb function on my server, but at least I’m not getting an image build error anymore.
What do I need to state to get code on Form1 to call a Python function on the Anvil server?
To call an anvil server function named identify_celeb, with ‘file’ sent as an argument, call anvil.server.call(identify_celeb, file). That function should no longer exist in any code connected via uplink.
Well I got it to work by requesting a fresh server_API key. I guess the old one was somehow imprinted with requesting the uplink that it would only recognize the remote uplink. That was the solution, and now I can leave my laptop closed. Thanks for your patience, Nick.
By the way, I just discovered your excellent tutorial. Wish I had known about it earllier. I see you have a server tab with code there. I would have loved to have been able to take a peek to compare it to what I have. Do you discuss the Server tab anywhere in the tutorial?