DibisoReporting#
Base class to generate reports.
You can use this class thought its child classes (Biso and PubPart) which will inherit from the generic
methods documented below.
The DibisoReporting Class#
- class dibisoreporting.dibisoreporting.DibisoReporting(entity_id: str = '', year: int | None = None, latex_main_file_path: str | None = None, latex_main_file_url: str | None = None, latex_biblio_file_path: str | None = None, latex_biblio_file_url: str | None = None, latex_template_path: str | None = None, latex_template_url: str | None = None, latexmkrc_file_path: str | None = None, latexmkrc_file_url: str | None = None, max_entities: int | None = 1000, max_plotted_entities: int = 25, plot_main_color: str | None = None, root_path: str | None = None, **kwargs)#
Bases:
objectClass to generate the BiSO report
- Variables:
figures_dir_name – Directory where figures are stored.
class_mapping – Dictionary that maps class names to actual classes
default_plot_main_color – Default color for the main plot (blue)
default_latexmkrc_file_content – Default content of the latexmkrc file.
default_visualizations – Dictionary contains each type of plot to include in the report with the parameters of each plot.
- __init__(entity_id: str = '', year: int | None = None, latex_main_file_path: str | None = None, latex_main_file_url: str | None = None, latex_biblio_file_path: str | None = None, latex_biblio_file_url: str | None = None, latex_template_path: str | None = None, latex_template_url: str | None = None, latexmkrc_file_path: str | None = None, latexmkrc_file_url: str | None = None, max_entities: int | None = 1000, max_plotted_entities: int = 25, plot_main_color: str | None = None, root_path: str | None = None, **kwargs)#
Initialize the Biso class with the given parameters.
- Parameters:
entity_id (str) – The ID of the entity to make the report on (e.g. the HAL collection identifier).
year (int | None, optional) – The year of the report. If None, uses the current year.
latex_main_file_path (str | None, optional) – Path to a single LaTeX main file. This file is the one to use to compile the report. It will copy the main file to root_path. Default to None. If None, doesn’t try getting the main file from the path. If both latex_main_file_path and latex_main_file_url are not None, the library will first try to get the main file from the path.
latex_main_file_url (str | None, optional) – URL to download a single LaTeX main file. It will download the file directly to root_path. Default to None. If None, doesn’t try getting the main file from the URL.
latex_biblio_file_path (str | None, optional) – Path to a single LaTeX biblio file. This file is the one to use to compile the bibliography. It will copy the biblio file to root_path. Default to None. If None, doesn’t try getting the biblio file from the path. If both latex_biblio_file_path and latex_biblio_file_url are not None, the library will first try to get the biblio file from the path.
latex_biblio_file_url (str | None, optional) – URL to download a single LaTeX biblio file. It will download the file directly to root_path. Default to None. If None, doesn’t try getting the biblio file from the URL.
latex_template_path (str | None, optional) – Path to the LaTeX template files. It will copy the templates files to root_path. Default to None. If None, doesn’t try getting the template from the path. If both latex_template_path and latex_template_url are not None, the library will first try to get the template from the path.
latex_template_url (str | None, optional) – URL to a GitHub repository containing the template. It will get the latest repository release and extract it to get the template files. Default to None. If None, doesn’t try getting the template from the URL.
latexmkrc_file_path (str | None, optional) – Path to a latexmkrc file. This file contains the LaTeX compiler configuration for Overleaf. It will copy the main file to root_path. Default to None. If None, doesn’t try getting the main file from the path. If both latexmkrc_file_path and latexmkrc_file_url are not None, the library will first try to get the main file from the path. If both latexmkrc_file_path and latexmkrc_file_url are None, a default latexmkrc will be created.
latexmkrc_file_url (str | None, optional) – URL to download a latexmkrc file. It will download the file directly to root_path. Default to None. If None, doesn’t try getting the main file from the URL.
max_entities (int | None, optional) – Default maximum number of entities used to create the plot. Default 1000. Set to None to disable the limit. This value limits the number of queried entities when doing analysis. For example, when creating the collaboration map, it limits the number of works to query from HAL to extract the collaborating institutions from.
max_plotted_entities (int, optional) – Maximum number of bars in the plot or rows in the table. Default to 25.
plot_main_color (str, optional) – Main color used in the plots. Default to “blue”. Plotly color.
root_path (str, optional) – Path to the root directory where the report and figures will be generated.
- add_marco(name: str, value)#
Add a LaTeX macro to the report.
- Parameters:
name (str) – Name of the macro.
value – Value of the macro.
- Returns:
- class_mapping = {}#
- create_default_latexmkrc_file()#
Create the default latexmkrc file in the root path of the project.
- default_latexmkrc_file_content = "$pdflatex = 'lualatex %O %S --shell-escape';\n$pdf_mode = 1;\n$postscript_mode = $dvi_mode = 0;\n"#
- default_plot_main_color = 'blue'#
- default_visualizations = {}#
- figures_dir_name = 'figures'#
- generate_report(visualizations_to_make: dict[str, list[dict]] | None = None, import_default_visualizations=True)#
Generate the report by calling the specified functions with their parameters to create the desired visualizations. To select which visualization to make and configure them, you can use visualizations_to_make as follows:
visualizations_to_make = { "AnrProjects": [ { "name": "anr1", "param1": "value1", "param2": "value2" }, { "name": "anr2", "param1": "value3", "param2": "value4" } ], "Chapters": [ { "name": "chapter1", "param1": "value1", "param2": "value2" } ], "CollaborationMap": [ { "name": "collab1", "max_entities": 1000, "resolution": 50, "map_zoom": True }, { "name": "collab2", "max_entities": 500, "resolution": 100, "map_zoom": False } ], "CollaborationNames": [ {} ], "Conferences": [] }
- This example, will create:
2 AnrProjects visualizations (with the parameters defined in the dictionaries)
1 Chapters visualization
2 CollaborationMaps visualizations
1 Conferences CollaborationNames (with the default parameters as there is one empty dictionary)
0 Conferences visualizations (as the list is empty)
- Parameters:
visualizations_to_make (list[dict[str, Any]]) – A dictionary specifying which visualizations to make and their parameters.
import_default_visualizations (bool) – Whether to import default visualizations settings. Defaults to True. To not generate a plot, set its dictionary in import_default_visualizations to an empty list. Example: If you don’t want to generate the Conferences visualization, you can set import_default_visualizations as follows:
import_default_visualizations = {"Conferences": []}.
- get_file_from_path(file_path: str, file_type: str)#
If file_path is not None, get the file from a local path. It copies the file from the specified path to the root path of the project. Checks the file type based on its extension and rename latexmkrc files.
- Parameters:
file_path (str) – The path to the file.
file_type (str) – The file type (“tex” or “latexmkrc”).
- Returns:
The path to the LaTeX main file.
- get_file_from_url(file_url: str, file_type: str)#
If file_url is not None, get the file from a URL. It downloads the file from the specified URL to the root path of the project. Checks the file type based on its extension and rename latexmkrc files.
- Parameters:
file_url (str) – The URL of the file.
file_type (str) – The file type (“tex” or “latexmkrc”).
- Returns:
The path to the LaTeX main file.
- get_latex_template_from_github()#
Get the LaTeX template either from a GitHub repository release. It saves the template in the root path of the project.
- get_latex_template_from_path()#
Get the LaTeX template from a local path. It copies the template files from the specified path to the root path of the project.