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

Merge branch 'master' into 'production'

resolve import issues

See merge request !30
parents 50c8f847 4de98529
No related branches found
No related tags found
1 merge request!30resolve import issues
Pipeline #1183 passed
...@@ -12,7 +12,10 @@ NACSOS_DB__PASSWORD="root" ...@@ -12,7 +12,10 @@ NACSOS_DB__PASSWORD="root"
NACSOS_DB__DATABASE="nacsos_core" NACSOS_DB__DATABASE="nacsos_core"
NACSOS_PIPES__API_URL="http://localhost:8000/api" NACSOS_PIPES__API_URL="http://localhost:8000/api"
NACSOS_PIPES__TOKEN="" NACSOS_PIPES__TOKEN="bfed6708-f4b6-48d9-8c81-925cd4e7f3a5"
NACSOS_PIPES__USERNAME="system"
NACSOS_PIPES__USER_ID="4138daf5-69b7-405b-b364-ccafaef25a01"
#NACSOS_PIPES__PW="kbt2t1h1t7jb1g086755bg2x8wvbmu45kqvf7g7v5vqdbmv6g0wr14akl98406g"
#NACSOS_USERS__DEFAULT_USER="user1" #NACSOS_USERS__DEFAULT_USER="user1"
NACSOS_USERS__DEFAULT_USER NACSOS_USERS__DEFAULT_USER
\ No newline at end of file
fastapi==0.92.0 fastapi==0.93.0
hypercorn==0.14.3 hypercorn==0.14.3
toml==0.10.2 toml==0.10.2
email-validator==1.3.1 email-validator==1.3.1
......
flake8==6.0.0 flake8==6.0.0
tox==4.4.6 tox==4.4.6
pytest==7.2.1 pytest==7.2.2
pytest-cov==4.0.0 pytest-cov==4.0.0
mypy==1.0.1 mypy==1.1.1
types-toml==0.10.8.5 types-toml==0.10.8.5
types-PyYAML==6.0.12.8 types-PyYAML==6.0.12.8
\ No newline at end of file
...@@ -140,9 +140,13 @@ async def get_scheme_definitions_for_project(project_id: str, ...@@ -140,9 +140,13 @@ async def get_scheme_definitions_for_project(project_id: str,
async def _construct_annotation_item(assignment: AssignmentModel, project_id: str) -> AnnotationItem: async def _construct_annotation_item(assignment: AssignmentModel, project_id: str) -> AnnotationItem:
if assignment.assignment_id is None: if assignment.assignment_id is None:
raise MissingInformationError('No `assignment_id` set for `assignment`.') raise MissingInformationError('No `assignment_id` set for `assignment`.')
scope = await read_assignment_scope(assignment_scope_id=assignment.assignment_scope_id, db_engine=db_engine) scope = await read_assignment_scope(assignment_scope_id=assignment.assignment_scope_id, db_engine=db_engine)
scheme = await read_annotation_scheme(annotation_scheme_id=assignment.annotation_scheme_id, db_engine=db_engine) if scope is None:
raise AnnotationSchemeNotFoundError(f'No annotation scope found in DB for id '
f'{assignment.assignment_scope_id}')
scheme = await read_annotation_scheme(annotation_scheme_id=assignment.annotation_scheme_id, db_engine=db_engine)
if scheme is None: if scheme is None:
raise AnnotationSchemeNotFoundError(f'No annotation scheme found in DB for id ' raise AnnotationSchemeNotFoundError(f'No annotation scheme found in DB for id '
f'{assignment.annotation_scheme_id}') f'{assignment.annotation_scheme_id}')
...@@ -153,7 +157,11 @@ async def _construct_annotation_item(assignment: AssignmentModel, project_id: st ...@@ -153,7 +157,11 @@ async def _construct_annotation_item(assignment: AssignmentModel, project_id: st
project = await read_project_by_id(project_id=project_id, engine=db_engine) project = await read_project_by_id(project_id=project_id, engine=db_engine)
if project is None: if project is None:
raise ProjectNotFoundError(f'No project found in DB for id {project_id}') raise ProjectNotFoundError(f'No project found in DB for id {project_id}')
item = await read_any_item_by_item_id(item_id=assignment.item_id, item_type=project.type, engine=db_engine) item = await read_any_item_by_item_id(item_id=assignment.item_id, item_type=project.type, engine=db_engine)
if item is None:
raise MissingInformationError(f'No item found in DB for id {assignment.item_id}')
return AnnotationItem(scheme=merged_scheme, assignment=assignment, scope=scope, item=item) return AnnotationItem(scheme=merged_scheme, assignment=assignment, scope=scope, item=item)
......
...@@ -60,6 +60,8 @@ async def trigger_import(import_id: str, ...@@ -60,6 +60,8 @@ 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)
print(import_details.__dict__)
if import_details is not None and 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:
return await submit_jsonl_import_task(import_id=import_id, return await submit_jsonl_import_task(import_id=import_id,
......
...@@ -45,7 +45,10 @@ async def get_all_user_permissions(permission=Depends(UserPermissionChecker('own ...@@ -45,7 +45,10 @@ async def get_all_user_permissions(permission=Depends(UserPermissionChecker('own
.options(selectinload(ProjectPermissions.user))) .options(selectinload(ProjectPermissions.user)))
result = (await session.execute(stmt)).scalars().all() result = (await session.execute(stmt)).scalars().all()
return [UserPermission(**{**row.__dict__, 'user': row.user.__dict__}) for row in result] return [UserPermission.parse_obj({
'user': row.user.__dict__,
**row.__dict__
}) for row in result]
@router.put('/permission', response_model=str) @router.put('/permission', response_model=str)
......
...@@ -132,6 +132,6 @@ class Settings(BaseSettings): ...@@ -132,6 +132,6 @@ class Settings(BaseSettings):
conf_file = os.environ.get('NACSOS_CONFIG', 'config/default.env') conf_file = os.environ.get('NACSOS_CONFIG', 'config/default.env')
settings = Settings(_env_file=conf_file, _env_file_encoding='utf-8') settings = Settings(_env_file=conf_file, _env_file_encoding='utf-8') # type: ignore[call-arg] # FIXME
__all__ = ['settings'] __all__ = ['settings']
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