Skip to content

Commit 5d2e035

Browse files
feat: Add PDF export functionality to main API (resolves #53)Update __init__.py
This commit addresses issue #53 by integrating the existing PDF export functionality into the main Harmony API. Changes: - Added imports for generate_pdf_report, generate_harmony_pdf_report, and generate_basic_harmony_report from services.export_pdf_report - Included graceful fallback with helpful error messages if PDF dependencies are not installed - Makes the comprehensive PDF export feature accessible to end users through the main harmony module The PDF export functionality was already fully implemented and tested, but not exposed through the main API. This change completes the integration, allowing users to create human-readable PDF reports with statistics, graphics, and professional formatting as requested in issue #53.
1 parent 743ed30 commit 5d2e035

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

src/harmony/__init__.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,60 @@
11
'''
22
MIT License
3-
43
Copyright (c) 2023 Ulster University (https://www.ulster.ac.uk).
54
Project: Harmony (https://harmonydata.ac.uk)
65
Maintainer: Thomas Wood (https://fastdatascience.com)
7-
86
Permission is hereby granted, free of charge, to any person obtaining a copy
97
of this software and associated documentation files (the "Software"), to deal
108
in the Software without restriction, including without limitation the rights
119
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1210
copies of the Software, and to permit persons to whom the Software is
1311
furnished to do so, subject to the following conditions:
14-
1512
The above copyright notice and this permission notice shall be included in all
1613
copies or substantial portions of the Software.
17-
1814
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1915
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2016
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2117
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2218
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2319
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2420
SOFTWARE.
25-
2621
'''
27-
2822
__version__ = "1.0.7"
29-
3023
# TODO: make these configurable at package level
3124
import os
32-
3325
from .examples import example_instruments
3426
from .schemas import *
3527
from .util.instrument_helper import create_instrument_from_list, import_instrument_into_harmony_web
3628
from .util.model_downloader import download_models
3729

30+
# PDF Export functionality (addresses issue #53)
31+
try:
32+
from .services.export_pdf_report import (
33+
generate_pdf_report,
34+
generate_harmony_pdf_report,
35+
generate_basic_harmony_report
36+
)
37+
except ImportError:
38+
# Graceful fallback if PDF dependencies are not available
39+
def generate_pdf_report(*args, **kwargs):
40+
raise ImportError("PDF export requires additional dependencies. Install with: pip install fpdf2 matplotlib seaborn")
41+
def generate_harmony_pdf_report(*args, **kwargs):
42+
raise ImportError("PDF export requires additional dependencies. Install with: pip install fpdf2 matplotlib seaborn")
43+
def generate_basic_harmony_report(*args, **kwargs):
44+
raise ImportError("PDF export requires additional dependencies. Install with: pip install fpdf2 matplotlib seaborn")
45+
3846
if os.environ.get("HARMONY_NO_PARSING") is None or os.environ.get("HARMONY_NO_PARSING") == "":
3947
from .parsing.text_parser import convert_text_to_instruments
4048
from .parsing.excel_parser import convert_excel_to_instruments
4149
from .parsing.pdf_parser import convert_pdf_to_instruments
4250
from .parsing.wrapper_all_parsers import convert_files_to_instruments
4351
from .parsing import *
4452
from .util.file_helper import load_instruments_from_local_file
45-
4653
if os.environ.get("HARMONY_NO_MATCHING") is None or os.environ.get("HARMONY_NO_MATCHING") == "":
4754
from .matching.matcher import match_instruments_with_function
4855
from .matching.generate_crosswalk_table import generate_crosswalk_table
4956
from .matching.deterministic_clustering import find_clusters_deterministic
5057
from .matching.cluster import cluster_questions
51-
5258
try:
5359
from .matching.default_matcher import match_instruments
5460
except ModuleNotFoundError:

0 commit comments

Comments
 (0)