-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Baptiste O'Jeanson
committed
Aug 1, 2023
1 parent
d01856d
commit e2663fe
Showing
19 changed files
with
165 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
marker_classification_with_1_fake_camera | ||
toto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 36 additions & 24 deletions
60
edge_orchestrator/edge_orchestrator/application/trigger_routes.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,61 @@ | ||
from fastapi import APIRouter, BackgroundTasks, Depends, File, UploadFile | ||
from fastapi import APIRouter, BackgroundTasks, File, UploadFile, Depends | ||
from fastapi.responses import JSONResponse | ||
from typing_extensions import Annotated | ||
|
||
from edge_orchestrator.application.config import Settings, get_settings, get_supervisor | ||
from edge_orchestrator.application.config import ( | ||
get_supervisor, | ||
get_station_config, | ||
get_uploader, | ||
) | ||
from edge_orchestrator.domain.models.item import Item | ||
from edge_orchestrator.domain.ports.station_config import StationConfig | ||
|
||
trigger_router = APIRouter() | ||
|
||
|
||
@trigger_router.post("/trigger") | ||
async def trigger_job( | ||
settings: Annotated[Settings, Depends(get_settings)], | ||
station_config: Annotated[StationConfig, Depends(get_station_config)], | ||
image: UploadFile = None, | ||
background_tasks: BackgroundTasks = None, | ||
): | ||
item = Item.from_nothing() | ||
supervisor = get_supervisor( | ||
settings.station_configs_folder, | ||
settings.inventory_path, | ||
settings.data_folder, | ||
settings.active_config_path, | ||
) | ||
if supervisor is None: | ||
if station_config.active_config: | ||
supervisor = get_supervisor() | ||
item = Item.from_nothing() | ||
if image: | ||
contents = image.file.read() | ||
camera_id = supervisor.station_config.get_cameras()[0] | ||
item.binaries = {camera_id: contents} | ||
background_tasks.add_task(supervisor.inspect, item) | ||
return {"item_id": item.id} | ||
else: | ||
return JSONResponse( | ||
status_code=403, | ||
content={ | ||
"message": "No active configuration selected! " | ||
"Set the active station configuration before triggering the inspection." | ||
}, | ||
) | ||
else: | ||
if image: | ||
contents = image.file.read() | ||
camera_id = supervisor.station_config.get_cameras()[0] | ||
item.binaries = {camera_id: contents} | ||
background_tasks.add_task(supervisor.inspect, item) | ||
return {"item_id": item.id} | ||
|
||
|
||
@trigger_router.post("/upload") | ||
async def upload_job( | ||
image: UploadFile = File(...), background_tasks: BackgroundTasks = None | ||
station_config: Annotated[StationConfig, Depends(get_station_config)], | ||
image: UploadFile = File(...), | ||
background_tasks: BackgroundTasks = None, | ||
): | ||
item = Item.from_nothing() | ||
contents = image.file.read() | ||
item.binaries = {"0": contents} | ||
background_tasks.add_task(uploader.upload, item) | ||
return {"item_id": item.id} | ||
if station_config.active_config: | ||
uploader = get_uploader() | ||
item = Item.from_nothing() | ||
contents = image.file.read() | ||
item.binaries = {"0": contents} | ||
background_tasks.add_task(uploader.upload, item) | ||
return {"item_id": item.id} | ||
else: | ||
return JSONResponse( | ||
status_code=403, | ||
content={ | ||
"message": "No active configuration selected! " | ||
"Set the active station configuration before uploading the image." | ||
}, | ||
) |
4 changes: 1 addition & 3 deletions
4
edge_orchestrator/edge_orchestrator/domain/models/edge_station.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.