Skip to content

Commit

Permalink
0.0.11
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonycorletti committed Jul 28, 2023
1 parent c4f2b4e commit 969e15b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 11 deletions.
2 changes: 2 additions & 0 deletions docs/getting-started/modal.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ snok new myapp --type app

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

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.

```sh
snok ok
```
Expand Down
2 changes: 1 addition & 1 deletion snok/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""snok"""

__version__ = "0.0.10"
__version__ = "0.0.11"
16 changes: 13 additions & 3 deletions snok/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,10 @@ def _test(
)
) -> None: # pragma: no cover
echo("Running tests...")
cmd = ["pytest"]
cmd = [
"ENV=test",
"pytest",
]
if keepitonehundred:
cmd.append("--cov-fail-under=100")
_run_cmd(cmd)
Expand Down Expand Up @@ -462,11 +465,18 @@ def _server(


@app.command("deploy")
def _deploy() -> None: # pragma: no cover
def _deploy(
env: str = Option(
"prod",
"--env",
"-e",
help="The environment to deploy to.",
),
) -> None: # pragma: no cover
"""Deploy your code."""
_run_cmd(
[
"ENV=prod",
f"ENV={env}",
"modal",
"deploy",
f"{_get_project_name()}/_modal.py",
Expand Down
5 changes: 2 additions & 3 deletions snok/templates/__app/_modal.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
from typing import Any, Callable, List, Optional

from {{ __template_name }}.config import Settings
from {{ __template_name }}.config import settings
from {{ __template_name }}.logger import log
from fastapi import FastAPI
from modal import Dict, Function, Image, Secret, Stub, asgi_app
from modal import Queue as ModalQueue

stub = Stub(name="{{ __template_name }}")
Settings.Config.env_file = ".env.prod"
stub["env"] = Secret.from_dict(
{str(k): str(v) for k, v in Settings().dict().items()} # type: ignore
{str(k): str(v) for k, v in settings.dict().items()} # type: ignore
)

_kv = Dict.new()
Expand Down
5 changes: 1 addition & 4 deletions snok/templates/__app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,7 @@ class Config:


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

Expand Down

0 comments on commit 969e15b

Please sign in to comment.