Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-advanced-user-tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-advanced-user-tools
Commits
1a6a00ab
Verified
Commit
1a6a00ab
authored
6 months ago
by
Daniel Hornung
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Even better error message.
parent
969f32d4
No related branches found
No related tags found
2 merge requests
!128
MNT: Added a warning when column metadata is not configured, and a better...
,
!120
XLSX-Konverter: Bessere Fehlermeldung bei inkorrektem Typ in Spalte, zusätzlicher Spalte
Pipeline
#57866
passed
6 months ago
Stage: setup
Stage: cert
Stage: style
Stage: unittest
Stage: integrationtest
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/caosadvancedtools/table_json_conversion/convert.py
+7
-6
7 additions, 6 deletions
src/caosadvancedtools/table_json_conversion/convert.py
unittests/table_json_conversion/test_read_xlsx.py
+2
-1
2 additions, 1 deletion
unittests/table_json_conversion/test_read_xlsx.py
with
9 additions
and
7 deletions
src/caosadvancedtools/table_json_conversion/convert.py
+
7
−
6
View file @
1a6a00ab
...
@@ -186,7 +186,8 @@ class XLSXConverter:
...
@@ -186,7 +186,8 @@ class XLSXConverter:
self
.
_check_columns
(
fail_fast
=
strict
)
self
.
_check_columns
(
fail_fast
=
strict
)
except
KeyError
as
e
:
except
KeyError
as
e
:
raise
jsonschema
.
ValidationError
(
f
"
Malformed metadata: Cannot parse paths.
"
raise
jsonschema
.
ValidationError
(
f
"
Malformed metadata: Cannot parse paths.
"
f
"
Unknown path:
{
e
}
"
)
from
e
f
"
Unknown path:
'
{
e
.
args
[
1
]
}
'
in sheet
'
{
e
.
args
[
0
]
}
'
.
"
)
from
e
self
.
_handled_sheets
:
set
[
str
]
=
set
()
self
.
_handled_sheets
:
set
[
str
]
=
set
()
self
.
_result
:
dict
=
{}
self
.
_result
:
dict
=
{}
self
.
_errors
:
dict
=
{}
self
.
_errors
:
dict
=
{}
...
@@ -270,8 +271,11 @@ class XLSXConverter:
...
@@ -270,8 +271,11 @@ class XLSXConverter:
parents
[
xlsx_utils
.
p2s
(
col
.
path
[:
-
1
])]
=
col
.
path
[:
-
1
]
parents
[
xlsx_utils
.
p2s
(
col
.
path
[:
-
1
])]
=
col
.
path
[:
-
1
]
col_paths
.
append
(
col
.
path
)
col_paths
.
append
(
col
.
path
)
for
path
in
parents
.
values
():
for
path
in
parents
.
values
():
subschema
=
xlsx_utils
.
get_subschema
(
path
,
self
.
_schema
)
try
:
subschema
=
xlsx_utils
.
get_subschema
(
path
,
self
.
_schema
)
except
KeyError
as
kerr
:
kerr
.
args
=
(
sheetname
,
*
kerr
.
args
)
raise
# Unfortunately, there are a lot of special cases to handle here.
# Unfortunately, there are a lot of special cases to handle here.
if
subschema
.
get
(
"
type
"
)
==
"
array
"
:
if
subschema
.
get
(
"
type
"
)
==
"
array
"
:
subschema
=
subschema
[
"
items
"
]
subschema
=
subschema
[
"
items
"
]
...
@@ -544,9 +548,6 @@ def _group_foreign_paths(foreign: list[list], common: list[str]) -> list[SimpleN
...
@@ -544,9 +548,6 @@ def _group_foreign_paths(foreign: list[list], common: list[str]) -> list[SimpleN
last_level
=
len
(
elem
.
path
)
last_level
=
len
(
elem
.
path
)
resultlist
.
append
(
elem
)
resultlist
.
append
(
elem
)
# from IPython import embed
# embed()
if
last_level
!=
len
(
common
):
if
last_level
!=
len
(
common
):
raise
ValueError
(
"
Foreign keys must cover the complete `common` depth.
"
)
raise
ValueError
(
"
Foreign keys must cover the complete `common` depth.
"
)
return
resultlist
return
resultlist
...
...
This diff is collapsed.
Click to expand it.
unittests/table_json_conversion/test_read_xlsx.py
+
2
−
1
View file @
1a6a00ab
...
@@ -153,7 +153,8 @@ def test_error_table():
...
@@ -153,7 +153,8 @@ def test_error_table():
with
pytest
.
raises
(
jsonschema
.
ValidationError
)
as
caught
:
with
pytest
.
raises
(
jsonschema
.
ValidationError
)
as
caught
:
convert
.
to_dict
(
xlsx
=
rfp
(
"
data/simple_data_broken_paths.xlsx
"
),
convert
.
to_dict
(
xlsx
=
rfp
(
"
data/simple_data_broken_paths.xlsx
"
),
schema
=
rfp
(
"
data/simple_schema.json
"
))
schema
=
rfp
(
"
data/simple_schema.json
"
))
assert
"
Malformed metadata: Cannot parse paths
"
in
str
(
caught
.
value
)
assert
(
"
Malformed metadata: Cannot parse paths. Unknown path:
'
There
'
in sheet
'
Person
'
.
"
==
str
(
caught
.
value
))
def
test_additional_column
():
def
test_additional_column
():
...
...
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