Skip to content

Commit

Permalink
Merge branch 'deploy/hammer' into hammer/bump-node
Browse files Browse the repository at this point in the history
Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
  • Loading branch information
aaronchongth committed Dec 13, 2023
2 parents 94c5b74 + 75ae256 commit 3a97786
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
4 changes: 4 additions & 0 deletions packages/api-server/api_server/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os

import uvicorn
from uvicorn.config import LOGGING_CONFIG

from .app import app
from .app_config import app_config, load_config
Expand All @@ -16,6 +17,9 @@


def main():
LOGGING_CONFIG["formatters"]["access"][
"fmt"
] = '%(asctime)s %(levelprefix)s %(client_addr)s - "%(request_line)s" %(status_code)s'
uvicorn.run(
app,
host=app_config.host,
Expand Down
11 changes: 11 additions & 0 deletions packages/api-server/api_server/authenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,17 @@ async def verify_token(self, token: Optional[str]) -> User:
issuer=self.iss,
)
return await self._get_user(claims)
except jwt.InvalidSignatureError as e:
logger.error("JWT invalid signature error")
raise AuthenticationError(str(e)) from e
except jwt.DecodeError as e:
logger.error("JWT decode error")
raise AuthenticationError(str(e)) from e
except jwt.ExpiredSignatureError as e:
logger.error("JWT expired signature error")
raise AuthenticationError(str(e)) from e
except jwt.InvalidTokenError as e:
logger.error("JWT invalid token error")
raise AuthenticationError(str(e)) from e

def fastapi_dep(self) -> Callable[..., Union[Coroutine[Any, Any, User], User]]:
Expand All @@ -72,6 +82,7 @@ async def dep(
try:
return await self.verify_token(parts[1])
except AuthenticationError as e:
logger.error("Failed to verify token")
raise HTTPException(401, str(e)) from e

return dep
Expand Down
10 changes: 5 additions & 5 deletions packages/api-server/api_server/rmf_io/book_keeper.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def _report_health(health: BaseBasicHealth, logger: logging.Logger):
def _record_beacon_state(self):
async def update(beacon_state: BeaconState):
await beacon_state.save()
self._loggers.beacon_state.info(json.dumps(beacon_state.dict()))
self._loggers.beacon_state.debug(json.dumps(beacon_state.dict()))

self._subscriptions.append(
self.rmf.beacons.subscribe(lambda x: self._create_task(update(x)))
Expand Down Expand Up @@ -165,7 +165,7 @@ async def update(building_map: BuildingMap):
def _record_door_state(self):
async def update(door_state: DoorState):
await door_state.save()
self._loggers.door_state.info(json.dumps(door_state.dict()))
self._loggers.door_state.debug(json.dumps(door_state.dict()))

self._subscriptions.append(
self.rmf.door_states.subscribe(lambda x: self._create_task(update(x)))
Expand All @@ -183,7 +183,7 @@ async def update(health: DoorHealth):
def _record_lift_state(self):
async def update(lift_state: LiftState):
await lift_state.save()
self._loggers.lift_state.info(lift_state.json())
self._loggers.lift_state.debug(lift_state.json())

self._subscriptions.append(
self.rmf.lift_states.subscribe(lambda x: self._create_task(update(x)))
Expand All @@ -201,7 +201,7 @@ async def update(health: LiftHealth):
def _record_dispenser_state(self):
async def update(dispenser_state: DispenserState):
await dispenser_state.save()
self._loggers.dispenser_state.info(dispenser_state.json())
self._loggers.dispenser_state.debug(dispenser_state.json())

self._subscriptions.append(
self.rmf.dispenser_states.subscribe(lambda x: self._create_task(update(x)))
Expand All @@ -219,7 +219,7 @@ async def update(health: DispenserHealth):
def _record_ingestor_state(self):
async def update(ingestor_state: IngestorState):
await ingestor_state.save()
self._loggers.ingestor_state.info(ingestor_state.json())
self._loggers.ingestor_state.debug(ingestor_state.json())

self._subscriptions.append(
self.rmf.ingestor_states.subscribe(lambda x: self._create_task(update(x)))
Expand Down
2 changes: 1 addition & 1 deletion packages/api-server/api_server/routes/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,4 @@ async def rmf_gateway(websocket: WebSocket):
msg: Dict[str, Any] = await websocket.receive_json()
await process_msg(msg, fleet_repo)
except WebSocketDisconnect:
pass
logger.warn("Client websocket disconnected")
1 change: 1 addition & 0 deletions packages/api-server/sqlite_local_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
"db_url": f"sqlite://{run_dir}/db.sqlite3",
"cache_directory": f"{run_dir}/cache", # The directory where cached files should be stored.
"ros_args": ["-p", "use_sim_time:=true"],
"log_level": "INFO",
}
)

0 comments on commit 3a97786

Please sign in to comment.