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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
CaosDB Crawler
Commits
88c72db6
Commit
88c72db6
authored
3 years ago
by
Alexander Schlemmer
Browse files
Options
Downloads
Patches
Plain Diff
FIX: copy attributes now working
parent
65fe289f
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!53
Release 0.1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/newcrawler/crawl.py
+4
-9
4 additions, 9 deletions
src/newcrawler/crawl.py
unittests/test_tool.py
+0
-5
0 additions, 5 deletions
unittests/test_tool.py
with
4 additions
and
14 deletions
src/newcrawler/crawl.py
+
4
−
9
View file @
88c72db6
...
@@ -38,7 +38,7 @@ from .converters import Converter, DirectoryConverter
...
@@ -38,7 +38,7 @@ from .converters import Converter, DirectoryConverter
from
.identifiable_adapters
import
IdentifiableAdapter
,
LocalStorageIdentifiableAdapter
from
.identifiable_adapters
import
IdentifiableAdapter
,
LocalStorageIdentifiableAdapter
from
collections
import
defaultdict
from
collections
import
defaultdict
from
typing
import
Union
,
Any
,
Optional
from
typing
import
Union
,
Any
,
Optional
from
caosdb.apiutils
import
compare_entities
from
caosdb.apiutils
import
compare_entities
,
merge_entities
from
copy
import
deepcopy
from
copy
import
deepcopy
from
jsonschema
import
validate
from
jsonschema
import
validate
...
@@ -337,12 +337,8 @@ class Crawler(object):
...
@@ -337,12 +337,8 @@ class Crawler(object):
"""
"""
Copy all attributes from one entity to another entity.
Copy all attributes from one entity to another entity.
"""
"""
# add missing parents:
for
parent
in
fro
.
parents
:
merge_entities
(
to
,
fro
)
if
to
.
get_parent
(
parent
.
name
)
is
None
:
to
.
add_parent
(
parent
)
# TODO: unfinished
raise
NotImplementedError
()
def
split_into_inserts_and_updates
(
self
,
ent_list
:
list
[
db
.
Entity
]):
def
split_into_inserts_and_updates
(
self
,
ent_list
:
list
[
db
.
Entity
]):
if
self
.
identifiableAdapter
is
None
:
if
self
.
identifiableAdapter
is
None
:
...
@@ -377,8 +373,7 @@ class Crawler(object):
...
@@ -377,8 +373,7 @@ class Crawler(object):
# information
# information
# Update an (local) identified record that will be inserted
# Update an (local) identified record that will be inserted
newrecord
=
self
.
get_identified_record_from_local_cache
(
record
)
newrecord
=
self
.
get_identified_record_from_local_cache
(
record
)
# breakpoint()
self
.
copy_attributes
(
fro
=
record
,
to
=
newrecord
)
# self.copy_attributes(fro=record, to=newrecord)
# Bend references to the other object
# Bend references to the other object
# TODO refactor this
# TODO refactor this
for
el
in
flat
+
to_be_inserted
+
to_be_updated
:
for
el
in
flat
+
to_be_inserted
+
to_be_updated
:
...
...
This diff is collapsed.
Click to expand it.
unittests/test_tool.py
+
0
−
5
View file @
88c72db6
...
@@ -173,7 +173,6 @@ def test_ambigious_records(crawler, ident):
...
@@ -173,7 +173,6 @@ def test_ambigious_records(crawler, ident):
def
test_crawler_update_list
(
crawler
,
ident
):
def
test_crawler_update_list
(
crawler
,
ident
):
crawler
.
copy_attributes
=
Mock
()
# If the following assertions fail, that is a hint, that the test file records.xml has changed
# If the following assertions fail, that is a hint, that the test file records.xml has changed
# and this needs to be updated:
# and this needs to be updated:
assert
len
(
ident
.
get_records
())
==
18
assert
len
(
ident
.
get_records
())
==
18
...
@@ -334,8 +333,6 @@ def mock_retrieve(crawler):
...
@@ -334,8 +333,6 @@ def mock_retrieve(crawler):
else
:
else
:
return
None
return
None
crawler
.
copy_attributes
=
Mock
()
# a record that is found remotely and should be added to the update list and one that is not
# a record that is found remotely and should be added to the update list and one that is not
# found and should be added to the insert one
# found and should be added to the insert one
remote_known
=
{
"
A
"
:
db
.
Record
(
id
=
1111
,
name
=
"
A
"
)}
remote_known
=
{
"
A
"
:
db
.
Record
(
id
=
1111
,
name
=
"
A
"
)}
...
@@ -432,7 +429,6 @@ def test_split_into_inserts_and_updates_with_complex(mock_retrieve):
...
@@ -432,7 +429,6 @@ def test_split_into_inserts_and_updates_with_complex(mock_retrieve):
# TODO write test where the unresoled entity is not part of the identifiable
# TODO write test where the unresoled entity is not part of the identifiable
@pytest.mark.xfail
def
test_split_into_inserts_and_updates_with_copy_attr
(
mock_retrieve
):
def
test_split_into_inserts_and_updates_with_copy_attr
(
mock_retrieve
):
crawler
=
mock_retrieve
crawler
=
mock_retrieve
# assume identifiable is only the name
# assume identifiable is only the name
...
@@ -443,7 +439,6 @@ def test_split_into_inserts_and_updates_with_copy_attr(mock_retrieve):
...
@@ -443,7 +439,6 @@ def test_split_into_inserts_and_updates_with_copy_attr(mock_retrieve):
entlist
=
[
a
,
b
]
entlist
=
[
a
,
b
]
insert
,
update
=
crawler
.
split_into_inserts_and_updates
(
entlist
)
insert
,
update
=
crawler
.
split_into_inserts_and_updates
(
entlist
)
# expected TODO
assert
update
[
0
].
get_property
(
"
bar
"
).
value
==
2
assert
update
[
0
].
get_property
(
"
bar
"
).
value
==
2
assert
update
[
0
].
get_property
(
"
foo
"
).
value
==
1
assert
update
[
0
].
get_property
(
"
foo
"
).
value
==
1
...
...
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