Skip to content

Commit

Permalink
ValidationResponse does not need state
Browse files Browse the repository at this point in the history
  • Loading branch information
Noza23 committed Jan 16, 2024
1 parent ed9cd6f commit b5b804e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 11 additions & 1 deletion backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,16 @@ async def run_validation(
myos = Myotubes.model_validate_json(
await redis.get(keys.result_key(img_hash))
)
if not myos.myo_objects:
raise HTTPException(
status_code=404,
detail="myotubes not found for the given hash.",
)

if myos[0].measure_unit != config.general_config.measure_unit:
myos.adjust_measure_unit(config.general_config.measure_unit)
await redis.set(keys.result_key(img_hash), myos.model_dump_json())

state = State.model_validate_json(
await redis.get(keys.state_key(img_hash))
)
Expand Down Expand Up @@ -159,7 +169,7 @@ async def run_validation(
redis,
)

return ValidationResponse(state=state, hash_str=img_hash, image_path=path)
return ValidationResponse(hash_str=img_hash, image_path=path)


# Validation Socket: 0 = Invalid, 1 = Valid, 2 = Skip, -1 = Undo
Expand Down
1 change: 0 additions & 1 deletion backend/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ def get_next(self) -> int:
class ValidationResponse(BaseModel):
"""Validation response."""

state: State = Field(description="validation state.")
image_hash: str = Field(description="The hash string of the image.")
image_path: str = Field(description="The path of the image.")

Expand Down

0 comments on commit b5b804e

Please sign in to comment.