Switching from RHEL 8 to RHEL 9 (#318)
* Switching from RHEL 8 to RHEL 9 * Switching from RHEL 8 to RHEL 9 * Switching from RHEL 8 to RHEL 9 * Fixing ROCPD for older Python Versions * Formatting and checking if SQRT is available or not * Formatting and checking if SQRT is available or not * Formatting and checking if SQRT is available or not * Formatting and checking if SQRT is available or not * Formatting and checking if SQRT is available or not * Update projects/rocprofiler-sdk/source/lib/python/rocpd/summary.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update summary.py * Update summary.py * Update projects/rocprofiler-sdk/source/lib/python/rocpd/summary.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update projects/rocprofiler-sdk/source/lib/python/rocpd/summary.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update summary.py * Update summary.py --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
zatwierdzone przez
GitHub
rodzic
311e279596
commit
28977999ad
@@ -25,6 +25,7 @@
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import math
|
||||
|
||||
from typing import Any, List, Tuple
|
||||
from .importer import RocpdImportData, execute_statement
|
||||
@@ -32,6 +33,28 @@ from .query import export_sqlite_query
|
||||
from . import output_config
|
||||
|
||||
|
||||
def check_function_availability(connection, function_name):
|
||||
"""
|
||||
Checks if a given function exists in the SQLite database.
|
||||
|
||||
Args:
|
||||
connection (sqlite3 db connection): The SQLite database connection handler.
|
||||
function_name (str): The name of the function to check.
|
||||
|
||||
Returns:
|
||||
bool: True if the function exists, False otherwise.
|
||||
"""
|
||||
cursor = connection.cursor()
|
||||
|
||||
# Query pragma_function_list to check for the function
|
||||
cursor.execute(
|
||||
"SELECT EXISTS(SELECT 1 FROM pragma_function_list WHERE name=?)", (function_name,)
|
||||
)
|
||||
result = cursor.fetchone()[0]
|
||||
|
||||
return bool(result)
|
||||
|
||||
|
||||
def get_temp_view_names(connection: RocpdImportData) -> List[str]:
|
||||
"""Return the names of all temporary views in the SQLite connection."""
|
||||
return [
|
||||
@@ -374,6 +397,17 @@ def generate_all_summaries(connection: RocpdImportData, **kwargs: Any) -> None:
|
||||
region_categories = kwargs.get("region_categories", None)
|
||||
output_format = kwargs.get("format", "console")
|
||||
|
||||
if not check_function_availability(connection, "sqrt"):
|
||||
connection.create_function(
|
||||
"sqrt",
|
||||
1,
|
||||
lambda x: (
|
||||
math.sqrt(x)
|
||||
if x is not None and isinstance(x, (int, float)) and x >= 0
|
||||
else None
|
||||
),
|
||||
)
|
||||
|
||||
# create the temporary summary views
|
||||
create_summary_views(connection, by_rank)
|
||||
create_summary_region_views(connection, by_rank, region_categories=region_categories)
|
||||
|
||||
Reference in New Issue
Block a user