Skip to content

Commit 969e15b

Browse files
0.0.11
1 parent c4f2b4e commit 969e15b

File tree

5 files changed

+19
-11
lines changed

5 files changed

+19
-11
lines changed

docs/getting-started/modal.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ snok new myapp --type app
5555

5656
### Check that everything's ready to go!
5757

58+
You might have to set up a database so that tests pass, but we aren't testing anything with databases in this, so it's ok if tests fail.
59+
5860
```sh
5961
snok ok
6062
```

snok/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""snok"""
22

3-
__version__ = "0.0.10"
3+
__version__ = "0.0.11"

snok/cli.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,10 @@ def _test(
294294
)
295295
) -> None: # pragma: no cover
296296
echo("Running tests...")
297-
cmd = ["pytest"]
297+
cmd = [
298+
"ENV=test",
299+
"pytest",
300+
]
298301
if keepitonehundred:
299302
cmd.append("--cov-fail-under=100")
300303
_run_cmd(cmd)
@@ -462,11 +465,18 @@ def _server(
462465

463466

464467
@app.command("deploy")
465-
def _deploy() -> None: # pragma: no cover
468+
def _deploy(
469+
env: str = Option(
470+
"prod",
471+
"--env",
472+
"-e",
473+
help="The environment to deploy to.",
474+
),
475+
) -> None: # pragma: no cover
466476
"""Deploy your code."""
467477
_run_cmd(
468478
[
469-
"ENV=prod",
479+
f"ENV={env}",
470480
"modal",
471481
"deploy",
472482
f"{_get_project_name()}/_modal.py",

snok/templates/__app/_modal.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
from typing import Any, Callable, List, Optional
22

3-
from {{ __template_name }}.config import Settings
3+
from {{ __template_name }}.config import settings
44
from {{ __template_name }}.logger import log
55
from fastapi import FastAPI
66
from modal import Dict, Function, Image, Secret, Stub, asgi_app
77
from modal import Queue as ModalQueue
88

99
stub = Stub(name="{{ __template_name }}")
10-
Settings.Config.env_file = ".env.prod"
1110
stub["env"] = Secret.from_dict(
12-
{str(k): str(v) for k, v in Settings().dict().items()} # type: ignore
11+
{str(k): str(v) for k, v in settings.dict().items()} # type: ignore
1312
)
1413

1514
_kv = Dict.new()

snok/templates/__app/config.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,7 @@ class Config:
100100

101101

102102
def _set_settings() -> Settings:
103-
_env = ENV(os.environ["ENV"].lower()) if os.getenv("ENV") else ENV.dev
104-
# override for test
105-
if os.getenv("_", "").endswith("pytest") or "pytest" in "".join(sys.argv):
106-
_env = ENV.test
103+
_env = ENV(os.getenv("ENV", "dev").lower())
107104
Settings.Config.env_file = f".env.{_env.value}"
108105
return Settings() # type: ignore
109106

0 commit comments

Comments
 (0)