Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: consolidate run details models + None valid out type #80

Merged
merged 1 commit into from
May 21, 2024
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
12 changes: 6 additions & 6 deletions bento_wes/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from .backends.backend_types import Command
from .constants import SERVICE_ARTIFACT
from .events import get_flask_event_bus
from .models import RunLog, RunRequest, Run, RunWithDetailsAndOutput
from .models import RunLog, RunRequest, Run, RunWithDetails
from .types import RunStream
from .utils import iso_now

Expand Down Expand Up @@ -187,13 +187,13 @@ def get_task_logs(c: sqlite3.Cursor, run_id: uuid.UUID | str) -> list:
return [task_log_dict(task_log) for task_log in c.fetchall()]

@classmethod
def run_with_details_and_output_from_row(
def run_with_details_from_row(
cls,
c: sqlite3.Cursor,
run: sqlite3.Row,
stream_content: bool,
) -> RunWithDetailsAndOutput:
return RunWithDetailsAndOutput.model_validate(dict(
) -> RunWithDetails:
return RunWithDetails.model_validate(dict(
run_id=run["id"],
state=run["state"],
request=run_request_from_row(run),
Expand All @@ -218,9 +218,9 @@ def get_run_with_details(
c: sqlite3.Cursor,
run_id: uuid.UUID | str,
stream_content: bool,
) -> RunWithDetailsAndOutput | None:
) -> RunWithDetails | None:
if run := cls._get_run_row(c, run_id):
return cls.run_with_details_and_output_from_row(c, run, stream_content)
return cls.run_with_details_from_row(c, run, stream_content)
return None

def set_run_log_name(self, run: Run, workflow_name: str):
Expand Down
16 changes: 6 additions & 10 deletions bento_wes/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"Run",
"RunWithDetails",
"RunOutput",
"RunWithDetailsAndOutput",
]


Expand Down Expand Up @@ -46,16 +45,13 @@ class Run(BaseModel):
state: str # TODO: Literal


class RunOutput(BaseModel): # Bento-specific schema
type: str # WDL / (workflow descriptor language) type
value: str | int | float | bool | list | None # Output value


class RunWithDetails(Run):
request: RunRequest
run_log: RunLog
task_logs: list[dict] # TODO: model


class RunOutput(BaseModel):
type: str # WDL / (workflow descriptor language) type
value: str | int | float | bool | list # Output value


class RunWithDetailsAndOutput(RunWithDetails):
outputs: dict[str, RunOutput] # Bento-specific extension
outputs: dict[str, RunOutput]
2 changes: 1 addition & 1 deletion bento_wes/runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def run_list():
perms_list: list[RunRequest] = []

for r in c.execute("SELECT * FROM runs").fetchall():
run = db.run_with_details_and_output_from_row(c, r, stream_content=False)
run = db.run_with_details_from_row(c, r, stream_content=False)
perms_list.append(run.request)

if not public_endpoint or run.state == STATE_COMPLETE:
Expand Down
Loading