Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fluid/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Reusable server side python modules"""

__version__ = "1.6.3"
__version__ = "1.6.4"
42 changes: 34 additions & 8 deletions fluid/scheduler/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from pydantic import BaseModel
from rich.console import Console
from rich.table import Table
from typing_extensions import Annotated, Doc
from uvicorn.importer import import_from_string

from fluid.utils import log as log_
Expand Down Expand Up @@ -38,19 +39,43 @@ class TaskManagerCLI(LazyGroup):
def __init__(
self,
task_manager_app: TaskManagerApp,
log_config: dict | None = None,
**kwargs: Any,
):
kwargs.setdefault("commands", DEFAULT_COMMANDS)
super().__init__(**kwargs)
self.task_manager_app = task_manager_app
self.task_manager_app: Annotated[
TaskManagerApp,
Doc(
"""
Task manager application.

This can be a FastAPI app, a callable that returns a FastAPI app,
or a string import path to a FastAPI app.
"""
),
] = task_manager_app
self.log_config: Annotated[
dict,
Doc(
"""
Log configuration parameters.

These parameters are passed to the log_config argument of
`fluid.utils.log.config()`.
"""
),
] = (
log_config or {}
)


def ctx_task_manager_app(ctx: click.Context) -> TaskManagerApp:
return ctx.parent.command.task_manager_app # type: ignore
def ctx_task_manager_cli(ctx: click.Context) -> TaskManagerCLI:
return ctx.parent.command # type: ignore


def ctx_app(ctx: click.Context) -> FastAPI:
app = ctx_task_manager_app(ctx) # type: ignore
app = ctx_task_manager_cli(ctx).task_manager_app
if isinstance(app, str):
return import_from_string(app)()
elif isinstance(app, FastAPI):
Expand Down Expand Up @@ -81,7 +106,8 @@ def get_command(self, ctx: click.Context, cmd_name: str) -> click.Command | None
@from_pydantic(task.params_model)
def execute_task(log: bool, run_id: str, params: str, **extra: Any) -> None:
if log:
log_.config()
log_config = ctx_task_manager_cli(ctx).log_config
log_.config(**log_config)
kwargs = json.loads(params or "{}")
for value in extra.values():
if isinstance(value, BaseModel):
Expand Down Expand Up @@ -132,14 +158,14 @@ def ls(ctx: click.Context) -> None:
@click.pass_context
def serve(ctx: click.Context, host: str, port: int, reload: bool) -> None:
"""Run the service"""
task_manager_app = ctx_task_manager_app(ctx)
cli = ctx_task_manager_cli(ctx)
uvicorn.run(
task_manager_app,
cli.task_manager_app,
port=port,
host=host,
log_level="info",
reload=reload,
log_config=log_.config(),
log_config=log_.config(**cli.log_config),
)


Expand Down
6 changes: 3 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "aio-fluid"
version = "1.6.3"
version = "1.6.4"
description = "Tools for backend python services"
authors = [{ name = "Luca Sbardella", email = "luca@quantmind.com" }]
license = "BSD"
Expand Down