Пример #1
0
async def handle_patch_comparisons(
        project_id: str,
        comparison_id: str,
        comparison: projects.schemas.comparison.ComparisonUpdate,
        session: Session = Depends(database.session_scope),
        kubeflow_userid: Optional[str] = Header(database.DB_TENANT),
):
    """
    Handles PATCH requests to /<comparison_id>.

    Parameters
    ----------
    project_id : str
    comparison_id : str
    comparison : projects.schemas.comparison.ComparisonUpdate
    session : sqlalchemy.orm.session.Session
    kubeflow_userid : fastapi.Header

    Returns
    -------
    projects.schemas.comparison.Comparison
    """
    project_controller = ProjectController(session,
                                           kubeflow_userid=kubeflow_userid)
    project_controller.raise_if_project_does_not_exist(project_id)

    comparison_controller = ComparisonController(session)
    comparison = comparison_controller.update_comparison(
        comparison_id=comparison_id,
        project_id=project_id,
        comparison=comparison,
    )
    return comparison
Пример #2
0
async def handle_list_comparisons(
        project_id: str,
        session: Session = Depends(database.session_scope),
        kubeflow_userid: Optional[str] = Header(database.DB_TENANT),
):
    """
    Handles GET requests to /.

    Parameters
    ----------
    project_id : str
    session : sqlalchemy.orm.session.Session
    kubeflow_userid : fastapi.Header

    Returns
    -------
    projects.schemas.comparison.ComparisonList
    """
    project_controller = ProjectController(session,
                                           kubeflow_userid=kubeflow_userid)
    project_controller.raise_if_project_does_not_exist(project_id)

    comparison_controller = ComparisonController(session)
    comparisons = comparison_controller.list_comparisons(project_id=project_id)
    return comparisons
Пример #3
0
async def handle_patch_comparisons(project_id: str,
                                   comparison_id: str,
                                   comparison: projects.schemas.comparison.ComparisonUpdate,
                                   session: Session = Depends(session_scope)):
    """
    Handles PATCH requests to /<comparison_id>.

    Parameters
    ----------
    project_id : str
    comparison_id : str
    comparison : projects.schemas.comparison.ComparisonUpdate
    session : sqlalchemy.orm.session.Session

    Returns
    -------
    projects.schemas.comparison.Comparison
    """
    project_controller = ProjectController(session)
    project_controller.raise_if_project_does_not_exist(project_id)

    comparison_controller = ComparisonController(session)
    comparison = comparison_controller.update_comparison(
        comparison_id=comparison_id,
        project_id=project_id,
        comparison=comparison,
    )
    return comparison
Пример #4
0
async def handle_delete_comparisons(project_id: str,
                                    comparison_id: str,
                                    session: Session = Depends(session_scope)):
    """
    Handles DELETE requests to /<comparison_id>.

    Parameters
    ----------
    project_id : str
    comparison_id : str
    session : sqlalchemy.orm.session.Session

    Returns
    -------
    projects.schemas.message.Message
    """
    project_controller = ProjectController(session)
    project_controller.raise_if_project_does_not_exist(project_id)

    comparison_controller = ComparisonController(session)
    comparison = comparison_controller.delete_comparison(
        comparison_id=comparison_id,
        project_id=project_id,
    )
    return comparison
Пример #5
0
async def handle_post_comparisons(project_id: str,
                                  session: Session = Depends(session_scope)):
    """
    Handles POST requests to /.

    Parameters
    ----------
    project_id : str
    session : sqlalchemy.orm.session.Session

    Returns
    -------
    projects.schemas.comparison.Comparison
    """
    project_controller = ProjectController(session)
    project_controller.raise_if_project_does_not_exist(project_id)

    comparison_controller = ComparisonController(session)
    comparison = comparison_controller.create_comparison(project_id=project_id)
    return comparison