-
Notifications
You must be signed in to change notification settings - Fork 44
Google App Engine deployments? #450
Comments
Hi @igordertigor! We're going to release K8s, SageMaker and "deploy" to Docker containers very soon (they're already available in |
Hi @aguschin , thanks for the quick reply. I haven't actually deployed an mlem model to GAE yet, but was planning to use the pre-built Docker image if possible. I believe that something like this would work for the # Default runtime is python38
runtime: python38
# Default instance class is F1 (set depending on model)
instance_class: F1
entrypoint: mlem serve $MODEL_SPEC
env_variables:
MODEL_SPEC=<INSERT FROM GITHUB ACTIONS> (obviously, mlem should be in the |
Do you know MLEM can build docker images that run |
Of course I know. Unfortunately, running docker in GAE requires the non-standard tier, which requires a tiny bit more maintenance from our side. We would prefer to avoid that in favour of the basic GAE environment. But then, the deployment script isn't super complex anyway. It would just be nice to streamline everything with mlem. If you could give me some pointers where to start, I would be happy to take a look into how much effort it would be to implement it and potentially just submit a pull request. By the way congrats on the new release. |
I took a quick look and it seems that something like this can prepare a directory with all that you need import os
import sys
from yaml import safe_dump
import mlem
from mlem.api import load_meta, build
from mlem.contrib.fastapi import FastAPIServer
from mlem.core.objects import MlemModel
from mlem.runtime.server import Server
def prepare_for_gae(path: str, server: Server, target: str = ".", project: str = None, rev: str = None, ):
model = load_meta(path, project, rev, force_type=MlemModel)
os.makedirs(target, exist_ok=True)
model.clone(os.path.join(target, "model"))
reqs_path = os.path.join(target, "requirements.txt")
build("requirements", model, target=reqs_path)
with open(reqs_path, "a") as f:
reqs = server.get_requirements() + [f"mlem=={mlem.__version__}"]
print(reqs)
f.write("\n".join(reqs.to_pip()))
with open(os.path.join(target, "app.yaml"), "w") as f:
f.write(f"runtime: python{sys.version_info[0]}{sys.version_info[1]}\n"
f"entrypoint: mlem serve --load server.mlem --model model")
with open(os.path.join(target, "server.mlem"), "w") as f:
f.write(safe_dump(server.dict()))
def main():
prepare_for_gae("model", server=FastAPIServer(), target="./build")
if __name__ == '__main__':
main() However I did not find a good way to then deploy this to GAE from code. They have this library https://googleapis.dev/python/appengine/latest/index.html but docs are practically non-existant. Also didn't find any good If you can help with questions like this:
then I will be able to help you create a full |
Hi @mike0sv, thank you for sharing your script. I believe that I was doing something quite similar but without using mlem internals. Regarding your questions, I'll assume that the user is logged into the target gcloud project (looking at at least the heroku deployment, that seemed to be assumed there too). Then:
And yes, there is very little and confusing/outdated documentation. I hope this helps at least a bit. |
Is there a way to do this without calling |
This page might be helpful https://cloud.google.com/appengine/docs/admin-api/deploying-apps |
Not an easy way that I'm aware of. But as you already pointed out: It's kind of a mess with the docs. You could of course assemble the requests yourself. I think you already pointed there with the second comment. |
It's just hard to ensure that |
That certainly makes sense. It might be tricky to get the credentials in that case though. |
I think there is an env var with path to json key file. It can be used to make those oauth calls (or whatever gcloud uses). Also we can find where gcloud stores it's credentials and use them. Basically it's what aws do inside boto3 for example, the difference is that they have slightly better docs :) |
Mother of God, Ok App Engine part is written in 2016 |
Oh ha! |
I see that so far, mlem can only deploy to heroku natively. For google app engine, there is no dedicated deployment type. What's the timeline for adding something like that? Right now it seems that the workaround would be to run
mlem serve
inside theapp.yaml
. Is that correct? Is there any plan to provide an adapter for this?The text was updated successfully, but these errors were encountered: