Skip to content

Commit

Permalink
Ensure username is added to DB entries during creation. Rename 'run' …
Browse files Browse the repository at this point in the history
…directory to 'runs'.
  • Loading branch information
suecharo committed Oct 13, 2024
1 parent 2101657 commit 84b5cf8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,6 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

run/
runs/
keycloak-data/
tests/htmlcov/
6 changes: 3 additions & 3 deletions compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ services:
- ${PWD}/sapporo:/app/sapporo
- ${PWD}/tests:/app/tests
# The ones below are mounted for cwltool and DinD.
- ${PWD}/run:${PWD}/run
- ${PWD}/runs:${PWD}/runs
- /var/run/docker.sock:/var/run/docker.sock
- /tmp:/tmp
environment:
# Priority: [CLI Args] -> [Env Vals] -> [Defaults]
- SAPPORO_HOST=0.0.0.0
- SAPPORO_PORT=1122
- SAPPORO_DEBUG=True
- SAPPORO_RUN_DIR=${PWD}/run
- SAPPORO_RUN_DIR=${PWD}/runs
ports:
- 127.0.0.1:1123:1122
- 127.0.0.1:1122:1122
restart: on-failure
working_dir: /app
command: [ "sleep", "infinity" ]
Expand Down
6 changes: 3 additions & 3 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ services:
container_name: sapporo-service
volumes:
# The ones below are mounted for cwltool and DinD.
- ${PWD}/run:${PWD}/run
- ${PWD}/runs:${PWD}/runs
- /var/run/docker.sock:/var/run/docker.sock
- /tmp:/tmp
environment:
# Priority: [CLI Args] -> [Env Vals] -> [Defaults]
- SAPPORO_HOST=0.0.0.0
- SAPPORO_PORT=1122
- SAPPORO_DEBUG=False
- SAPPORO_RUN_DIR=${PWD}/run
- SAPPORO_RUN_DIR=${PWD}/runs
ports:
- 127.0.0.1:1122:1122
restart: on-failure
working_dir: /app
command: ["sapporo"]
command: [ "sapporo" ]
networks:
- sapporo-network

Expand Down
7 changes: 5 additions & 2 deletions sapporo/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

from sapporo.config import get_config
from sapporo.factory import create_run_summary
from sapporo.run import glob_all_run_ids
from sapporo.run import glob_all_run_ids, read_file
from sapporo.schemas import RunSummary, State
from sapporo.utils import dt_to_time_str, time_str_to_dt

Expand Down Expand Up @@ -52,6 +52,8 @@ def get_session() -> Generator[Session, None, None]:


class Run(SQLModel, table=True): # type: ignore
__tablename__ = "runs"

run_id: str = Field(primary_key=True)
username: Optional[str] = None
state: State
Expand Down Expand Up @@ -86,9 +88,10 @@ def init_db() -> None:
with get_session() as session:
for run_id in glob_all_run_ids():
run_summary = create_run_summary(run_id)
username: Optional[str] = read_file(run_id, "username")
run = Run(
run_id=run_summary.run_id,
username=None,
username=username,
state=run_summary.state,
start_time=run_summary.start_time and time_str_to_dt(run_summary.start_time),
end_time=run_summary.end_time and time_str_to_dt(run_summary.end_time),
Expand Down

0 comments on commit 84b5cf8

Please sign in to comment.