Skip to content

Commit

Permalink
mkdir for root_path, logs, and status_semaphore if they don't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
eriktaubeneck committed Jan 19, 2024
1 parent 1818490 commit 25d4212
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions sidecar/app/query/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,13 @@ class Query:
logger: loguru.Logger = field(init=False, repr=False)
_logger_id: int = field(init=False, repr=False)
step_classes: ClassVar[list[type[Step]]] = []
_log_dir: Path = settings.root_path / Path("logs")
_status_dir: Path = settings.root_path / Path("status_semaphore")

def __post_init__(self):
self.logger = logger.bind(task=self.query_id)
self._log_dir.mkdir(exist_ok=True)
self._status_dir.mkdir(exist_ok=True)
self.log_file_path.touch()
self._logger_id = logger.add(
self.log_file_path,
Expand Down Expand Up @@ -87,11 +91,11 @@ def running(self):

@property
def log_file_path(self) -> Path:
return settings.root_path / Path("logs") / Path(f"{self.query_id}.log")
return self._log_dir / Path(f"{self.query_id}.log")

@property
def status_file_path(self) -> Path:
return settings.root_path / Path("status_semaphore") / Path(f"{self.query_id}")
return self._status_dir / Path(f"{self.query_id}")

@property
def steps(self) -> Iterable[Step]:
Expand Down
1 change: 1 addition & 0 deletions sidecar/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def start_helper_sidecar_command(
role = Role(int(identity))
network_config = config_path / Path("network.toml")
root_path = root_path or Path(f"tmp/sidecar/{role.value}")
root_path.mkdir(parents=True, exist_ok=True)
helpers = load_helpers_from_network_config(network_config)
if role == Role.COORDINATOR:
private_key_pem_path = config_path / Path("coordinator.key")
Expand Down

0 comments on commit 25d4212

Please sign in to comment.