scilens 0.3.7__py3-none-any.whl → 0.3.9__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- scilens/cli/main.py +20 -14
- scilens/components/executor.py +16 -9
- scilens/config/models/execute.py +1 -1
- scilens/config/models/reader_format_csv.py +2 -2
- scilens/config/models/reader_format_txt_fixed_cols.py +1 -1
- scilens/config/models/readers.py +8 -12
- scilens/config/models/report.py +1 -1
- scilens/config/models/report_html.py +10 -5
- scilens/processors/execute_and_compare.py +2 -2
- scilens/readers/mat_dataset.py +7 -13
- scilens/readers/reader_csv.py +33 -27
- scilens/readers/reader_txt_fixed_cols.py +68 -25
- scilens/report/html_report.py +1 -1
- scilens/report/templates/body_01_title.html +0 -12
- scilens/report/templates/body_02_tabs.html +9 -0
- scilens/report/templates/compare_11_summary.html +12 -1
- scilens/report/templates/compare_12_sections.html +6 -1
- scilens/report/templates/index.html +29 -15
- scilens/report/templates/js_chartlibs_plotly.js +44 -26
- scilens/report/templates/js_com_page.js +1 -1
- scilens/report/templates/js_curvemgr.js +61 -24
- scilens/report/templates/style.css +9 -0
- scilens/report/templates/uti_matrix.js +22 -9
- scilens/report/templates/uti_spectrograms.js +29 -20
- scilens/report/templates/utils_compare_report_anim.js +4 -1
- scilens/report/templates/utils_compare_report_framesseries.js +5 -2
- scilens/run/standalone_task_runner.py +1 -1
- scilens/utils/file.py +2 -0
- scilens/utils/load_model_from_file.py +16 -0
- {scilens-0.3.7.dist-info → scilens-0.3.9.dist-info}/METADATA +1 -1
- {scilens-0.3.7.dist-info → scilens-0.3.9.dist-info}/RECORD +33 -31
- {scilens-0.3.7.dist-info → scilens-0.3.9.dist-info}/WHEEL +0 -0
- {scilens-0.3.7.dist-info → scilens-0.3.9.dist-info}/entry_points.txt +0 -0
scilens/cli/main.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
_B='green'
|
|
2
2
|
_A=True
|
|
3
|
-
import logging,os,coloredlogs,rich_click as click
|
|
3
|
+
import logging,os,webbrowser,coloredlogs,rich_click as click
|
|
4
4
|
from scilens.app import pkg_name,pkg_version
|
|
5
5
|
from scilens.readers.reader_manager import ReaderManager
|
|
6
6
|
from scilens.run.tasks_collector import TasksCollector
|
|
@@ -52,25 +52,31 @@ def config_json():config_print('envvars')
|
|
|
52
52
|
@click.option('--export-json',is_flag=_A,help=f"Generate JSON report(s).")
|
|
53
53
|
@click.option('--export-yaml',is_flag=_A,help=f"Generate YAML report(s).")
|
|
54
54
|
@click.option('--export-html-add-index',is_flag=_A,help=f"Generate an index for generated HTML reports.")
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
@click.option('--export-html-open',is_flag=_A,help=f"Open all generated HTML reports in the default browser.")
|
|
56
|
+
def run(path,config,collect_discover,collect_depth,processor,tag,collect_only,report_title,export_html,export_json,export_yaml,export_html_add_index,export_html_open):
|
|
57
|
+
V='datetime';M=export_html_open;L=export_html_add_index;K=processor;J=collect_discover;I=config;E=collect_depth;echo_separator('Info');echo_info();echo_separator('System Info');echo_system_info();W=list(tag);B=os.path.abspath(path)
|
|
57
58
|
if not os.path.isdir(B):logging.error(f"Dir '{B}' does not exist.");exit(1)
|
|
58
59
|
if not bool(I)+J+(bool(E)or E==0)+bool(K)in[0,1]:logging.error(f"Options --config, --collect-discover, --collect-depth and --processor are mutually exclusive.");exit(1)
|
|
59
60
|
echo_separator('Collecting tasks');F=[]
|
|
60
|
-
try:F=TasksCollector(B,I,J,E,
|
|
61
|
+
try:F=TasksCollector(B,I,J,E,W,K).process(get_vars(report_title,export_html,export_json,export_yaml))
|
|
61
62
|
except Exception as D:logging.error(D);exit(1)
|
|
62
63
|
if collect_only:echo_separator();logging.info('Collecting tasks only - End');echo_separator();exit(0)
|
|
63
64
|
else:
|
|
64
|
-
|
|
65
|
-
for(
|
|
66
|
-
echo_separator(f"Running task {
|
|
67
|
-
try:C=
|
|
65
|
+
N=TimeTracker();A=len(F);O=0;P=0;Q=0;R=[]
|
|
66
|
+
for(X,Y)in enumerate(F):
|
|
67
|
+
echo_separator(f"Running task {X+1}/{A}")
|
|
68
|
+
try:C=Y.process()
|
|
68
69
|
except Exception as D:echo_task_error();logging.error(D);C=TaskResults(error=str(D))
|
|
69
|
-
if C.report_results:
|
|
70
|
-
if C.error:
|
|
70
|
+
if C.report_results:R+=C.report_results.files_created
|
|
71
|
+
if C.error:O+=1
|
|
71
72
|
G=C.processor_results
|
|
72
73
|
if G:
|
|
73
|
-
if G.warnings:
|
|
74
|
-
if G.errors:
|
|
75
|
-
if
|
|
76
|
-
|
|
74
|
+
if G.warnings:Q+=1
|
|
75
|
+
if G.errors:P+=1
|
|
76
|
+
if L or M:
|
|
77
|
+
echo_separator(f"Post Actions");S=[A for A in R if A.endswith('.html')]
|
|
78
|
+
if L:logging.info(f"Generate HTML Index for the HTML reports");T=os.path.join(B,'index.html');SearchAndIndex().create_html_index(SearchAndIndex().file_list_info_from_origin(S,B),T,title='Index of Reports');logging.info(f"HTML Index generated at '{T}'")
|
|
79
|
+
if M:
|
|
80
|
+
logging.info(f"Open HTML reports in the default browser")
|
|
81
|
+
for U in S:logging.info(f"Open '{U}'");Z=f"file://{U}";webbrowser.open(Z)
|
|
82
|
+
echo_separator(f"End Running tasks ({A}/{A})");N.stop();H=N.get_data();logging.info(f"Tasks with errors ............... {O}/{A}");logging.info(f"Tasks with processor errors ..... {P}/{A}");logging.info(f"Tasks with processor warnings ... {Q}/{A}");logging.info(f"Start ........................... {H['start'][V]} utc");logging.info(f"End ............................. {H['end'][V]} utc");logging.info(f"Duration......................... {H['duration_seconds']} seconds");echo_separator()
|
scilens/components/executor.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
_A=None
|
|
1
2
|
import logging,os,shutil,stat,subprocess,platform,tempfile,zipfile
|
|
2
3
|
from scilens.config.models import ExecuteConfig
|
|
3
4
|
from scilens.utils.file import dir_remove,dir_create
|
|
@@ -27,30 +28,36 @@ def find_command(command_path,working_dirs,guess_os_extension=False):
|
|
|
27
28
|
B=os.path.join(E,F)
|
|
28
29
|
if os.path.exists(B):return B
|
|
29
30
|
class Executor:
|
|
30
|
-
def __init__(A,absolute_working_dir,config,alternative_working_dir=
|
|
31
|
-
D=alternative_working_dir;C=absolute_working_dir;B=config;A.config=B;A.working_dir=C;A.dirs=[C]+([D]if D else[]);A.command_path=
|
|
31
|
+
def __init__(A,absolute_working_dir,config,config_file_path=_A,alternative_working_dir=_A):
|
|
32
|
+
D=alternative_working_dir;C=absolute_working_dir;B=config;A.config=B;A.config_file_path=config_file_path;A.working_dir=C;A.dirs=[C]+([D]if D else[]);A.command_path=_A;A.temp_dir=_A
|
|
32
33
|
if not bool(B.exe_url)+bool(B.exe_url)!=1:raise Exception('exe_url and exe_path are mutually exclusive.')
|
|
33
34
|
if not os.path.exists(A.working_dir):logging.info(f"Creating working directory {A.working_dir}");dir_create(A.working_dir)
|
|
34
35
|
def __enter__(A):return A
|
|
35
36
|
def __exit__(A,exc_type,exc_value,traceback):A._cleanup()
|
|
36
37
|
def _cleanup(A):0
|
|
37
38
|
def _pre_operations(A):
|
|
38
|
-
logging.info(f"Execute - Pre Operations")
|
|
39
|
-
|
|
39
|
+
D=A.working_dir;logging.info(f"Execute - Pre Operations")
|
|
40
|
+
if A.config.pre_files_delete:
|
|
41
|
+
logging.info(f"Files deletion")
|
|
42
|
+
for F in os.listdir(D):
|
|
43
|
+
E=os.path.join(D,F)
|
|
44
|
+
if not F.startswith('.')and not os.path.isdir(E)and E!=A.config_file_path:logging.debug(f"Delete file {E}");os.remove(E)
|
|
45
|
+
logging.info(f"Folders deletion")
|
|
46
|
+
for dir in A.config.pre_folder_delete or[]:dir_remove(os.path.join(D,dir))
|
|
40
47
|
logging.info(f"Folders creation")
|
|
41
|
-
for dir in A.config.pre_folder_creation or[]:dir_create(os.path.join(
|
|
48
|
+
for dir in A.config.pre_folder_creation or[]:dir_create(os.path.join(D,dir))
|
|
42
49
|
if A.config.exe_url or A.config.exe_path:
|
|
43
50
|
logging.info(f"Executable file preparation")
|
|
44
51
|
if A.config.exe_url:
|
|
45
|
-
logging.info(f"Download executable {A.config.exe_url}");A.temp_dir=tempfile.mkdtemp();
|
|
52
|
+
logging.info(f"Download executable {A.config.exe_url}");A.temp_dir=tempfile.mkdtemp();H='executable';B=os.path.join(A.temp_dir,H)
|
|
46
53
|
try:Web().download_progress(A.config.exe_url,B,headers=A.config.exe_url_headers,callback100=lambda percentage:logging.info(f"Downloaded {percentage}%"))
|
|
47
|
-
except Exception as
|
|
54
|
+
except Exception as I:raise ValueError(f"Error downloading executable: {I}")
|
|
48
55
|
logging.info(f"Download completed")
|
|
49
56
|
elif A.config.exe_path:B=A.config.exe_path
|
|
50
|
-
if A.config.exe_unzip_and_use:logging.info(f"Unzip archive");
|
|
57
|
+
if A.config.exe_unzip_and_use:logging.info(f"Unzip archive");G=os.path.dirname(B);unzip_file(B,G);B=os.path.join(G,A.config.exe_unzip_and_use);logging.info(f"Unzip completed")
|
|
51
58
|
C=find_command(B,A.dirs,guess_os_extension=A.config.exe_guess_os_extension)
|
|
52
59
|
if not C:raise FileNotFoundError(f"Command not found: {B}")
|
|
53
|
-
logging.info(f"Command path resolved: {C}");logging.info(f"Add executable permissions");
|
|
60
|
+
logging.info(f"Command path resolved: {C}");logging.info(f"Add executable permissions");J=os.stat(C).st_mode;os.chmod(C,J|stat.S_IXUSR|stat.S_IXGRP|stat.S_IXOTH)
|
|
54
61
|
elif A.config.exe_command:logging.info(f"Command path: {A.config.exe_command}");C=A.config.exe_command
|
|
55
62
|
A.command_path=C
|
|
56
63
|
def _post_operations(A):logging.info(f"Execute - Post Operations")
|
scilens/config/models/execute.py
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
_A=None
|
|
2
2
|
from pydantic import BaseModel,Field
|
|
3
|
-
class ExecuteConfig(BaseModel):pre_folder_delete:list[str]|_A=Field(default=_A,description='Liste de répertoire à supprimer avant l\'éxecution. Ex: `["DEBUG", "LOG", "OUT"]`');pre_folder_creation:list[str]|_A=Field(default=_A,description='Liste de répertoire à créeravant l\'éxecution. Ex : `["INI", "DAT"]`');exe_path:str|_A=Field(default=_A,description="Chemin de l'exécutable. Ex : `/absolute/path/executable` or `relative/path/executable`. Dans le cas, d'un chemin relatif, il testera le `working directory` et le `origin working directory` (exclusif avec `exe_url` et `exe_command`).");exe_url:str|_A=Field(default=_A,description="Url de l'exécutable à télécharger avant de l'exécuter. Ex : `https://github.com/org/app/releases/download/v3.31.5/app-2.12.2-linux-x86-64` (exclusif avec `exe_path` et `exe_command`).");exe_command:str|_A=Field(default=_A,description='Commande à exécuter sans résolution de chemin. Ex : `./app-2.12.2-linux-x86-64` ou `python3 app.py` (exclusif avec `exe_path` et `exe_url`).');exe_url_headers:dict[str,str]|_A=Field(default=_A,description='Si `exe_url` les en-têtes à ajouter à la requête de téléchargement de l\'exécutable. Ex : `{"Authorization": "Bearer token"}`');exe_unzip_and_use:str|_A=Field(default=_A,description="Si l'exécutable (`exe_path` ou `exe_url`) est zippé, alors décompresse et utilise le fichier spécifié. Ex : `app-2.12.2-linux-x86-64`");exe_guess_os_extension:bool=Field(default=False,description="Si l'exécutable (`exe_path` ou `exe_url`) n'est pas trouvée, cherche avec des extensions en fonction de l'OS. Ex : `.exe`, `.bat` pour windows");command_suffix:str|_A=Field(default=_A,description='Suffixe à ajouter à la commande. Typiquemnt des secrets. Ex : ` --token DGDFGDFGDH`');working_dir:str|_A=Field(default=_A,description="Chemin relatif du répertoire de travail pour l'éxecution de la commande. Dans le contexte processeur `ExecuteAndCompare` si non défini, récupère respectivement la valeur de `compare.sources.test_folder_relative_path` ou `compare.sources.reference_folder_relative_path`")
|
|
3
|
+
class ExecuteConfig(BaseModel):pre_files_delete:bool=Field(default=False,description="Si `true`, supprime les fichiers avant l'éxecution. (le fichier de configuration et les fichiers . ne seront pas supprimés)");pre_folder_delete:list[str]|_A=Field(default=_A,description='Liste de répertoire à supprimer avant l\'éxecution. Ex: `["DEBUG", "LOG", "OUT"]`');pre_folder_creation:list[str]|_A=Field(default=_A,description='Liste de répertoire à créeravant l\'éxecution. Ex : `["INI", "DAT"]`');exe_path:str|_A=Field(default=_A,description="Chemin de l'exécutable. Ex : `/absolute/path/executable` or `relative/path/executable`. Dans le cas, d'un chemin relatif, il testera le `working directory` et le `origin working directory` (exclusif avec `exe_url` et `exe_command`).");exe_url:str|_A=Field(default=_A,description="Url de l'exécutable à télécharger avant de l'exécuter. Ex : `https://github.com/org/app/releases/download/v3.31.5/app-2.12.2-linux-x86-64` (exclusif avec `exe_path` et `exe_command`).");exe_command:str|_A=Field(default=_A,description='Commande à exécuter sans résolution de chemin. Ex : `./app-2.12.2-linux-x86-64` ou `python3 app.py` (exclusif avec `exe_path` et `exe_url`).');exe_url_headers:dict[str,str]|_A=Field(default=_A,description='Si `exe_url` les en-têtes à ajouter à la requête de téléchargement de l\'exécutable. Ex : `{"Authorization": "Bearer token"}`');exe_unzip_and_use:str|_A=Field(default=_A,description="Si l'exécutable (`exe_path` ou `exe_url`) est zippé, alors décompresse et utilise le fichier spécifié. Ex : `app-2.12.2-linux-x86-64`");exe_guess_os_extension:bool=Field(default=False,description="Si l'exécutable (`exe_path` ou `exe_url`) n'est pas trouvée, cherche avec des extensions en fonction de l'OS. Ex : `.exe`, `.bat` pour windows");command_suffix:str|_A=Field(default=_A,description='Suffixe à ajouter à la commande. Typiquemnt des secrets. Ex : ` --token DGDFGDFGDH`');working_dir:str|_A=Field(default=_A,description="Chemin relatif du répertoire de travail pour l'éxecution de la commande. Dans le contexte processeur `ExecuteAndCompare` si non défini, récupère respectivement la valeur de `compare.sources.test_folder_relative_path` ou `compare.sources.reference_folder_relative_path`")
|
|
@@ -2,5 +2,5 @@ _B=False
|
|
|
2
2
|
_A=None
|
|
3
3
|
from pydantic import BaseModel,Field
|
|
4
4
|
from scilens.config.models.reader_format_cols_curve import ReaderColsCurveParserConfig
|
|
5
|
-
class ReaderCsvMatrixConfig(BaseModel):x_value_line:int|_A=Field(default=_A,description="Indique la ligne des valeurs x si applicable. Peut être la ligne d'en-tête (=1).");has_y:bool=Field(default=_B,description='Indique si la première colonne est la colonne des valeurs y.');
|
|
6
|
-
class ReaderCsvConfig(BaseModel):delimiter:str|_A=Field(default=',',description='Délimiteur de colonnes.');quotechar:str|_A=Field(default='"',description='Délimiteur de texte.');has_header:bool|_A=Field(default=_A,description="Indique si la 1ère ligne est une ligne d'en-tête. Si non spécifié, il y aura une détection automatique.");is_matrix:bool=Field(default=_B,description='Indique si le fichier est une matrice.');ignore_columns:list[str]|_A=Field(default=_A,description='Liste des noms des colonnes à ignorer. (Valide seulement si la première ligne est une ligne en-têtes et non matrice)');curve_parser:ReaderColsCurveParserConfig|_A=Field(default=_A,description='Parseur de courbe à utiliser.');matrix:ReaderCsvMatrixConfig|_A=Field(default=_A,description='Configuration de la matrice. (Valide seulement si `is_matrix` est vrai)')
|
|
5
|
+
class ReaderCsvMatrixConfig(BaseModel):x_value_line:int|_A=Field(default=_A,description="Indique la ligne des valeurs x si applicable. Peut être la ligne d'en-tête (=1).");has_y:bool=Field(default=_B,description='Indique si la première colonne est la colonne des valeurs y.');x_name:str=Field(default='X',description='Nom de la colonne des valeurs x.');y_name:str=Field(default='Y',description='Nom de la colonne des valeurs y.');export_report:bool=Field(default=_B,description='Indique si les matrices doivent être exportées dans les rapports.')
|
|
6
|
+
class ReaderCsvConfig(BaseModel):delimiter:str|_A=Field(default=',',description='Délimiteur de colonnes.');quotechar:str|_A=Field(default='"',description='Délimiteur de texte.');has_header:bool|_A=Field(default=_A,description="Indique si la 1ère ligne est une ligne d'en-tête. Si non spécifié, il y aura une détection automatique.");is_matrix:bool=Field(default=_B,description='Indique si le fichier est une matrice.');ignore_columns:list[str]|_A=Field(default=_A,description='Liste des noms des colonnes à ignorer. (Valide seulement si la première ligne est une ligne en-têtes et non matrice)');curve_parser:ReaderColsCurveParserConfig|_A=Field(default=_A,description='Parseur de courbe à utiliser.');ignore_lines_patterns:list[str]|_A=Field(default=_A,description='Liste des patterns de lignes à ignorer. Ex: ["^#", "^//"]. Non applicable si `is_matrix` est vrai.');matrix:ReaderCsvMatrixConfig|_A=Field(default=_A,description='Configuration de la matrice. (Valide seulement si `is_matrix` est vrai)')
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
_A=None
|
|
2
2
|
from pydantic import BaseModel,Field
|
|
3
3
|
from scilens.config.models.reader_format_cols_curve import ReaderColsCurveParserConfig
|
|
4
|
-
class ReaderTxtFixedColsConfig(BaseModel):ignore_lines_patterns:list[str]|_A=Field(default=_A,description='Liste des patterns de lignes à ignorer. Ex: ["^#", "^//"].');has_header:bool=Field(default=False,description="Indique si le dataset contient une ligne d'entête.");
|
|
4
|
+
class ReaderTxtFixedColsConfig(BaseModel):ignore_lines_patterns:list[str]|_A=Field(default=_A,description='Liste des patterns de lignes à ignorer. Ex: ["^#", "^//"].');has_header:bool=Field(default=False,description="Indique si le dataset contient une ligne d'entête.");has_header_line:int|_A=Field(default=_A,description="Numéro de la ligne d'entête. Si None, la première ligne non ignorée est considérée comme l'entête.");has_header_ignore:list[str]|_A=Field(default=_A,description="Chaînes de caractères à ignorer dans la ligne d'entête. eex: ['##', '|'].");column_widths:list[int]|_A=Field(default=_A,description='Liste des largeurs de colonnes. Ex: [9, 13, 12]. Exclusif avec `column_indexes`.');column_indexes:list[tuple[int,int]]|_A=Field(default=_A,description='Liste des index de début et fin de colonnes. Ex: [[0, 8], [9, 12], [13, 28]]. Exclusif avec `column_widths`.');curve_parser:ReaderColsCurveParserConfig|_A=Field(default=_A,description='Parseur de courbe à utiliser.')
|
scilens/config/models/readers.py
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
_B='netcdf'
|
|
2
|
-
_A='txt_fixed_cols'
|
|
3
1
|
from typing import Literal
|
|
4
|
-
from pydantic import BaseModel,Field
|
|
2
|
+
from pydantic import BaseModel,Field
|
|
5
3
|
from scilens.config.models.reader_format_txt import ReaderTxtConfig
|
|
6
4
|
from scilens.config.models.reader_format_csv import ReaderCsvConfig
|
|
7
5
|
from scilens.config.models.reader_format_txt_fixed_cols import ReaderTxtFixedColsConfig
|
|
8
6
|
from scilens.config.models.reader_format_netcdf import ReaderNetcdfConfig
|
|
9
|
-
|
|
10
|
-
class
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return A
|
|
17
|
-
class ReadersConfig(BaseModel):txt:ReaderTxtConfig=Field(default=ReaderTxtConfig(),description='Configuration des readers txt.');csv:ReaderCsvConfig=Field(default=ReaderCsvConfig(),description='Configuration des readers csv.');txt_fixed_cols:ReaderTxtFixedColsConfig=Field(default=ReaderTxtFixedColsConfig(),description='Configuration des readers txt avec colonnes fixes.');netcdf:ReaderNetcdfConfig=Field(default=ReaderNetcdfConfig(),description='Configuration des readers NetCDF.');catalog:dict[str,ReaderConfig]|None=Field(default=None,description="Catalogue de configuration de readers par clé. Ex: `{'csv_comma': {'type': 'csv', 'parameters': {'delimiter': ','}}, 'csv_semicolon': {'type': 'csv', 'parameters': {'delimiter': ';'}}}`")
|
|
7
|
+
class BaseCatalogItem(BaseModel):type:str
|
|
8
|
+
class ReaderTxtConfigItem(BaseCatalogItem):type:Literal['txt'];parameters:ReaderTxtConfig
|
|
9
|
+
class ReaderCsvConfigItem(BaseCatalogItem):type:Literal['csv'];parameters:ReaderCsvConfig
|
|
10
|
+
class ReaderTxtFixedColsConfigItem(BaseCatalogItem):type:Literal['txt_fixed_cols'];parameters:ReaderTxtFixedColsConfig
|
|
11
|
+
class ReaderNetcdfConfigItem(BaseCatalogItem):type:Literal['netcdf'];parameters:ReaderNetcdfConfig
|
|
12
|
+
CATALOG_ITEM_TYPE=ReaderTxtConfigItem|ReaderCsvConfigItem|ReaderTxtFixedColsConfigItem|ReaderNetcdfConfigItem
|
|
13
|
+
class ReadersConfig(BaseModel):txt:ReaderTxtConfig=Field(default=ReaderTxtConfig(),description='Configuration des readers txt.');csv:ReaderCsvConfig=Field(default=ReaderCsvConfig(),description='Configuration des readers csv.');txt_fixed_cols:ReaderTxtFixedColsConfig=Field(default=ReaderTxtFixedColsConfig(),description='Configuration des readers txt avec colonnes fixes.');netcdf:ReaderNetcdfConfig=Field(default=ReaderNetcdfConfig(),description='Configuration des readers NetCDF.');catalog:dict[str,CATALOG_ITEM_TYPE]|None=Field(default=None,description="Catalogue de configuration de readers par clé. Ex: `{'csv_comma': {'type': 'csv', 'parameters': {'delimiter': ','}}, 'csv_semicolon': {'type': 'csv', 'parameters': {'delimiter': ';'}}}`")
|
scilens/config/models/report.py
CHANGED
|
@@ -3,4 +3,4 @@ from pydantic import BaseModel,Field
|
|
|
3
3
|
from scilens.app import product_name
|
|
4
4
|
from scilens.config.models.report_html import ReportHtmlConfig
|
|
5
5
|
from scilens.config.models.report_output import ReportOutputConfig
|
|
6
|
-
class ReportConfig(BaseModel):debug:bool=Field(default=False,description='If `true` the report will be more verbose and displays template input data.');title:str=Field(default=_A,description='Titre du rapport');title_prefix:str=Field(default=f"{product_name} Report",description='Préfixe au Titre du rapport');logo:str|_A=Field(default=_A,description="Source d'une image logo. Peut être une url ou une url data image encodée base64 (exclusif avec `logo_file`).");logo_file:str|_A=Field(default=_A,description="Source fichier d'une image logo (exclusif avec `logo`).");output:ReportOutputConfig=ReportOutputConfig();html:ReportHtmlConfig=ReportHtmlConfig()
|
|
6
|
+
class ReportConfig(BaseModel):debug:bool=Field(default=False,description='If `true` the report will be more verbose and displays template input data.');title:str=Field(default=_A,description='Titre du rapport');title_prefix:str=Field(default=f"{product_name} Report",description='Préfixe au Titre du rapport');description:str|_A=Field(default=_A,description='Description inclu dans une section spécifique description des rapports');logo:str|_A=Field(default=_A,description="Source d'une image logo. Peut être une url ou une url data image encodée base64 (exclusif avec `logo_file`).");logo_file:str|_A=Field(default=_A,description="Source fichier d'une image logo (exclusif avec `logo`).");output:ReportOutputConfig=ReportOutputConfig();html:ReportHtmlConfig=ReportHtmlConfig()
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
_D="Paramètre modifiable par l'utilisateur"
|
|
2
|
+
_C=False
|
|
3
|
+
_B=True
|
|
4
|
+
_A=None
|
|
2
5
|
from pydantic import BaseModel,Field
|
|
3
|
-
class ReportParameterPageModeConfig(BaseModel):is_user_preference:bool=Field(default=
|
|
4
|
-
class ReportParameterOpenFileInConfig(BaseModel):is_user_preference:bool=Field(default=
|
|
5
|
-
class ReportHtmlCurvesConfig(BaseModel):display_on_load:bool=Field(default=
|
|
6
|
-
class
|
|
6
|
+
class ReportParameterPageModeConfig(BaseModel):is_user_preference:bool=Field(default=_B,description=_D);default_value:str=Field(default='onepage',description='`tabs` ou `onepage`')
|
|
7
|
+
class ReportParameterOpenFileInConfig(BaseModel):is_user_preference:bool=Field(default=_B,description=_D);default_value:str=Field(default='browser',description='`browser` ou `vscode`')
|
|
8
|
+
class ReportHtmlCurvesConfig(BaseModel):display_on_load:bool=Field(default=_C,description="Si `true`, affiche tous les graphiques courbes à l'ouverture du rapport.");init_width:int=Field(default=600,description='Largeur initiale des graphiques courbes.');init_height:int=Field(default=400,description='Hauteur initiale des graphiques courbes.');compare_vs_values:bool=Field(default=_B,description='Dans le chart de comparaison, affiche les valeurs de référence et de test.');compare_vs_difference:bool=Field(default=_C,description='Dans le chart de comparaison, affiche la différence entre les valeurs de référence et de test.')
|
|
9
|
+
class ReportHtmlSpectrogramsConfig(BaseModel):test_ref:bool=Field(default=_B,description='Indique si les spectrogrammes de test doivent être affichés.');differences:bool=Field(default=_B,description='Indique si les spectrogrammes de différence doivent être affichés.');init_width:int=Field(default=300,description='Largeur initiale des spectrogrammes.');init_height:int=Field(default=300,description='Hauteur initiale des spectrogrammes.')
|
|
10
|
+
class ReportHtmlMatrixConfig(BaseModel):spectrograms:ReportHtmlSpectrogramsConfig|_A=_A;frameseries:bool=Field(default=_C,description='Indique si les matrices doivent être affichées en mode frameseries.')
|
|
11
|
+
class ReportHtmlConfig(BaseModel):custom_style:str|_A=Field(default=_A,description='CSS personnalisé.');custom_script_head:str|_A=Field(default=_A,description='Script personnalisé dans le `<head>`.');custom_script_body:str|_A=Field(default=_A,description='Script personnalisé en fin de `<body>`.');extra_html_start:str|_A=Field(default=_A,description='HTML personnalisé en début de rapport.');extra_html_summary:str|_A=Field(default=_A,description='HTML personnalisé dans la section `Summary`.');extra_html_end:str|_A=Field(default=_A,description='HTML personnalisé en fin de rapport.');logo_height:int=Field(default=40,description='Hauteur du logo dans le titre.');compare_color_test:str=Field(default='1982c4',description='Couleur pour les données de test.');compare_color_reference:str=Field(default='6a4c93',description='Couleur pour les données de référence.');collapse_if_successful:bool=Field(default=_B,description="N'affiche par défaut les sections de comparaison sans erreur.");parameter_page_mode:ReportParameterPageModeConfig=ReportParameterPageModeConfig();parameter_open_file_in:ReportParameterOpenFileInConfig=ReportParameterOpenFileInConfig();curves:ReportHtmlCurvesConfig=ReportHtmlCurvesConfig();matrix:ReportHtmlMatrixConfig=ReportHtmlMatrixConfig()
|
|
@@ -11,7 +11,7 @@ class ExecuteAndCompare:
|
|
|
11
11
|
if not F.test_only:G.append({I:'reference',J:N,B:F.reference})
|
|
12
12
|
for A in G:
|
|
13
13
|
if not A[B]:C=D
|
|
14
|
-
else:C=ExecuteConfig();C.pre_folder_delete=A[B].pre_folder_delete or D.pre_folder_delete;C.pre_folder_creation=A[B].pre_folder_creation or D.pre_folder_creation;C.exe_path=A[B].exe_path or D.exe_path;C.exe_url=A[B].exe_url or D.exe_url;C.exe_command=A[B].exe_command or D.exe_command;C.exe_url_headers=A[B].exe_url_headers or D.exe_url_headers;C.exe_unzip_and_use=A[B].exe_unzip_and_use or D.exe_unzip_and_use;C.exe_guess_os_extension=A[B].exe_guess_os_extension or D.exe_guess_os_extension;C.command_suffix=A[B].command_suffix or D.command_suffix
|
|
14
|
+
else:C=ExecuteConfig();C.pre_files_delete=A[B].pre_files_delete or D.pre_files_delete;C.pre_folder_delete=A[B].pre_folder_delete or D.pre_folder_delete;C.pre_folder_creation=A[B].pre_folder_creation or D.pre_folder_creation;C.exe_path=A[B].exe_path or D.exe_path;C.exe_url=A[B].exe_url or D.exe_url;C.exe_command=A[B].exe_command or D.exe_command;C.exe_url_headers=A[B].exe_url_headers or D.exe_url_headers;C.exe_unzip_and_use=A[B].exe_unzip_and_use or D.exe_unzip_and_use;C.exe_guess_os_extension=A[B].exe_guess_os_extension or D.exe_guess_os_extension;C.command_suffix=A[B].command_suffix or D.command_suffix
|
|
15
15
|
logging.info(f"Execute {A[I]} Command")
|
|
16
|
-
with Executor(A[J],C,alternative_working_dir=E.context.origin_working_dir)as O:O.process()
|
|
16
|
+
with Executor(A[J],C,E.context.config_file,alternative_working_dir=E.context.origin_working_dir)as O:O.process()
|
|
17
17
|
G=E.compare_folders.compute_list_filenames();logging.info(f"Number files to compare: {len(G)}");K=E.compare_folders.compute_comparison(G);H.warnings=[A[L]for A in K if A.get(L)];H.data=K;return H
|
scilens/readers/mat_dataset.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
_B=False
|
|
2
1
|
_A=None
|
|
3
2
|
import csv
|
|
4
3
|
from collections.abc import Iterator
|
|
@@ -6,8 +5,8 @@ from dataclasses import dataclass,field,asdict
|
|
|
6
5
|
from scilens.components.compare_models import CompareGroup
|
|
7
6
|
from scilens.components.compare_floats import CompareFloats
|
|
8
7
|
@dataclass
|
|
9
|
-
class MatDataset:nb_lines:int=0;nb_columns:int=0;data:list[list[float]]=field(default_factory=lambda:[]);x_values:list[float]|_A=_A;y_values:list[float]|_A=_A
|
|
10
|
-
def
|
|
8
|
+
class MatDataset:x_name:str;y_name:str;nb_lines:int=0;nb_columns:int=0;data:list[list[float]]=field(default_factory=lambda:[]);x_values:list[float]|_A=_A;y_values:list[float]|_A=_A
|
|
9
|
+
def from_iterator(x_name,y_name,reader,x_value_line=_A,has_header=False,has_y=False):
|
|
11
10
|
E=has_y;D=x_value_line;B=reader;H=_A;I=[]if E else _A;A=[];F=0
|
|
12
11
|
if D:
|
|
13
12
|
J=1 if E else 0
|
|
@@ -19,14 +18,9 @@ def from_reader(reader,x_value_line=_A,has_header=_B,has_y=_B):
|
|
|
19
18
|
for C in B:L=float(C[0]);G=[float(A)for A in C[1:]];I.append(L);A.append(G)
|
|
20
19
|
else:
|
|
21
20
|
for C in B:G=[float(A)for A in C];A.append(G)
|
|
22
|
-
return MatDataset(nb_lines=len(A),nb_columns=len(A[0])if len(A)>0 else 0,data=A,x_values=H,y_values=I)
|
|
21
|
+
return MatDataset(x_name=x_name,y_name=y_name,nb_lines=len(A),nb_columns=len(A[0])if len(A)>0 else 0,data=A,x_values=H,y_values=I)
|
|
23
22
|
def compare(parent_group,compare_floats,test,ref,group_name=''):B=parent_group;A=test;D,C,E=compare_floats.add_group_and_compare_matrices(group_name,B,group_data=_A,test_mat=A.data,ref_mat=ref.data,x_vector=A.x_values,y_vector=A.y_values);B.error='Errors limit reached'if C else _A
|
|
24
|
-
def get_data(datasets,names,
|
|
25
|
-
|
|
26
|
-
if len(
|
|
27
|
-
|
|
28
|
-
if display_spectrograms:A['spectrograms']={E:1}
|
|
29
|
-
if display_frameseries:
|
|
30
|
-
A[F]={E:1}
|
|
31
|
-
if D:A[F]['steps']={'name':frameseries_steps_name,'data':D}
|
|
32
|
-
return A
|
|
23
|
+
def get_data(datasets,names,frameseries_steps_data=_A,frameseries_steps_name=_A):
|
|
24
|
+
B=names;A=datasets
|
|
25
|
+
if len(A)!=len(B):raise ValueError('Datasets and names must have the same length')
|
|
26
|
+
C={'datasets':[asdict(A)for A in A],'names':B};return C
|
scilens/readers/reader_csv.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
_A=None
|
|
2
|
-
import logging,csv
|
|
2
|
+
import logging,csv,re
|
|
3
3
|
from scilens.readers.reader_interface import ReaderInterface
|
|
4
4
|
from scilens.readers.cols_dataset import ColsDataset,ColsCurves,cols_dataset_get_curves_col_x,compare as cols_compare
|
|
5
|
-
from scilens.readers.mat_dataset import MatDataset,
|
|
5
|
+
from scilens.readers.mat_dataset import MatDataset,from_iterator as mat_from_iterator,compare as mat_compare,get_data
|
|
6
6
|
from scilens.config.models.reader_format_csv import ReaderCsvConfig,ReaderCsvMatrixConfig
|
|
7
7
|
from scilens.config.models.reader_format_cols_curve import ReaderCurveParserNameConfig
|
|
8
8
|
from scilens.components.compare_models import CompareGroup
|
|
@@ -20,31 +20,37 @@ def csv_detect(path,delimiter,quotechar,encoding):
|
|
|
20
20
|
class ReaderCsv(ReaderInterface):
|
|
21
21
|
configuration_type_code='csv';category='datalines';extensions=['CSV']
|
|
22
22
|
def read(A,reader_options):
|
|
23
|
-
B=reader_options;A.reader_options=B;A.raw_lines_number=_A;A.curves=_A;A.report_matrices=_A;D,F,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
H
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
23
|
+
B=reader_options;A.reader_options=B;J=B.ignore_lines_patterns;A.raw_lines_number=_A;A.curves=_A;A.report_matrices=_A;D,F,P=csv_detect(A.origin.path,A.reader_options.delimiter,A.reader_options.quotechar,encoding=A.encoding);A.has_header=D;A.cols=F;A.numeric_col_indexes=P
|
|
24
|
+
with open(A.origin.path,'r',encoding=A.encoding)as Q:
|
|
25
|
+
K=Q.readlines();L=csv.reader(K,delimiter=A.reader_options.delimiter,quotechar=A.reader_options.quotechar)
|
|
26
|
+
if B.is_matrix:
|
|
27
|
+
E=B.matrix or ReaderCsvMatrixConfig();G=mat_from_iterator(x_name=E.x_name,y_name=E.y_name,reader=L,has_header=D,x_value_line=E.x_value_line,has_y=E.has_y)
|
|
28
|
+
if E.export_report:A.report_matrices=get_data([G],['csv'])
|
|
29
|
+
A.mat_dataset=G;A.raw_lines_number=G.nb_lines+(1 if D else 0)
|
|
30
|
+
else:
|
|
31
|
+
if B.ignore_columns:
|
|
32
|
+
if not D:raise Exception('Ignore columns is not supported without header.')
|
|
33
|
+
A.numeric_col_indexes=[C for C in A.numeric_col_indexes if A.cols[C]not in B.ignore_columns]
|
|
34
|
+
M=len(F);C=ColsDataset(cols_count=M,names=F,numeric_col_indexes=A.numeric_col_indexes,data=[[]for A in range(M)]);H=0
|
|
35
|
+
for(R,S)in zip(K,L):
|
|
36
|
+
H+=1
|
|
37
|
+
if D and H==1:continue
|
|
38
|
+
if J:
|
|
39
|
+
N=False
|
|
40
|
+
for T in J:
|
|
41
|
+
if bool(re.match(T,R)):N=True;break
|
|
42
|
+
if N:continue
|
|
43
|
+
for(O,I)in enumerate(S):
|
|
44
|
+
if O in C.numeric_col_indexes:I=float(I)
|
|
45
|
+
C.data[O].append(I)
|
|
46
|
+
C.origin_line_nb.append(H)
|
|
47
|
+
C.rows_count=len(C.origin_line_nb);A.cols_dataset=C;A.raw_lines_number=C.rows_count+(1 if D else 0)
|
|
48
|
+
if B.curve_parser:
|
|
49
|
+
if B.curve_parser.name==ReaderCurveParserNameConfig.COL_X:
|
|
50
|
+
A.curves,U=cols_dataset_get_curves_col_x(C,B.curve_parser.parameters.x)
|
|
51
|
+
if A.curves:A.cols_curve=ColsCurves(type=ReaderCurveParserNameConfig.COL_X,info=U,curves=A.curves)
|
|
52
|
+
elif B.curve_parser.name==ReaderCurveParserNameConfig.COLS_COUPLE:raise NotImplementedError('cols_couple not implemented')
|
|
53
|
+
else:raise Exception('Curve parser not supported.')
|
|
48
54
|
def compare(A,compare_floats,param_reader,param_is_ref=True):
|
|
49
55
|
H='node';D=param_is_ref;C=param_reader;B=compare_floats;I=A.reader_options
|
|
50
56
|
if I.is_matrix:E=A.mat_dataset if D else C.mat_dataset;F=A.mat_dataset if not D else C.mat_dataset;J,G=B.compare_errors.add_group(H,'csv matrix');mat_compare(G,B,E,F)
|
|
@@ -1,38 +1,81 @@
|
|
|
1
|
+
_A=None
|
|
1
2
|
import logging,re
|
|
3
|
+
from dataclasses import dataclass
|
|
2
4
|
from scilens.readers.transform import string_2_float
|
|
3
5
|
from scilens.readers.reader_interface import ReaderInterface
|
|
4
6
|
from scilens.readers.cols_dataset import ColsDataset,ColsCurves,cols_dataset_get_curves_col_x,compare
|
|
5
7
|
from scilens.config.models import ReaderTxtFixedColsConfig
|
|
6
8
|
from scilens.config.models.reader_format_cols_curve import ReaderCurveParserNameConfig
|
|
7
9
|
from scilens.components.compare_floats import CompareFloats
|
|
10
|
+
@dataclass
|
|
11
|
+
class ParsedHeaders:raw:str;cleaned:str;data:list[str];ori_line_idx:int|_A=_A
|
|
8
12
|
class ReaderTxtFixedCols(ReaderInterface):
|
|
9
13
|
configuration_type_code='txt_fixed_cols';category='datalines';extensions=[]
|
|
10
|
-
def
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
def _ignore_line(A,line):
|
|
15
|
+
if not line.strip():return True
|
|
16
|
+
if A.reader_options.ignore_lines_patterns:
|
|
17
|
+
for B in A.reader_options.ignore_lines_patterns:
|
|
18
|
+
if bool(re.match(B,line)):return True
|
|
19
|
+
return False
|
|
20
|
+
def _get_parsed_headers(A,path):
|
|
21
|
+
B=A.reader_options;C=_A
|
|
22
|
+
with open(A.origin.path,'r',encoding=A.encoding)as G:
|
|
23
|
+
D=-1
|
|
24
|
+
if B.has_header_line is not _A:
|
|
25
|
+
for E in G:
|
|
26
|
+
D+=1
|
|
27
|
+
if D+1==B.has_header_line:C=E;break
|
|
28
|
+
else:
|
|
29
|
+
for E in G:
|
|
30
|
+
D+=1
|
|
31
|
+
if not A._ignore_line(E):C=E;break
|
|
32
|
+
if C:
|
|
33
|
+
H=C.strip();F=H
|
|
34
|
+
if B.has_header_ignore:
|
|
35
|
+
for I in B.has_header_ignore:F=F.replace(I,'')
|
|
36
|
+
return ParsedHeaders(raw=H,cleaned=F,data=F.split(),ori_line_idx=D)
|
|
37
|
+
def _get_first_data_line(A,path):
|
|
38
|
+
D=A.reader_options;B=D.has_header
|
|
39
|
+
with open(A.origin.path,'r',encoding=A.encoding)as E:
|
|
40
|
+
for C in E:
|
|
41
|
+
if not A._ignore_line(C):
|
|
42
|
+
if B:B=False;continue
|
|
43
|
+
else:return C
|
|
44
|
+
def _discover_col_idx_ralgin_spaces(G,line):
|
|
45
|
+
A=line;A=A.rstrip();C=[];D=_A;B=0
|
|
46
|
+
for(E,F)in enumerate(A):
|
|
47
|
+
if D is not _A and D!=' 'and F==' ':C.append((B,E));B=E
|
|
48
|
+
D=F
|
|
49
|
+
if B<len(A):C.append((B,len(A)))
|
|
50
|
+
return C
|
|
51
|
+
def _derive_col_indexes(A,header_row=_A):0
|
|
52
|
+
def read(A,reader_options):
|
|
53
|
+
B=reader_options;A.reader_options=B;E=A._get_parsed_headers(A.origin.path)if B.has_header else _A;I=open(A.origin.path,'r',encoding=A.encoding);C=[]
|
|
54
|
+
if B.column_indexes or B.column_widths:
|
|
55
|
+
if B.column_indexes and B.column_widths:raise Exception('column_indexes and column_widths are exclusive.')
|
|
56
|
+
if B.column_widths:
|
|
57
|
+
logging.debug(f"Using column widths: {B.column_widths}");H=0
|
|
58
|
+
for J in B.column_widths:C+=[(H,H+J)];H+=J
|
|
59
|
+
else:logging.debug(f"Using column indexes: {B.column_indexes}");C=B.column_indexes
|
|
60
|
+
else:logging.debug(f"Using auto derived column indexes.");M=A._get_first_data_line(A.origin.path);C=A._discover_col_idx_ralgin_spaces(M)
|
|
61
|
+
logging.debug(f"Column indexes: {C}")
|
|
62
|
+
if not C:raise Exception('No column indexes or widths provided, and no headers found to derive column indexes.')
|
|
63
|
+
F=len(C);D=ColsDataset(cols_count=F,names=[f"Column {A+1}"for A in range(F)],numeric_col_indexes=[A for A in range(F)],data=[[]for A in range(F)])
|
|
64
|
+
if E:D.names=E.data
|
|
65
|
+
G=0
|
|
66
|
+
for K in I:
|
|
13
67
|
G+=1
|
|
14
|
-
if
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
elif A.has_header_repetition and F==D.strip():continue
|
|
26
|
-
if not D.strip():continue
|
|
27
|
-
I=0;N=0
|
|
28
|
-
for O in K:R=D[I:I+O].strip();S=string_2_float(R);C.data[N].append(S);I+=O;N+=1
|
|
29
|
-
C.origin_line_nb.append(G)
|
|
30
|
-
C.rows_count=len(C.origin_line_nb);J.close();B.cols_dataset=C;B.raw_lines_number=G;B.curves=None
|
|
31
|
-
if A.curve_parser:
|
|
32
|
-
if A.curve_parser.name==ReaderCurveParserNameConfig.COL_X:
|
|
33
|
-
B.curves,T=cols_dataset_get_curves_col_x(C,A.curve_parser.parameters.x)
|
|
34
|
-
if B.curves:B.cols_curve=ColsCurves(type=ReaderCurveParserNameConfig.COL_X,info=T,curves=B.curves)
|
|
35
|
-
elif A.curve_parser.name==ReaderCurveParserNameConfig.COLS_COUPLE:raise NotImplementedError('cols_couple not implemented')
|
|
68
|
+
if A._ignore_line(K):continue
|
|
69
|
+
if E:
|
|
70
|
+
if E.ori_line_idx==G-1:continue
|
|
71
|
+
for(N,L)in enumerate(C):O=K[L[0]:L[1]].strip();P=string_2_float(O);D.data[N].append(P)
|
|
72
|
+
D.origin_line_nb.append(G)
|
|
73
|
+
D.rows_count=len(D.origin_line_nb);I.close();A.cols_dataset=D;A.raw_lines_number=G;A.curves=_A;A.cols_curve=_A
|
|
74
|
+
if B.curve_parser:
|
|
75
|
+
if B.curve_parser.name==ReaderCurveParserNameConfig.COL_X:
|
|
76
|
+
A.curves,Q=cols_dataset_get_curves_col_x(D,B.curve_parser.parameters.x)
|
|
77
|
+
if A.curves:A.cols_curve=ColsCurves(type=ReaderCurveParserNameConfig.COL_X,info=Q,curves=A.curves)
|
|
78
|
+
elif B.curve_parser.name==ReaderCurveParserNameConfig.COLS_COUPLE:raise NotImplementedError('cols_couple not implemented')
|
|
36
79
|
else:raise Exception('Curve parser not supported.')
|
|
37
80
|
def compare(A,compare_floats,param_reader,param_is_ref=True):D=param_is_ref;C=param_reader;B=compare_floats;E=A.cols_dataset if D else C.cols_dataset;F=A.cols_dataset if not D else C.cols_dataset;G=A.cols_curve;I,H=B.compare_errors.add_group('node','txt cols');return compare(H,B,E,F,G)
|
|
38
81
|
def class_info(A):return{'cols':A.cols_dataset.names,'raw_lines_number':A.raw_lines_number,'curves':A.curves}
|
scilens/report/html_report.py
CHANGED
|
@@ -22,6 +22,6 @@ class HtmlReport:
|
|
|
22
22
|
E=os.path.join(L,D)
|
|
23
23
|
if os.path.isfile(E):C=E;break
|
|
24
24
|
if not C:raise FileNotFoundError(f"Logo file '{A.config.logo_file}' not found in {F}.")
|
|
25
|
-
M=A.config.title if A.config.title else A.config.title_prefix+' '+task_name;N={'app_name':product_name,'app_version':pkg_version,'app_homepage':pkg_homepage,'app_copyright':f"© {B[H][:4]} {powered_by['name']}. All rights reserved",'app_powered_by':powered_by,'execution_utc_datetime':B['datetime'],'execution_utc_date':B[H],'execution_utc_time':B['time'],'execution_dir':A.working_dir,'title':M,'image':K or get_logo_image_src(C),'config':A.config.html,'config_json':A.config.html.model_dump_json()};G=None
|
|
25
|
+
M=A.config.title if A.config.title else A.config.title_prefix+' '+task_name;N={'app_name':product_name,'app_version':pkg_version,'app_homepage':pkg_homepage,'app_copyright':f"© {B[H][:4]} {powered_by['name']}. All rights reserved",'app_powered_by':powered_by,'execution_utc_datetime':B['datetime'],'execution_utc_date':B[H],'execution_utc_time':B['time'],'execution_dir':A.working_dir,'title':M,'description':A.config.description,'image':K or get_logo_image_src(C),'config':A.config.html,'config_json':A.config.html.model_dump_json()};G=None
|
|
26
26
|
if A.config.debug:G=A.config.model_dump_json(indent=4)
|
|
27
27
|
return template_render_infolder('index.html',{I:N,'task':data.get(I),'data':{'files':data.get('processor_results')},'debug':G})
|
|
@@ -47,15 +47,3 @@
|
|
|
47
47
|
</table>
|
|
48
48
|
|
|
49
49
|
</div>
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
<div id="tabs" class="tabs noselect" style="display: none;">
|
|
54
|
-
<div class="tab active" onclick="actions.click_tab(event, 0)">Summary</div>
|
|
55
|
-
{% for file in data.files %}
|
|
56
|
-
{% if not file.skipped %}
|
|
57
|
-
<div class="tab {{ ns.statuses[loop.index] }}" onclick="actions.click_tab(event, {{ loop.index }})"><span class="">{{ file.name }}</span></div>
|
|
58
|
-
{% endif %}
|
|
59
|
-
{% endfor %}
|
|
60
|
-
<div class="tabend"></div>
|
|
61
|
-
</div>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<div id="tabs" class="tabs noselect" style="display: none;">
|
|
2
|
+
<div class="tab active" onclick="actions.click_tab(event, 0)">Summary</div>
|
|
3
|
+
{% for file in data.files %}
|
|
4
|
+
{% if not file.skipped %}
|
|
5
|
+
<div class="tab {{ ns.statuses[loop.index] }}" onclick="actions.click_tab(event, {{ loop.index }})"><span class="">{{ file.name }}</span></div>
|
|
6
|
+
{% endif %}
|
|
7
|
+
{% endfor %}
|
|
8
|
+
<div class="tabend"></div>
|
|
9
|
+
</div>
|
|
@@ -2,7 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
<h2>Summary</h2>
|
|
4
4
|
|
|
5
|
-
<!--
|
|
5
|
+
<!-- DESCRIPTION -->
|
|
6
|
+
{% if meta.description %}
|
|
7
|
+
<!-- <h3>Description</h3> -->
|
|
8
|
+
<div id="section_summary_description" class="description">
|
|
9
|
+
{{ meta.description }}
|
|
10
|
+
</div>
|
|
11
|
+
{% endif %}
|
|
12
|
+
|
|
13
|
+
<!-- EXTRA HTML -->
|
|
14
|
+
{% if meta.config.extra_html_summary %}{{ meta.config.extra_html_summary }}{% endif %}
|
|
15
|
+
|
|
16
|
+
<!-- DATASETS -->
|
|
6
17
|
<h3>
|
|
7
18
|
Datasets <action data-command="toogle" data-args="section_summary_datasets"></action>
|
|
8
19
|
</h3>
|
|
@@ -133,11 +133,16 @@
|
|
|
133
133
|
<div id="framesseries_{{ file_index }}" ></div>
|
|
134
134
|
{% endif %}
|
|
135
135
|
|
|
136
|
-
{% for item in [{"id": "spectrograms", "label": "Spectrograms"}, {"id": "frameseries", "label": "Frameseries"}] %}
|
|
137
136
|
|
|
137
|
+
<!-- MATRICES -->
|
|
138
|
+
{% if file.test.matrices %}
|
|
139
|
+
{% for item in [{"id": "spectrograms", "label": "Spectrograms"}, {"id": "frameseries", "label": "Frameseries"}] %}
|
|
140
|
+
{% if meta.config.matrix[item.id] %}
|
|
138
141
|
<h3>{{ item.label }} <action data-command="toogle" data-args="{{ item.id }}_{{ file_index|string }}"></action></h3>
|
|
139
142
|
<div id="{{ item.id }}_{{ file_index }}" ></div>
|
|
143
|
+
{% endif %}
|
|
140
144
|
{% endfor %}
|
|
145
|
+
{% endif %}
|
|
141
146
|
|
|
142
147
|
|
|
143
148
|
<!--COMPARISONS ERRORS AND WARNINGS-->
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
{% set ns.statuses = ns.statuses + ['SKIPPED' if file.skipped else ('ERROR' if file.error else ('WARNING' if file.comparison_errors and file.comparison_errors.error_nb > 0 else 'SUCCESS'))] %}
|
|
14
14
|
{% if file.test.matrices %}
|
|
15
15
|
{% set ns.has_matrices = true %}
|
|
16
|
-
{% if
|
|
17
|
-
{% if
|
|
16
|
+
{% if meta.config.matrix.spectrograms %}{% set ns.has_spectrograms = true %}{% endif %}
|
|
17
|
+
{% if meta.config.matrix.frameseries %}{% set ns.has_frameseries = true %}{% endif %}
|
|
18
18
|
{% endif %}
|
|
19
19
|
{% endfor %}
|
|
20
20
|
<html>
|
|
@@ -26,19 +26,29 @@
|
|
|
26
26
|
<script src="https://cdn.plot.ly/plotly-2.34.0.min.js" charset="utf-8"></script>
|
|
27
27
|
|
|
28
28
|
<script>
|
|
29
|
-
|
|
29
|
+
|
|
30
|
+
((w_1, undef) => { w_1.None = undef; w_1.True = true; ; w_1.False = false; })(window); // for Python None = undef when templating
|
|
30
31
|
{% include 'js_dom.js' %}
|
|
31
32
|
{% include 'js_palette.js' %}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
{% if
|
|
33
|
+
|
|
34
|
+
{% include 'js_com_page.js' with context %}
|
|
35
|
+
{% include 'js_chartlibs_plotly.js' %}
|
|
36
|
+
{% include 'js_chartlibs_echarts.js' %}
|
|
37
|
+
{% include 'js_curvemgr.js' %}
|
|
38
|
+
{% include 'utils_compare_report_anim.js' %}
|
|
39
|
+
{% include 'utils_compare_report_framesseries.js' %}
|
|
40
|
+
|
|
41
|
+
{% if meta.config.matrix.spectrograms %}
|
|
42
|
+
{% include 'uti_spectrograms.js' %}
|
|
43
|
+
Spectrograms.config({
|
|
44
|
+
"DISPLAY_TESTREF": {{ meta.config.matrix.spectrograms.test_ref }},
|
|
45
|
+
"DISPLAY_DIFF": {{ meta.config.matrix.spectrograms.differences }},
|
|
46
|
+
"WIDTH": {{ meta.config.matrix.spectrograms.init_width }},
|
|
47
|
+
"HEIGHT": {{ meta.config.matrix.spectrograms.init_height }},
|
|
48
|
+
});
|
|
49
|
+
{% endif %}
|
|
41
50
|
{% if ns.has_matrices %}{% include 'uti_matrix.js' %}{% endif %}
|
|
51
|
+
|
|
42
52
|
</script>
|
|
43
53
|
<script>
|
|
44
54
|
function load_animations(){
|
|
@@ -89,13 +99,16 @@ function load_file_section(global_var, section_prefix, cls) {
|
|
|
89
99
|
user-select: none; /* Standard syntax */
|
|
90
100
|
}
|
|
91
101
|
</style>
|
|
102
|
+
{% if meta.config.custom_style %}<style type="text/css">{{ meta.config.custom_style }}</style>{% endif %}
|
|
103
|
+
{% if meta.config.custom_script_head %}<script>{{ meta.config.custom_script_head }}</script>{% endif %}
|
|
92
104
|
</head>
|
|
93
105
|
<body>
|
|
94
106
|
{% include 'body_01_title.html' with context %}
|
|
95
|
-
|
|
107
|
+
{% if meta.config.extra_html_start %}{{ meta.config.extra_html_start }}{% endif %}
|
|
108
|
+
{% include 'body_02_tabs.html' with context %}
|
|
96
109
|
{% include 'compare_11_summary.html' with context %}
|
|
97
110
|
{% include 'compare_12_sections.html' with context %}
|
|
98
|
-
|
|
111
|
+
{% if meta.config.extra_html_end %}{{ meta.config.extra_html_end }}{% endif %}
|
|
99
112
|
{% include 'body_99_footer.html' with context %}
|
|
100
113
|
<script type="text/javascript">
|
|
101
114
|
const GLOBAL_VARS = {};
|
|
@@ -122,8 +135,9 @@ function load_file_section(global_var, section_prefix, cls) {
|
|
|
122
135
|
test : [ {% for file in data.files %} {{ file.test.matrices or 'null' }} , {% endfor %} ],
|
|
123
136
|
reference : [ {% for file in data.files %} {{ file.ref.matrices or 'null' }} , {% endfor %} ],
|
|
124
137
|
};
|
|
125
|
-
MatrixMgmt.loadGlobal();
|
|
138
|
+
MatrixMgmt.loadGlobal({{ns.has_spectrograms}}, {{ns.has_frameseries}});
|
|
126
139
|
</script>
|
|
127
140
|
{% endif %}
|
|
141
|
+
{% if meta.config.custom_script_body %}<script>{{ meta.config.custom_script_body }}</script>{% endif %}
|
|
128
142
|
</body>
|
|
129
143
|
</html>
|