Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Html parser when uplading file #72

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

AliceeLe
Copy link

@AliceeLe AliceeLe commented Dec 8, 2024

Description

I aim to resolve this issue: #37

What I did is to utilize existing pdfkit library to convert HTML to pdf because there are a lot of customization options for HTML. Hence, converting to PDF and use the existing method would be a more efficient choice. I used pdfkit and wkhtmltopdf for this change.

The front-end change for this back-end update is here: harmonydata/app#36

Fixes # 37

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

Testing

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test that it successfully converts to PDF and matches the output in Jupyter notebook

Since the Harmony Python package is used by the Harmony API (which is itself used by the R library and the web app), we need to avoid making any changes that break the Harmony API. Please also run the Harmony API unit tests and check that the API still runs with your changes to the Python package: https://github.com/harmonydata/harmonyapi

Test Configuration

  • Library version: 1.0.1
  • OS: macOS Sonoma 14.0 (Darwin Kernel 24.0.0, ARM64)
  • Toolchain: npm v10.8.2, Node.js v18.20.5

Checklist

  • My code follows the style guidelines of this project. I have applied a Linter (recommended: Pycharm's code formatter) to make my whitespace consistent with the rest of the project.
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings
  • The Harmony API is not broken by my change to the Harmony Python library
  • If I introduced a new feature, I documented it (e.g. making a script example in the script examples repository so that people will know how to use it.

Optionally: feel free to paste your Discord username in this format: discordapp.com/users/yourID in your pull request description, then we can know to tag you in the Harmony Discord server when we announce the PR.

@woodthom2
Copy link
Contributor

Hi Alice
thanks so much for doing this, I really appreciate the time you took to contribute to the project.

Before I merge this in, I'm just a little concerned about 2 things in the PR:

  1. sending HTML via PDF and back - can we find a way to do this directly from HTML? PDF loses information and adds lots of line breaks, but actually the Harmony PDF processing involves a third party code (Tika) converting PDF to text and then we try to extract the data here. So there's no need to generate a PDF, since Harmony operates on plain text in text_parser.py anyway.
  2. the relatively large number of third party dependencies that are now added to the project - do you think you might be able to implement this functionality with the third party libraries that are already in pyproject.toml, or perhaps at most one extra dependency such as lxml being added? Sorry I should have mentioned this before but when we have many extra dependencies added, the project becomes large and unstable. If each issue solved added 4 dependencies, the project would rapidly become hard to manage as the dependencies tend to conflict with each other, so we're trying to keep this list as slim as possible.

I'd be really grateful if you get the time to check those two points and see if you can adjust the PR to have a smaller footprint, then we can look at merging it... thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants