wip
This commit is contained in:
parent
347418ee3f
commit
b8a9ea0f17
6 changed files with 63 additions and 18 deletions
|
|
@ -8,4 +8,6 @@ RUN pip3 install .
|
||||||
COPY . /app
|
COPY . /app
|
||||||
RUN pip3 install .
|
RUN pip3 install .
|
||||||
|
|
||||||
|
EXPOSE 5000
|
||||||
|
|
||||||
ENTRYPOINT ["learn-sql-model", "api", "run"]
|
ENTRYPOINT ["learn-sql-model", "api", "run"]
|
||||||
|
|
|
||||||
40
fly.toml
Normal file
40
fly.toml
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
# fly.toml app configuration file generated for learn-sql-model on 2023-06-13T20:34:33-05:00
|
||||||
|
#
|
||||||
|
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
|
||||||
|
#
|
||||||
|
|
||||||
|
app = "learn-sql-model"
|
||||||
|
primary_region = "ord"
|
||||||
|
console_command = "learn-sql-model api run"
|
||||||
|
|
||||||
|
[experimental]
|
||||||
|
auto_rollback = true
|
||||||
|
|
||||||
|
[build]
|
||||||
|
dockerfile = "Dockerfile"
|
||||||
|
|
||||||
|
[env]
|
||||||
|
PORT = "5000"
|
||||||
|
|
||||||
|
[[services]]
|
||||||
|
protocol = "tcp"
|
||||||
|
internal_port = 5000
|
||||||
|
processes = ["app"]
|
||||||
|
|
||||||
|
[[services.ports]]
|
||||||
|
port = 80
|
||||||
|
handlers = ["http"]
|
||||||
|
|
||||||
|
[[services.ports]]
|
||||||
|
port = 443
|
||||||
|
handlers = ["tls", "http"]
|
||||||
|
[services.concurrency]
|
||||||
|
type = "connections"
|
||||||
|
hard_limit = 25
|
||||||
|
soft_limit = 20
|
||||||
|
|
||||||
|
[[services.tcp_checks]]
|
||||||
|
interval = "15s"
|
||||||
|
timeout = "2s"
|
||||||
|
grace_period = "1s"
|
||||||
|
restart_limit = 0
|
||||||
|
|
@ -6,6 +6,7 @@ from learn_sql_model.cli.api import api_app
|
||||||
from learn_sql_model.cli.config import config_app
|
from learn_sql_model.cli.config import config_app
|
||||||
from learn_sql_model.cli.hero import hero_app
|
from learn_sql_model.cli.hero import hero_app
|
||||||
from learn_sql_model.cli.model import model_app
|
from learn_sql_model.cli.model import model_app
|
||||||
|
from learn_sql_model.game.game import game_app
|
||||||
|
|
||||||
app = typer.Typer(
|
app = typer.Typer(
|
||||||
name="learn_sql_model",
|
name="learn_sql_model",
|
||||||
|
|
@ -16,6 +17,7 @@ app.add_typer(config_app, name="config")
|
||||||
app.add_typer(model_app, name="model")
|
app.add_typer(model_app, name="model")
|
||||||
app.add_typer(api_app, name="api")
|
app.add_typer(api_app, name="api")
|
||||||
app.add_typer(hero_app, name="hero")
|
app.add_typer(hero_app, name="hero")
|
||||||
|
app.add_typer(game_app, name="game")
|
||||||
|
|
||||||
|
|
||||||
def version_callback(value: bool) -> None:
|
def version_callback(value: bool) -> None:
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ from contextvars import ContextVar
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from fastapi import Depends
|
from fastapi import Depends
|
||||||
from pydantic import BaseModel, BaseSettings
|
from pydantic import BaseModel, BaseSettings, validator
|
||||||
from sqlalchemy import create_engine
|
from sqlalchemy import create_engine
|
||||||
from sqlmodel import SQLModel, Session
|
from sqlmodel import SQLModel, Session
|
||||||
|
|
||||||
|
|
@ -61,6 +61,12 @@ class Config(BaseSettings):
|
||||||
env_nested_delimiter = "__"
|
env_nested_delimiter = "__"
|
||||||
env_file = ".env", ".env.dev", ".env.qa", ".env.prod"
|
env_file = ".env", ".env.dev", ".env.qa", ".env.prod"
|
||||||
|
|
||||||
|
@validator("database_url")
|
||||||
|
def validate_database_url(cls, v: str) -> str:
|
||||||
|
if v.startswith("postgres://"):
|
||||||
|
return v.replace("postgres://", "postgresql+psycopg2://")
|
||||||
|
return v
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def database(self) -> Database:
|
def database(self) -> Database:
|
||||||
return get_database(config=self)
|
return get_database(config=self)
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,7 @@
|
||||||
# using pygame make a game using Hero
|
|
||||||
# it should be gamepad and mouse compatible
|
|
||||||
# it should have a server that keeps track of the game logic
|
|
||||||
# it should have a renderer that renders the game
|
|
||||||
# it should have a client that sends commands to the server
|
|
||||||
#
|
|
||||||
|
|
||||||
|
|
||||||
import atexit
|
import atexit
|
||||||
|
|
||||||
|
from faker import Faker
|
||||||
import pygame
|
import pygame
|
||||||
import typer
|
|
||||||
from typer import Typer
|
from typer import Typer
|
||||||
from websocket import create_connection
|
from websocket import create_connection
|
||||||
|
|
||||||
|
|
@ -49,7 +41,7 @@ class Client:
|
||||||
def ws(self):
|
def ws(self):
|
||||||
def connect():
|
def connect():
|
||||||
self._ws = create_connection(
|
self._ws = create_connection(
|
||||||
f"ws://{config.api_client.host}:{config.api_client.port}/wsecho"
|
f"ws://{config.api_client.url.replace('https://', '')}/wsecho"
|
||||||
)
|
)
|
||||||
|
|
||||||
if not hasattr(self, "_ws"):
|
if not hasattr(self, "_ws"):
|
||||||
|
|
@ -176,17 +168,17 @@ class Client:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
app = Typer()
|
game_app = Typer()
|
||||||
|
|
||||||
|
|
||||||
@app.command()
|
@game_app.command()
|
||||||
def run(
|
def run():
|
||||||
name: str = typer.Option(...),
|
f = Faker()
|
||||||
secret_name: str = typer.Option(...),
|
name = "-".join(f.words(2))
|
||||||
):
|
secret_name = "-".join(f.words(2))
|
||||||
client = Client(name, secret_name)
|
client = Client(name, secret_name)
|
||||||
client.run()
|
client.run()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app()
|
game_app()
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,9 @@ dependencies = [
|
||||||
"psycopg2-binary",
|
"psycopg2-binary",
|
||||||
'pygame',
|
'pygame',
|
||||||
'black',
|
'black',
|
||||||
|
'alembic',
|
||||||
|
'pygame',
|
||||||
|
"pyflyby",
|
||||||
"anyconfig",
|
"anyconfig",
|
||||||
"copier",
|
"copier",
|
||||||
"engorgio",
|
"engorgio",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue