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
a9cfd002
Commit
a9cfd002
authored
Feb 1, 2022
by
Alexander Schlemmer
Browse files
Options
Downloads
Patches
Plain Diff
ENH: completed file retrieval implementation
parent
7d773b3e
No related branches found
No related tags found
1 merge request
!53
Release 0.1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/newcrawler/identifiable_adapters.py
+16
-17
16 additions, 17 deletions
src/newcrawler/identifiable_adapters.py
with
16 additions
and
17 deletions
src/newcrawler/identifiable_adapters.py
+
16
−
17
View file @
a9cfd002
...
...
@@ -129,7 +129,10 @@ class IdentifiableAdapter(metaclass=ABCMeta):
pass
@abstractmethod
def
get_file
(
self
,
record
:
db
.
File
):
def
get_file
(
self
,
identifiable
:
db
.
File
):
"""
Retrieve the file object for a (File) identifiable.
"""
pass
...
...
@@ -141,7 +144,9 @@ class IdentifiableAdapter(metaclass=ABCMeta):
with a specific path. In the future, this could be extended
to allow for names, parents and custom properties.
"""
pass
identifiable
=
db
.
File
()
identifiable
.
path
=
record
.
path
return
identifiable
...
...
@@ -151,12 +156,8 @@ class IdentifiableAdapter(metaclass=ABCMeta):
identifiable
"""
# TODO: this is incorrect
# The identifiable of a File is a file object with a path set.
# This needs to be taken into account also for retrieving the
# actually identified record.
if
record
.
role
==
"
File
"
:
return
self
.
get_file
(
record
)
return
self
.
get_
identifiable_for_
file
(
record
)
registered_identifiable
=
self
.
get_registered_identifiable
(
record
)
...
...
@@ -231,6 +232,9 @@ class IdentifiableAdapter(metaclass=ABCMeta):
if
identifiable
is
None
:
return
None
if
identifiable
.
role
==
"
File
"
:
return
self
.
get_file
(
identifiable
)
return
self
.
retrieve_identified_record_for_identifiable
(
identifiable
)
...
...
@@ -358,22 +362,21 @@ class LocalStorageIdentifiableAdapter(IdentifiableAdapter):
class
CaosDBIdentifiableAdapter
(
IdentifiableAdapter
):
"""
Identifiable adapter which can be used for production.
TODO: store registred identifiables not locally
"""
# TODO: don't store registered identifiables locally
def
__init__
(
self
):
self
.
_registered_identifiables
=
dict
()
def
register_identifiable
(
self
,
name
:
str
,
definition
:
db
.
RecordType
):
self
.
_registered_identifiables
[
name
]
=
definition
def
get_file
(
self
,
record
:
db
.
File
):
if
record
.
path
is
None
:
def
get_file
(
self
,
identifiable
:
db
.
File
):
if
identifiable
.
path
is
None
:
raise
RuntimeError
(
"
Path must not be None for File retrieval.
"
)
candidates
=
db
.
execute_query
(
"
FIND File which is stored at {}
"
.
format
(
record
.
path
))
identifiable
.
path
))
if
len
(
candidates
)
>
1
:
raise
RuntimeError
(
"
Identifiable was not defined unambigiously.
"
)
if
len
(
candidates
)
==
0
:
...
...
@@ -399,13 +402,9 @@ class CaosDBIdentifiableAdapter(IdentifiableAdapter):
"""
if
record
.
id
is
None
:
return
record
# breakpoint()
# raise NotImplementedError()
return
record
.
id
def
retrieve_identified_record
(
self
,
identifiable
:
db
.
Record
):
# if identifiable.parents[0].name == "Measurement":
# breakpoint()
query_string
=
self
.
create_query_for_identifiable
(
identifiable
)
candidates
=
db
.
execute_query
(
query_string
)
if
len
(
candidates
)
>
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