Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
CaosDB Crawler
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 Crawler
Commits
5bcefcca
Commit
5bcefcca
authored
1 year ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
MAINT: do not allow Identifiable for nodes without registered ident
parent
28b1b816
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!178
FIX: #96 Better error output for crawl.py script.
,
!167
Sync Graph
Pipeline
#50843
passed with warnings
1 year ago
Stage: info
Stage: setup
Stage: cert
Stage: style
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/caoscrawler/identifiable_adapters.py
+55
-60
55 additions, 60 deletions
src/caoscrawler/identifiable_adapters.py
with
55 additions
and
60 deletions
src/caoscrawler/identifiable_adapters.py
+
55
−
60
View file @
5bcefcca
...
@@ -288,72 +288,68 @@ startswith: bool, optional
...
@@ -288,72 +288,68 @@ startswith: bool, optional
Identifiable, the identifiable for record.
Identifiable, the identifiable for record.
"""
"""
registered_identifiable
=
se
.
registered_identifiable
property_name_list_A
=
[]
property_name_list_A
=
[]
property_name_list_B
=
[]
property_name_list_B
=
[]
identifiable_props
=
{}
identifiable_props
=
{}
name
=
None
name
=
None
# TODO
if
se
.
registered_identifiable
is
None
:
# if registered_identifiable is None:
raise
ValueError
(
"
no register_identifiable
"
)
# raise ValueError("no register_identifiable")
if
registered_identifiable
is
not
None
:
# fill the values:
# fill the values:
for
prop
in
se
.
registered_identifiable
.
properties
:
for
prop
in
registered_identifiable
.
properties
:
if
prop
.
name
==
"
name
"
:
if
prop
.
name
==
"
name
"
:
name
=
se
.
name
name
=
se
.
name
continue
continue
# problem: what happens with multi properties?
# problem: what happens with multi properties?
# case A: in the registered identifiable
# case A: in the registered identifiable
# case B: in the identifiable
# case B: in the identifiable
# treated elsewhere
if
prop
.
name
.
lower
()
==
"
is_referenced_by
"
:
for
el
in
identifiable_backrefs
:
assert
isinstance
(
el
,
SyncNode
)
if
len
(
identifiable_backrefs
)
==
0
:
raise
MissingReferencingEntityError
(
f
"
Could not find referencing entities of type(s):
{
prop
.
value
}
\n
"
f
"
for registered identifiable:
\n
{
registered_identifiable
}
\n
"
f
"
There were
{
len
(
identifiable_backrefs
)
}
referencing entities to choose from.
\n
"
f
"
This error can also occur in case of merge conflicts in the referencing entities.
"
)
elif
len
([
e
.
id
for
e
in
identifiable_backrefs
if
el
.
id
is
None
])
>
0
:
raise
RuntimeError
(
f
"
Referencing entity has no id
"
)
continue
options
=
[
p
.
value
for
p
in
se
.
properties
if
p
.
name
==
prop
.
name
]
# treated elsewhere
if
len
(
options
)
==
0
:
if
prop
.
name
.
lower
()
==
"
is_referenced_by
"
:
raise
MissingIdentifyingProperty
(
for
el
in
identifiable_backrefs
:
f
"
The following record is missing an identifying property:
\n
"
assert
isinstance
(
el
,
SyncNode
)
f
"
RECORD
\n
{
se
}
\n
Identifying PROPERTY
\n
{
prop
.
name
}
"
if
len
(
identifiable_backrefs
)
==
0
:
raise
MissingReferencingEntityError
(
f
"
Could not find referencing entities of type(s):
{
prop
.
value
}
\n
"
f
"
for registered identifiable:
\n
{
se
.
registered_identifiable
}
\n
"
f
"
There were
{
len
(
identifiable_backrefs
)
}
referencing entities to choose from.
\n
"
f
"
This error can also occur in case of merge conflicts in the referencing entities.
"
)
)
for
ii
,
el
in
enumerate
(
options
):
elif
len
([
e
.
id
for
e
in
identifiable_backrefs
if
el
.
id
is
None
])
>
0
:
if
isinstance
(
el
,
SyncNode
):
raise
RuntimeError
(
options
[
ii
]
=
el
.
id
f
"
Referencing entity has no id
"
if
el
.
id
is
None
:
)
raise
RuntimeError
(
"
Reference to unchecked in identifiable:
\n
"
continue
f
"
{
prop
.
name
}
:
\n
{
el
}
"
)
else
:
options
=
[
p
.
value
for
p
in
se
.
properties
if
p
.
name
==
prop
.
name
]
options
[
ii
]
=
el
if
len
(
options
)
==
0
:
if
not
all
([
f
==
options
[
0
]
for
f
in
options
]):
raise
MissingIdentifyingProperty
(
raise
RuntimeError
(
"
differing prop values
"
)
f
"
The following record is missing an identifying property:
\n
"
f
"
RECORD
\n
{
se
}
\n
Identifying PROPERTY
\n
{
prop
.
name
}
"
identifiable_props
[
prop
.
name
]
=
options
[
0
]
)
property_name_list_A
.
append
(
prop
.
name
)
for
ii
,
el
in
enumerate
(
options
):
if
isinstance
(
el
,
SyncNode
):
# check for multi properties in the record:
options
[
ii
]
=
el
.
id
for
prop
in
property_name_list_A
:
if
el
.
id
is
None
:
property_name_list_B
.
append
(
prop
)
raise
RuntimeError
(
"
Reference to unchecked in identifiable:
\n
"
if
(
len
(
set
(
property_name_list_B
))
!=
len
(
property_name_list_B
)
or
len
(
f
"
{
prop
.
name
}
:
\n
{
el
}
"
)
set
(
property_name_list_A
))
!=
len
(
property_name_list_A
)):
else
:
raise
RuntimeError
(
options
[
ii
]
=
el
"
Multi properties used in identifiables could cause unpredictable results and
"
if
not
all
([
f
==
options
[
0
]
for
f
in
options
]):
"
are not allowed. You might want to consider a Property with a list as value.
"
)
raise
RuntimeError
(
"
differing prop values
"
)
identifiable_props
[
prop
.
name
]
=
options
[
0
]
property_name_list_A
.
append
(
prop
.
name
)
# check for multi properties in the record:
for
prop
in
property_name_list_A
:
property_name_list_B
.
append
(
prop
)
if
(
len
(
set
(
property_name_list_B
))
!=
len
(
property_name_list_B
)
or
len
(
set
(
property_name_list_A
))
!=
len
(
property_name_list_A
)):
raise
RuntimeError
(
"
Multi properties used in identifiables could cause unpredictable results and
"
"
are not allowed. You might want to consider a Property with a list as value.
"
)
# use the RecordType of the registered Identifiable if it exists
# use the RecordType of the registered Identifiable if it exists
# We do not use parents of Record because it might have multiple
# We do not use parents of Record because it might have multiple
...
@@ -361,8 +357,7 @@ startswith: bool, optional
...
@@ -361,8 +357,7 @@ startswith: bool, optional
return
Identifiable
(
return
Identifiable
(
record_id
=
se
.
id
,
record_id
=
se
.
id
,
path
=
se
.
path
,
path
=
se
.
path
,
record_type
=
(
registered_identifiable
.
parents
[
0
].
name
record_type
=
se
.
registered_identifiable
.
parents
[
0
].
name
,
if
registered_identifiable
else
None
),
name
=
name
,
name
=
name
,
properties
=
identifiable_props
,
properties
=
identifiable_props
,
backrefs
=
[
e
.
id
for
e
in
identifiable_backrefs
]
backrefs
=
[
e
.
id
for
e
in
identifiable_backrefs
]
...
...
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