2727 ProjectNodeCreate ,
2828)
2929from simcore_postgres_database .webserver_models import ProjectType as ProjectTypeDB
30+ from yarl import URL
3031
3132from ..application_settings import get_application_settings
3233from ..catalog import catalog_service
@@ -249,7 +250,9 @@ async def _compose_project_data(
249250async def create_project ( # pylint: disable=too-many-arguments,too-many-branches,too-many-statements # noqa: C901, PLR0913
250251 progress : TaskProgress ,
251252 * ,
252- request : web .Request ,
253+ app : web .Application ,
254+ url : URL ,
255+ headers : dict [str , str ],
253256 new_project_was_hidden_before_data_was_copied : bool ,
254257 from_study : ProjectID | None ,
255258 as_template : bool ,
@@ -281,7 +284,6 @@ async def create_project( # pylint: disable=too-many-arguments,too-many-branche
281284 web.HTTPUnauthorized:
282285
283286 """
284- assert request .app # nosec
285287 _logger .info (
286288 "create_project for '%s' with %s %s %s" ,
287289 f"{ user_id = } " ,
@@ -290,7 +292,7 @@ async def create_project( # pylint: disable=too-many-arguments,too-many-branche
290292 f"{ from_study = } " ,
291293 )
292294
293- _projects_repository_legacy = ProjectDBAPI .get_from_app_context (request . app )
295+ _projects_repository_legacy = ProjectDBAPI .get_from_app_context (app )
294296
295297 new_project : ProjectDict = {}
296298 copy_file_coro = None
@@ -303,7 +305,7 @@ async def create_project( # pylint: disable=too-many-arguments,too-many-branche
303305 if predefined_project :
304306 if workspace_id := predefined_project .get ("workspaceId" , None ):
305307 await check_user_workspace_access (
306- request . app ,
308+ app ,
307309 user_id = user_id ,
308310 workspace_id = workspace_id ,
309311 product_name = product_name ,
@@ -312,7 +314,7 @@ async def create_project( # pylint: disable=too-many-arguments,too-many-branche
312314 if folder_id := predefined_project .get ("folderId" , None ):
313315 # Check user has access to folder
314316 await folders_folders_repository .get_for_user_or_workspace (
315- request . app ,
317+ app ,
316318 folder_id = folder_id ,
317319 product_name = product_name ,
318320 user_id = user_id if workspace_id is None else None ,
@@ -328,7 +330,7 @@ async def create_project( # pylint: disable=too-many-arguments,too-many-branche
328330 project_node_coro ,
329331 copy_file_coro ,
330332 ) = await _prepare_project_copy (
331- request . app ,
333+ app ,
332334 user_id = user_id ,
333335 product_name = product_name ,
334336 src_project_uuid = from_study ,
@@ -342,7 +344,7 @@ async def create_project( # pylint: disable=too-many-arguments,too-many-branche
342344 # 1.2 does project belong to some folder?
343345 workspace_id = new_project ["workspaceId" ]
344346 prj_to_folder_db = await _folders_repository .get_project_to_folder (
345- request . app ,
347+ app ,
346348 project_id = from_study ,
347349 private_workspace_user_id_or_none = (
348350 user_id if workspace_id is None else None
@@ -361,7 +363,7 @@ async def create_project( # pylint: disable=too-many-arguments,too-many-branche
361363 if predefined_project :
362364 # 2. overrides with optional body and re-validate
363365 new_project , project_nodes = await _compose_project_data (
364- request . app ,
366+ app ,
365367 user_id = user_id ,
366368 new_project = new_project ,
367369 predefined_project = predefined_project ,
@@ -378,7 +380,7 @@ async def create_project( # pylint: disable=too-many-arguments,too-many-branche
378380 )
379381 # add parent linking if needed
380382 await set_project_ancestors (
381- request . app ,
383+ app ,
382384 user_id = user_id ,
383385 project_uuid = new_project ["uuid" ],
384386 parent_project_uuid = parent_project_uuid ,
@@ -389,7 +391,7 @@ async def create_project( # pylint: disable=too-many-arguments,too-many-branche
389391 # 3.2 move project to proper folder
390392 if folder_id :
391393 await _folders_repository .insert_project_to_folder (
392- request . app ,
394+ app ,
393395 project_id = new_project ["uuid" ],
394396 folder_id = folder_id ,
395397 private_workspace_user_id_or_none = (
@@ -405,20 +407,20 @@ async def create_project( # pylint: disable=too-many-arguments,too-many-branche
405407 # 5. unhide the project if needed since it is now complete
406408 if not new_project_was_hidden_before_data_was_copied :
407409 await _projects_repository .patch_project (
408- request . app ,
410+ app ,
409411 project_uuid = new_project ["uuid" ],
410412 new_partial_project_data = {"hidden" : False },
411413 )
412414
413415 # update the network information in director-v2
414416 await dynamic_scheduler_service .update_projects_networks (
415- request . app , project_id = ProjectID (new_project ["uuid" ])
417+ app , project_id = ProjectID (new_project ["uuid" ])
416418 )
417419 await progress .update ()
418420
419421 # This is a new project and every new graph needs to be reflected in the pipeline tables
420422 await director_v2_service .create_or_update_pipeline (
421- request . app ,
423+ app ,
422424 user_id ,
423425 new_project ["uuid" ],
424426 product_name ,
@@ -433,12 +435,12 @@ async def create_project( # pylint: disable=too-many-arguments,too-many-branche
433435 user_id = user_id ,
434436 project = new_project ,
435437 is_template = as_template ,
436- app = request . app ,
438+ app = app ,
437439 )
438440 await progress .update ()
439441
440442 # Adds permalink
441- await update_or_pop_permalink_in_project (request , new_project )
443+ await update_or_pop_permalink_in_project (app , url , headers , new_project )
442444
443445 # Adds folderId
444446 user_specific_project_data_db = (
@@ -454,7 +456,7 @@ async def create_project( # pylint: disable=too-many-arguments,too-many-branche
454456 # Overwrite project access rights
455457 if workspace_id :
456458 workspace : UserWorkspaceWithAccessRights = await get_user_workspace (
457- request . app ,
459+ app ,
458460 user_id = user_id ,
459461 workspace_id = workspace_id ,
460462 product_name = product_name ,
@@ -497,7 +499,7 @@ async def create_project( # pylint: disable=too-many-arguments,too-many-branche
497499 except (ParentProjectNotFoundError , ParentNodeNotFoundError ) as exc :
498500 if project_uuid := new_project .get ("uuid" ):
499501 await _projects_service .submit_delete_project_task (
500- app = request . app ,
502+ app = app ,
501503 project_uuid = project_uuid ,
502504 user_id = user_id ,
503505 simcore_user_agent = simcore_user_agent ,
@@ -511,12 +513,13 @@ async def create_project( # pylint: disable=too-many-arguments,too-many-branche
511513 )
512514 if project_uuid := new_project .get ("uuid" ):
513515 await _projects_service .submit_delete_project_task (
514- app = request . app ,
516+ app = app ,
515517 project_uuid = project_uuid ,
516518 user_id = user_id ,
517519 simcore_user_agent = simcore_user_agent ,
518520 )
519521 raise
520522
521523
522- TaskRegistry .register (create_project )
524+ def register_create_project_task (app : web .Application ) -> None :
525+ TaskRegistry .register_partial (create_project , app = app )
0 commit comments