Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bob
bob.bio.base
Commits
04ff36c2
Commit
04ff36c2
authored
Sep 02, 2016
by
Manuel Günther
Committed by
Tiago de Freitas Pereira
Sep 15, 2016
Browse files
Updated dummy databases to work with bob.db.atnt directly and return BioFile or BioFileSet objects
parent
1d88685f
Changes
2
Hide whitespace changes
Inline
Side-by-side
bob/bio/base/test/dummy/database.py
View file @
04ff36c2
from
bob.bio.db
import
ZTBioDatabase
,
AtntBioDatabas
e
from
bob.bio.db
import
ZTBioDatabase
,
BioFil
e
from
bob.bio.base.test.utils
import
atnt_database_directory
...
...
@@ -14,13 +14,17 @@ class DummyDatabase(ZTBioDatabase):
training_depends_on_protocol
=
False
,
models_depend_on_protocol
=
False
)
self
.
__db
=
AtntBioDatabase
()
import
bob.db.atnt
self
.
__db
=
bob
.
db
.
atnt
.
Database
()
def
_make_bio
(
self
,
files
):
return
[
BioFile
(
client_id
=
f
.
client_id
,
path
=
f
.
path
,
file_id
=
f
.
id
)
for
f
in
files
]
def
model_ids_with_protocol
(
self
,
groups
=
None
,
protocol
=
None
,
**
kwargs
):
return
self
.
__db
.
model_ids
_with_protocol
(
groups
,
protocol
)
return
self
.
__db
.
model_ids
(
groups
,
protocol
)
def
objects
(
self
,
groups
=
None
,
protocol
=
None
,
purposes
=
None
,
model_ids
=
None
,
**
kwargs
):
return
self
.
__db
.
objects
(
group
s
,
p
ro
tocol
,
purposes
,
model_ids
,
**
kwargs
)
return
self
.
_make_bio
(
self
.
__db
.
objects
(
model_id
s
,
g
ro
ups
,
purposes
,
protocol
,
**
kwargs
)
)
def
tobjects
(
self
,
groups
=
None
,
protocol
=
None
,
model_ids
=
None
,
**
kwargs
):
return
[]
...
...
@@ -29,7 +33,7 @@ class DummyDatabase(ZTBioDatabase):
return
[]
def
tmodel_ids_with_protocol
(
self
,
protocol
=
None
,
groups
=
None
,
**
kwargs
):
return
self
.
__db
.
model_ids
_with_protocol
(
groups
,
protocol
)
return
self
.
__db
.
model_ids
(
groups
)
def
t_enroll_files
(
self
,
t_model_id
,
group
=
'dev'
):
return
self
.
enroll_files
(
t_model_id
,
group
)
...
...
bob/bio/base/test/dummy/fileset.py
View file @
04ff36c2
from
bob.bio.db
import
ZTBioDatabase
,
BioFileSet
,
BioFile
from
bob.bio.base.test.utils
import
atnt_database_directory
class
DummyDatabase
(
ZTBioDatabase
):
def
__init__
(
self
):
...
...
@@ -20,25 +19,21 @@ class DummyDatabase(ZTBioDatabase):
def
uses_probe_file_sets
(
self
):
return
True
def
_make_bio
(
self
,
files
):
return
[
BioFile
(
client_id
=
f
.
client_id
,
path
=
f
.
path
,
file_id
=
f
.
id
)
for
f
in
files
]
def
probe_file_sets
(
self
,
model_id
=
None
,
group
=
'dev'
):
"""Returns the list of probe File objects (for the given model id, if given)."""
# import ipdb; ipdb.set_trace()
files
=
self
.
arrange_by_client
(
self
.
sort
(
self
.
objects
(
protocol
=
None
,
groups
=
group
,
purposes
=
'probe'
)))
# arrange files by clients
file_sets
=
[]
for
client_files
in
files
:
# convert into our File objects (so that they are tested as well)
our_files
=
[
BioFile
(
f
.
client_id
,
f
.
path
,
f
.
id
)
for
f
in
client_files
]
# generate file set for each client
file_set
=
BioFileSet
(
our_files
[
0
].
client_id
,
our_files
)
file_sets
.
append
(
file_set
)
file_sets
=
[
BioFileSet
(
client_files
[
0
].
client_id
,
client_files
)
for
client_files
in
files
]
return
file_sets
def
model_ids_with_protocol
(
self
,
groups
=
None
,
protocol
=
None
,
**
kwargs
):
return
self
.
__db
.
model_ids
(
groups
,
protocol
)
def
objects
(
self
,
groups
=
None
,
protocol
=
None
,
purposes
=
None
,
model_ids
=
None
,
**
kwargs
):
return
self
.
__db
.
objects
(
model_ids
,
groups
,
purposes
,
protocol
,
**
kwargs
)
return
self
.
_make_bio
(
self
.
__db
.
objects
(
model_ids
,
groups
,
purposes
,
protocol
,
**
kwargs
)
)
def
tobjects
(
self
,
groups
=
None
,
protocol
=
None
,
model_ids
=
None
,
**
kwargs
):
return
[]
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment