Skip to content
Snippets Groups Projects
Commit d9c71661 authored by Tim Repke's avatar Tim Repke
Browse files

fix mypy round2

parent 3c86151d
No related branches found
No related tags found
No related merge requests found
...@@ -29,9 +29,8 @@ async def get_all_imports_for_project(permissions: UserPermissions = Depends(Use ...@@ -29,9 +29,8 @@ async def get_all_imports_for_project(permissions: UserPermissions = Depends(Use
async def get_import_details(import_id: str, async def get_import_details(import_id: str,
permissions: UserPermissions = Depends(UserPermissionChecker('imports_read'))) \ permissions: UserPermissions = Depends(UserPermissionChecker('imports_read'))) \
-> ImportModel: -> ImportModel:
import_details = await read_import(import_id=import_id, import_details = await read_import(import_id=import_id, engine=db_engine)
engine=db_engine) if import_details is not None and str(import_details.project_id) == str(permissions.permissions.project_id):
if str(import_details.project_id) == str(permissions.permissions.project_id):
return import_details return import_details
raise InsufficientPermissions('You do not have permission to access this information.') raise InsufficientPermissions('You do not have permission to access this information.')
...@@ -59,7 +58,7 @@ async def trigger_import(import_id: str, ...@@ -59,7 +58,7 @@ async def trigger_import(import_id: str,
permissions: UserPermissions = Depends(UserPermissionChecker('imports_edit'))): permissions: UserPermissions = Depends(UserPermissionChecker('imports_edit'))):
import_details = await read_import(import_id=import_id, engine=db_engine) import_details = await read_import(import_id=import_id, engine=db_engine)
if str(import_details.project_id) == str(permissions.permissions.project_id): if import_details is not None and str(import_details.project_id) == str(permissions.permissions.project_id):
if import_details.type == ImportType.jsonl: if import_details.type == ImportType.jsonl:
await submit_jsonl_import_task(import_id=import_id, await submit_jsonl_import_task(import_id=import_id,
base_url=settings.PIPES.API_URL, base_url=settings.PIPES.API_URL,
......
...@@ -30,12 +30,16 @@ async def update_import_status(event: PipelineTaskStatusChangedEvent): ...@@ -30,12 +30,16 @@ async def update_import_status(event: PipelineTaskStatusChangedEvent):
# Seems like task was started, remember the time # Seems like task was started, remember the time
if event.status == 'RUNNING' and import_details.time_started is None: if event.status == 'RUNNING' and import_details.time_started is None:
logger.debug(f'Updating import start time for {import_details.import_id}') logger.debug( # type: ignore[unreachable]
f'Updating import start time for {import_details.import_id}'
)
import_details.time_started = datetime.now() import_details.time_started = datetime.now()
await session.commit() await session.commit()
elif (event.status == 'COMPLETED' or event.status == 'FAILED' or event.status == 'CANCELLED') \ elif (event.status == 'COMPLETED' or event.status == 'FAILED' or event.status == 'CANCELLED') \
and import_details.time_finished is None: and import_details.time_finished is None:
logger.debug(f'Updating import finish time for {import_details.import_id}') logger.debug( # type: ignore[unreachable]
f'Updating import finish time for {import_details.import_id}'
)
import_details.time_finished = datetime.now() import_details.time_finished = datetime.now()
await session.commit() await session.commit()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment