Skip to content

Commit

Permalink
extra logging
Browse files Browse the repository at this point in the history
  • Loading branch information
ensaremirerol committed Dec 13, 2024
1 parent 08161ad commit 0ee7009
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 0 deletions.
18 changes: 18 additions & 0 deletions server/services/core/config_service.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import logging

from kink import inject
from sqlalchemy import delete

Expand All @@ -13,24 +15,38 @@
@inject(alias=ConfigServiceProtocol)
class ConfigService(ConfigServiceProtocol):
def __init__(self, db_service: DBService):
self.logger = logging.getLogger(__name__)
self._db_service = db_service

self.logger.info("ConfigService initialized")

def get(self, key: str) -> str | None:
self.logger.info(f"Getting config: {key}")
with self._db_service.get_session() as session:
result: ConfigTable | None = session.get(
ConfigTable, key
)
self.logger.info(f"Got config {key}: {result}")
return result.value if result else None

def set(self, key: str, value: str):
self.logger.info(
f"Setting config: {key} to {value}"
)
with self._db_service.get_session() as session:
session.merge(ConfigTable(key=key, value=value))
session.commit()

self.logger.info(f"Set config {key} to {value}")

def delete(self, key: str):
self.logger.info(f"Deleting config: {key}")
with self._db_service.get_session() as session:
item = session.get(ConfigTable, key)
if not item:
self.logger.info(
f"Config {key} not found, ignoring delete"
)
return
session.execute(
delete(ConfigTable).where(
Expand All @@ -39,5 +55,7 @@ def delete(self, key: str):
)
session.commit()

self.logger.info(f"Deleted config {key}")


__all__ = ["ConfigService"]
4 changes: 4 additions & 0 deletions server/services/core/workspace_metadata_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ def __init__(self, db_service: DBService):
)
self._db_service: DBService = db_service

self.logger.info(
"WorkspaceMetadataService initialized"
)

def get_workspace_metadata(
self,
uuid: str,
Expand Down
4 changes: 4 additions & 0 deletions server/services/local/local_fs_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ def __init__(
)
self._FILE_DIR.mkdir()

self.logger.info(
f"LocalFSService initialized with file directory {self._FILE_DIR}"
)

def upload_file(
self,
name: str,
Expand Down
15 changes: 15 additions & 0 deletions server/services/local/local_mapping_service.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import logging

from kink import inject

from server.service_protocols.mapping_service_protocol import (
MappingServiceProtocol,
)


@inject(alias=MappingServiceProtocol)
class LocalMappingService(MappingServiceProtocol):
def __init__(self) -> None:
self.logger = logging.getLogger(__name__)

self.logger.info("LocalMappingService initialized")
2 changes: 2 additions & 0 deletions server/services/local/local_ontology_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def __init__(
self.fs_service: FSServiceProtocol = fs_service
self.db_service: DBService = db_service

self.logger.info("LocalOntologyService initialized")

def _get_from_ontology_table(
self, ontology_id: str
) -> OntologyTable | None:
Expand Down
2 changes: 2 additions & 0 deletions server/services/local/local_source_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ def __init__(
self.fs_service = fs_service
self.logger = logging.getLogger(__name__)

self.logger.info("LocalSourceService initialized")

def get_source(self, source_id: str) -> Source:
self.logger.info(f"Getting source {source_id}")

Expand Down
4 changes: 4 additions & 0 deletions server/services/local/local_workspace_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ def __init__(self, fs_service: LocalFSService):
self.logger = logging.getLogger(__name__)
self._fs_service: LocalFSService = fs_service

self.logger.info(
"LocalWorkspaceService initialized"
)

def get_workspace(
self, location: str
) -> WorkspaceModel:
Expand Down

0 comments on commit 0ee7009

Please sign in to comment.