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
330808fa
Commit
330808fa
authored
1 year ago
by
Timm Fitschen
Committed by
Florian Spreckelsen
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
AUDIT: Apply suggestions from review
parent
66d4f8e3
No related branches found
No related tags found
2 merge requests
!73
MAINT: change wording of TableImporter argument and allow converters and...
,
!72
Extend json-schema model parser
Pipeline
#37101
passed
1 year ago
Stage: setup
Stage: cert
Stage: style
Stage: unittest
Stage: integrationtest
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.md
+2
-1
2 additions, 1 deletion
CHANGELOG.md
src/caosadvancedtools/models/parser.py
+9
-7
9 additions, 7 deletions
src/caosadvancedtools/models/parser.py
src/doc/json_schema_interface.rst
+1
-1
1 addition, 1 deletion
src/doc/json_schema_interface.rst
with
12 additions
and
9 deletions
CHANGELOG.md
+
2
−
1
View file @
330808fa
...
...
@@ -9,7 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ###
-
TableImporter now accepts a
`existing_columns`
argument which demands that certain columns exist
-
The
`JsonSchemaParser`
class now supports
`patternProperties`
and json-schema references
-
The
`JsonSchemaParser`
class supports
`patternProperties`
-
The
`JsonSchemaParser`
calss supports json-schema references (
`$ref`
)
### Changed ###
...
...
This diff is collapsed.
Click to expand it.
src/caosadvancedtools/models/parser.py
+
9
−
7
View file @
330808fa
...
...
@@ -192,7 +192,7 @@ def parse_model_from_json_schema(
"""
# @author Florian Spreckelsen
# @date 2022-02-17
# @review
Daniel Hornung
202
2
-0
2-18
# @review
Timm Fitschen
202
3
-0
5-25
parser
=
JsonSchemaParser
(
types_for_missing_array_items
,
ignore_unspecified_array_items
)
return
parser
.
parse_model_from_json_schema
(
filename
,
top_level_recordtype
)
...
...
@@ -639,7 +639,7 @@ class JsonSchemaParser(Parser):
"""
# @author Florian Spreckelsen
# @date 2022-02-17
# @review Timm Fitschen 202
2
-0
2-30
# @review Timm Fitschen 202
3
-0
5-25
def
__init__
(
self
,
types_for_missing_array_items
=
{},
ignore_unspecified_array_items
=
False
):
super
().
__init__
()
...
...
@@ -665,7 +665,7 @@ class JsonSchemaParser(Parser):
"""
# @author Florian Spreckelsen
# @date 2022-02-17
# @review Timm Fitschen 202
2
-0
2-30
# @review Timm Fitschen 202
3
-0
5-25
with
open
(
filename
,
'
r
'
)
as
schema_file
:
model_dict
=
jsonref
.
load
(
schema_file
)
...
...
@@ -711,7 +711,7 @@ class JsonSchemaParser(Parser):
# Check if this is a valid Json Schema
name
=
self
.
_stringify
(
elt
[
"
title
"
],
context
=
elt
)
self
.
_treat_element
(
elt
,
name
)
elif
"
properties
"
in
elt
or
"
patternProperties
"
:
elif
"
properties
"
in
elt
or
"
patternProperties
"
in
elt
:
# No top-level type but there are entities
if
"
properties
"
in
elt
:
for
key
,
prop
in
elt
[
"
properties
"
].
items
():
...
...
@@ -732,7 +732,7 @@ class JsonSchemaParser(Parser):
return
DataModel
(
self
.
model
.
values
())
def
_get_name_from_property
(
self
,
key
:
str
,
prop
:
dict
):
# @review Timm Fitschen 2023-05-25
if
"
title
"
in
prop
:
name
=
self
.
_stringify
(
prop
[
"
title
"
])
else
:
...
...
@@ -741,7 +741,7 @@ class JsonSchemaParser(Parser):
return
name
def
_get_atomic_datatype
(
self
,
elt
):
# @review Timm Fitschen 202
2
-0
2-30
# @review Timm Fitschen 202
3
-0
5-25
if
elt
[
"
type
"
]
==
"
string
"
:
if
"
format
"
in
elt
and
elt
[
"
format
"
]
in
[
"
date
"
,
"
date-time
"
]:
return
db
.
DATETIME
...
...
@@ -859,7 +859,7 @@ class JsonSchemaParser(Parser):
return
rt
def
_treat_list
(
self
,
elt
:
dict
,
name
:
str
):
# @review Timm Fitschen 202
2
-0
2-30
# @review Timm Fitschen 202
3
-0
5-25
if
"
items
"
not
in
elt
and
name
not
in
self
.
types_for_missing_array_items
:
if
self
.
ignore_unspecified_array_items
:
...
...
@@ -890,6 +890,7 @@ class JsonSchemaParser(Parser):
return
db
.
Property
(
name
=
name
,
datatype
=
datatype
),
False
def
_get_pattern_prop
(
self
):
# @review Timm Fitschen 2023-05-25
if
"
__pattern_property_pattern_property
"
in
self
.
model
:
return
self
.
model
[
"
__pattern_property_pattern_property
"
]
pp
=
db
.
Property
(
name
=
"
__matched_pattern
"
,
datatype
=
db
.
TEXT
)
...
...
@@ -910,6 +911,7 @@ class JsonSchemaParser(Parser):
array.
"""
# @review Timm Fitschen 2023-05-25
num_patterns
=
len
(
pattern_elements
)
pattern_prop
=
self
.
_get_pattern_prop
()
returns
=
[]
...
...
This diff is collapsed.
Click to expand it.
src/doc/json_schema_interface.rst
+
1
−
1
View file @
330808fa
...
...
@@ -16,7 +16,7 @@ RecordTypes are created from their parent element's name by appending the string
``"Entry"`` and possibly a number if there are more than one pattern properties
for one parent.
All the RecordTypes created for pattern properties have at least an
b
oligatory
All the RecordTypes created for pattern properties have at least an o
b
ligatory
``__matched_pattern`` property which will -- as the name suggests -- store the
matched pattern of an actual data entry.
...
...
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