Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
DAN
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Container Registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Automatic Text Recognition
DAN
Commits
a2c9dd76
Commit
a2c9dd76
authored
1 year ago
by
Yoann Schneider
Browse files
Options
Downloads
Plain Diff
Merge branch 'log-element-id-when-download-failed' into 'main'
Log element ID when download as failed Closes
#228
See merge request
!320
parents
afbe821f
35ac8365
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!320
Log element ID when download as failed
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
dan/datasets/extract/arkindex.py
+1
-1
1 addition, 1 deletion
dan/datasets/extract/arkindex.py
dan/datasets/extract/exceptions.py
+4
-3
4 additions, 3 deletions
dan/datasets/extract/exceptions.py
tests/test_extract.py
+4
-3
4 additions, 3 deletions
tests/test_extract.py
with
9 additions
and
7 deletions
dan/datasets/extract/arkindex.py
+
1
−
1
View file @
a2c9dd76
...
...
@@ -259,7 +259,7 @@ class ArkindexExtractor:
except
Exception
as
e
:
raise
ImageDownloadError
(
split
=
split
,
path
=
str
(
destination
)
,
url
=
download_url
,
exc
=
e
split
=
split
,
path
=
destination
,
url
=
download_url
,
exc
=
e
)
def
format_text
(
self
,
text
:
str
,
charset
:
Optional
[
set
]
=
None
):
...
...
This diff is collapsed.
Click to expand it.
dan/datasets/extract/exceptions.py
+
4
−
3
View file @
a2c9dd76
# -*- coding: utf-8 -*-
from
pathlib
import
Path
class
ProcessingError
(
Exception
):
...
...
@@ -26,13 +27,13 @@ class ImageDownloadError(Exception):
"""
def
__init__
(
self
,
split
:
str
,
path
:
str
,
url
:
str
,
exc
:
Exception
,
*
args
:
object
self
,
split
:
str
,
path
:
Path
,
url
:
str
,
exc
:
Exception
,
*
args
:
object
)
->
None
:
super
().
__init__
(
*
args
)
self
.
split
:
str
=
split
self
.
path
:
str
=
path
self
.
path
:
str
=
str
(
path
)
self
.
url
:
str
=
url
self
.
message
=
str
(
exc
)
self
.
message
=
f
"
{
str
(
exc
)
}
for element
{
path
.
stem
}
"
class
NoTranscriptionError
(
ElementProcessingError
):
...
...
This diff is collapsed.
Click to expand it.
tests/test_extract.py
+
4
−
3
View file @
a2c9dd76
...
...
@@ -5,6 +5,7 @@ import logging
import
pickle
import
re
from
operator
import
attrgetter
,
methodcaller
from
pathlib
import
Path
from
typing
import
NamedTuple
from
unittest.mock
import
patch
...
...
@@ -701,7 +702,7 @@ def test_download_image_error(iiif_url, caplog, capsys):
"
split
"
:
"
train
"
,
"
polygon
"
:
[],
"
image_url
"
:
"
deadbeef
"
,
"
destination
"
:
"
/dev/null
"
,
"
destination
"
:
Path
(
"
/dev/null
"
)
,
}
# Make download_image crash
iiif_url
.
return_value
=
BoundingBox
(
0
,
0
,
0
,
0
),
task
[
"
image_url
"
]
...
...
@@ -723,7 +724,7 @@ def test_download_image_error(iiif_url, caplog, capsys):
extractor
.
tasks
=
[
task
]
# Add the key in data
extractor
.
data
[
task
[
"
split
"
]][
task
[
"
destination
"
]]
=
"
deadbeefdata
"
extractor
.
data
[
task
[
"
split
"
]][
str
(
task
[
"
destination
"
]
)
]
=
"
deadbeefdata
"
extractor
.
download_images
()
...
...
@@ -738,7 +739,7 @@ def test_download_image_error(iiif_url, caplog, capsys):
# Check stdout
captured
=
capsys
.
readouterr
()
assert
captured
.
out
==
"
deadbeef: Image URL must be HTTP(S)
\n
"
assert
captured
.
out
==
"
deadbeef: Image URL must be HTTP(S)
for element null
\n
"
def
test_download_image_error_try_max
(
responses
,
caplog
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment