Skip to content

Commit

Permalink
fix: explain xpdf install failure
Browse files Browse the repository at this point in the history
Log list of GPUs for tensorflow.
  • Loading branch information
cofiem committed May 28, 2023
1 parent b41fa0d commit bfcd15d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions .idea/leaf-focus.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion install_xpdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def run(self) -> bool:
raise ValueError(msg)

logger.info("Finished.")
return False
return True

def _get_url_file_name(self, url: str) -> str:
parsed_url = urlparse(url)
Expand Down Expand Up @@ -163,6 +163,7 @@ def _gpg_verify(
result_import = subprocess.run(cmd_import, capture_output=True)
expected_import_return_code = 2
if result_import.returncode != expected_import_return_code:
logger.warning("Unexpected return code '%s'.", result_import)
# expecting return code 2 because there is no ultimately trusted key
return False
contains_email = [
Expand All @@ -171,6 +172,7 @@ def _gpg_verify(
if expected_email in line.decode()
]
if len(contains_email) != 1:
logger.warning("Unexpected stderr '%s'.", result_import)
# gpg key must contain the expected email address
return False

Expand All @@ -185,6 +187,7 @@ def _gpg_verify(
]
result_verify = subprocess.run(cmd_verify, capture_output=True)
if result_verify.returncode != 0:
logger.warning("Unexpected return code '%s'.", result_verify)
# expecting status code 0
return False
contains_good_email = [
Expand All @@ -193,6 +196,7 @@ def _gpg_verify(
if f"Good signature from {expected_email}" in line.decode()
]
if len(contains_good_email) != 1:
logger.warning("Unexpected stderr code '%s'.", result_verify)
# must be a 'good' signature with the expected key
return False

Expand Down
4 changes: 4 additions & 0 deletions src/leaf_focus/ocr/keras_ocr.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ def engine_create(self) -> None:

tf.get_logger().setLevel(log_level)

# check the CPU / GPU in use
gpus = tf.config.list_physical_devices("GPU")
logger.info("GPUs in use: '%s'.", gpus)

try:
import keras_ocr # pylint: disable=import-outside-toplevel
except ModuleNotFoundError as error:
Expand Down

0 comments on commit bfcd15d

Please # to comment.