Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: get_db_path comments
Browse files Browse the repository at this point in the history
andylizf committed Oct 1, 2024
1 parent ef617c7 commit 743a34e
Showing 3 changed files with 19 additions and 4 deletions.
17 changes: 13 additions & 4 deletions sky/jobs/state.py
Original file line number Diff line number Diff line change
@@ -20,10 +20,19 @@

logger = sky_logging.init_logger(__name__)

_DB_PATH = pathlib.Path('~/.sky/spot_jobs.db')
_DB_PATH = _DB_PATH.expanduser().absolute()
_DB_PATH.parents[0].mkdir(parents=True, exist_ok=True)
_DB_PATH = str(_DB_PATH)

def _get_db_path() -> str:
"""
Workaround to collapse multi-step Path ops for type checker.
Ensures _DB_PATH is str, avoiding Union[Path, str] inference.
"""
path = pathlib.Path('~/.sky/spot_jobs.db')
path = path.expanduser().absolute()
path.parents[0].mkdir(parents=True, exist_ok=True)
return str(path)


_DB_PATH = _get_db_path()

# Module-level connection/cursor; thread-safe as the module is only imported
# once.
2 changes: 2 additions & 0 deletions sky/serve/replica_managers.py
Original file line number Diff line number Diff line change
@@ -23,8 +23,10 @@
from sky import sky_logging
from sky import status_lib
from sky.backends import backend_utils

if typing.TYPE_CHECKING:
from sky import resources

from sky.serve import constants as serve_constants
from sky.serve import serve_state
from sky.serve import serve_utils
4 changes: 4 additions & 0 deletions sky/serve/serve_state.py
Original file line number Diff line number Diff line change
@@ -19,6 +19,10 @@


def _get_db_path() -> str:
"""
Workaround to collapse multi-step Path ops for type checker.
Ensures _DB_PATH is str, avoiding Union[Path, str] inference.
"""
path = pathlib.Path(constants.SKYSERVE_METADATA_DIR) / 'services.db'
path = path.expanduser().absolute()
path.parents[0].mkdir(parents=True, exist_ok=True)

0 comments on commit 743a34e

Please sign in to comment.