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

feat: Use jpype instead of subprocess #356

Merged
merged 3 commits into from
Aug 27, 2023
Merged

feat: Use jpype instead of subprocess #356

merged 3 commits into from
Aug 27, 2023

Conversation

chezou
Copy link
Owner

@chezou chezou commented Aug 27, 2023

Description

Close #352
Successor of #355

Motivation and Context

To reduce JVM launch overhead for each execution.

How Has This Been Tested?

Unit test.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • I read the contributing document.
  • My code follows the code style of this project with running linter.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@chezou chezou marked this pull request as ready for review August 27, 2023 05:02
@@ -22,4 +22,6 @@ def lint(session):
@nox.session
def tests(session):
session.install(".[test]")
session.run("pytest", "-v")
session.run("pytest", "-v", "tests/test_read_pdf_table.py")
session.run("pytest", "-v", "tests/test_read_pdf_jar_path.py")
Copy link
Owner Author

@chezou chezou Aug 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is due to jpype limitation that doesn not allow shutdown JVM. Hence, we need to make separate session run for JVM option testing.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is due to jpype limitation that doesn not allow shutdown JVM

how about jpype.shutdownJVM()?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the document, we have to reboot Python to relaunch JVM.

https://jpype.readthedocs.io/en/latest/api.html#jpype.shutdownJVM

Due to limitations in the JPype, it is not possible to restart the JVM after being terminated.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see.

@chezou
Copy link
Owner Author

chezou commented Aug 27, 2023

The comparison of test running time is roughly 2.7 times faster than subprocess.

master branch:

$ Measure-Command { pytest .\tests\test_read_pdf_table.py }

Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 32
Milliseconds      : 298
Ticks             : 322984726
TotalDays         : 0.000373824914351852
TotalHours        : 0.00897179794444444
TotalMinutes      : 0.538307876666667
TotalSeconds      : 32.2984726
TotalMilliseconds : 32298.4726

This PR:

 Measure-Command { pytest .\tests\test_read_pdf_table.py; pytest .\tests\test_read_pdf_jar_path.py ; pytest .\tests\test_read_pdf_silent.py }

Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 12
Milliseconds      : 47
Ticks             : 120479953
TotalDays         : 0.000139444390046296
TotalHours        : 0.00334666536111111
TotalMinutes      : 0.200799921666667
TotalSeconds      : 12.0479953
TotalMilliseconds : 12047.9953

@chezou chezou changed the title Use jpype instead of subprocess feat: Use jpype instead of subprocess Aug 27, 2023
@chezou chezou merged commit d9154b3 into master Aug 27, 2023
2 checks passed
@chezou chezou deleted the jpype branch August 27, 2023 21:18
chezou added a commit that referenced this pull request Sep 9, 2023
@chezou chezou mentioned this pull request Sep 9, 2023
7 tasks
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.

Use JPype instead of subprocess
2 participants