server.web.repositories.task_template_repository ================================================ .. py:module:: server.web.repositories.task_template_repository Attributes ---------- .. autoapisummary:: server.web.repositories.task_template_repository.logger Classes ------- .. autoapisummary:: server.web.repositories.task_template_repository.ResourceUsageStatistics server.web.repositories.task_template_repository.TaskTemplateRepository Module Contents --------------- .. py:data:: logger .. py:class:: ResourceUsageStatistics Clean data class for resource usage statistics. .. py:attribute:: num_tasks :type: Optional[int] :value: None .. py:attribute:: min_mem :type: Optional[int] :value: None .. py:attribute:: max_mem :type: Optional[int] :value: None .. py:attribute:: mean_mem :type: Optional[float] :value: None .. py:attribute:: min_runtime :type: Optional[int] :value: None .. py:attribute:: max_runtime :type: Optional[int] :value: None .. py:attribute:: mean_runtime :type: Optional[float] :value: None .. py:attribute:: median_mem :type: Optional[float] :value: None .. py:attribute:: median_runtime :type: Optional[float] :value: None .. py:attribute:: ci_mem :type: Optional[List[Union[float, None]]] :value: None .. py:attribute:: ci_runtime :type: Optional[List[Union[float, None]]] :value: None .. py:attribute:: viz_data :type: Optional[List[jobmon.server.web.schemas.task_template.TaskResourceVizItem]] :value: None .. py:class:: TaskTemplateRepository(session: sqlalchemy.orm.Session) .. py:attribute:: session .. py:method:: _convert_to_task_resource_detail_item(row_data: Dict[str, Any]) -> Optional[jobmon.server.web.schemas.task_template.TaskResourceDetailItem] Convert raw database row to TaskResourceDetailItem, with error handling. .. py:method:: get_task_resource_details(task_template_version_id: int, workflows: Optional[List[int]], node_args: Optional[Dict[str, List[Any]]]) -> List[jobmon.server.web.schemas.task_template.TaskResourceDetailItem] Fetch and filter task resource details with optimized single-query approach. .. py:method:: _get_task_resource_details_with_node_args(task_template_version_id: int, workflows: Optional[List[int]], node_args: Dict[str, List[Any]], base_filters: List[sqlalchemy.sql.elements.ColumnElement], attempt_number_col: sqlalchemy.sql.elements.Label) -> List[jobmon.server.web.schemas.task_template.TaskResourceDetailItem] Optimized node_args filtering using database-level joins and filtering. .. py:method:: calculate_resource_statistics(task_details: List[jobmon.server.web.schemas.task_template.TaskResourceDetailItem], confidence_interval: Optional[str] = None, task_template_version_id: Optional[int] = None) -> ResourceUsageStatistics Calculate statistics from task details using scipy.stats. .. py:method:: get_task_template_resource_usage(req: jobmon.server.web.schemas.task_template.TaskTemplateResourceUsageRequest) -> Optional[List[jobmon.server.web.schemas.task_template.TaskResourceVizItem]] .. py:method:: _find_ttvid(workflow_id: int, task_template_id: int) -> Optional[int] Find the task template version id using workflow and task template ids. This could be slow for tt with huge nodes. However, given one workflow only us one tt version of a tt, we can search all the versions backwords to get the first none 0 version. :param workflow_id: ID of the workflow :param task_template_id: ID of the task template :param db: Database session :returns: Task template version id .. py:method:: get_task_template_details(workflow_id: int, task_template_id: int) -> Optional[jobmon.server.web.schemas.task_template.TaskTemplateDetailsResponse] Get task template details. .. py:method:: get_task_template_versions(task_id: Optional[int] = None, workflow_id: Optional[int] = None) -> Optional[jobmon.server.web.schemas.task_template.TaskTemplateVersionResponse] Get task template version IDs and names for a task or workflow. :param task_id: Optional task ID to get task template version for :param workflow_id: Optional workflow ID to get all task template versions for :returns: TaskTemplateVersionResponse with list of task template versions, or None if no data found. .. note:: If both task_id and workflow_id are provided, task_id takes precedence. .. py:method:: get_requested_cores(task_template_version_ids: List[int]) -> jobmon.server.web.schemas.task_template.RequestedCoresResponse Get the min, max, and avg of requested cores for task template versions. :param task_template_version_ids: List of task template version IDs :returns: RequestedCoresResponse with core information for each task template version .. py:method:: get_most_popular_queue(task_template_version_ids: List[int]) -> jobmon.server.web.schemas.task_template.MostPopularQueueResponse Get the most popular queue for task template versions. :param task_template_version_ids: List of task template version IDs :returns: MostPopularQueueResponse with queue information for each task template version .. py:method:: get_workflow_tt_status_viz(workflow_id: int, dialect: str = 'sqlite') -> Dict[int, jobmon.server.web.schemas.task_template.WorkflowTaskTemplateStatusItem] Get the status of workflow task templates for GUI visualization. Optimized version using single query with SQL aggregation instead of two separate queries and Python-level aggregation. :param workflow_id: ID of the workflow :param dialect: Database dialect for optimization hints :returns: Dictionary mapping task template ID to WorkflowTaskTemplateStatusItem .. py:method:: get_tt_error_log_viz(workflow_id: int, task_template_id: int, task_instance_id: Optional[int] = None, page: int = 1, page_size: int = 10, recent_errors_only: bool = False, cluster_errors: bool = False) -> jobmon.server.web.schemas.task_template.ErrorLogResponse Get error logs for a task template ID for GUI visualization. :param workflow_id: ID of the workflow :param task_template_id: ID of the task template :param task_instance_id: Optional specific task instance ID :param page: Page number for pagination :param page_size: Number of items per page :param recent_errors_only: Whether to show only recent errors :param cluster_errors: Whether to cluster similar errors :returns: ErrorLogResponse with paginated error log data