Modal Labs
Dec 28, 2022 - ⧖ 5 minPlaying around with Modal Labs
One of the first things I tried was a regular cron job...
@stub.function(
schedule=modal.Period(minutes=59), secret=modal.Secret.from_name("my-dummy-secret")
)
def say_hi():
now = time.ctime()
secret = os.environ.get("dummy-secret")
print(f"Hello {os.environ.get('USER', 'Rodney')} at {now}")
print(f"{secret=}")
This can get deployed with modal deploy --name <app name> <path to .py file with the stub and function defined in it>
This function gets deployed as an app that I conveniently call say_hi
(as far
as I can tell the app name can be anything - as I add functions to this same
app and deploy with the same name to get a new version)
Notice that this also is an example of giving access to a secret - defined in the Modal Labs dashboard
We can take a look at the apps running at https://modal.com/apps
I then added another function to experiment with custom container images and
saw then that Modal will just slap a new version on anything provisioned with
the same name (intuitive enough for sure) so when I add functions to my .py
script and run modal deploy --name say_hi myscript.py
over and over, the app
called say_hi
in the Modal apps dashboard just gets a new version
This means I can spin up several instances of functionally the same app but with different names/versions etc... Q: Maybe there's gitops or policy stuff builtin to app names then?
I needed to take down an app I deployed as a duplicate but you don't stop apps by name, you stop them by an id... see below
modal-sandbox/modal_sandbox ๎ฅ main ๏ ร1 ๎ฅ ร9 via ๎ต v3.10.6(modal-sandbox)
โ modal app stop --help
Usage: modal app stop [OPTIONS] APP_ID
Stop an app.
โญโ Arguments โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ * app_id TEXT [default: None] [required] โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โญโ Options โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ --help Show this message and exit. โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
modal-sandbox/modal_sandbox ๎ฅ main ๏ ร1 ๎ฅ ร9 via ๎ต v3.10.6(modal-sandbox)
โฏ modal app list
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโณโโโโโโโโโโโโโโโโโโโโโโณโโโโโโโโโโโณโโโโโโโโโโโโโโโโโโโโโโโโโโโโณโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ App ID โ Description โ State โ Creation time โ Stop time โ
โกโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฉ
โ ap-lzy1AAuVy7POFkUcDKRxpQ โ print_info โ deployed โ 2022-12-28 20:59:07-06:00 โ โ
โ ap-qYjE45dciqgT3C3CpNp3RL โ say_hi โ deployed โ 2022-12-28 19:49:22-06:00 โ โ
โ ap-X7FYneUeYV5IKHcyirSb87 โ link-scraper โ stopped โ 2022-12-28 15:39:02-06:00 โ 2022-12-28 15:39:04-06:00 โ
โ ap-UOXTUU4uSRx2UZypJOcAsk โ example-get-started โ stopped โ 2022-12-28 15:17:47-06:00 โ 2022-12-28 15:17:49-06:00 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
modal-sandbox/modal_sandbox ๎ฅ main ๏ ร1 ๎ฅ ร9 via ๎ต v3.10.6(modal-sandbox)
โฏ modal app stop ap-lzy1AAuVy7POFkUcDKRxpQ
Git warning!
I ran modal deploy ...
after comitting some stuff I wanted to try BUT I had
changes in my file I didn't want to deploy... some git safety would be nice for
deployment!
git stash && modal deploy .. && git stash pop
Question for Modal team - in my modal sandbox repo at commit:
aab6162 (HEAD -> main) HEAD@{1}: commit: print base version of my own image to prove it to me
1 file changed, 2 insertions(+)
An environment variable, BASE_VERSION
that I expect to be in my base image
was not available to the python function in my Modal app... hopefully the log
is still
here
GitHub Actions
I think it'd be easy to deploy from GH actions... just need an API Key...
Deployment
Without gitops it's already ahrd to manage my versions... need to get that built in either to github or locally sooooon
Nomad?? :D