Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.bio.base
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
bob
bob.bio.base
Commits
b590fed2
Commit
b590fed2
authored
9 years ago
by
Manuel Günther
Browse files
Options
Downloads
Patches
Plain Diff
Improved FileSet object
parent
87811a90
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bob/bio/base/database/utils.py
+13
-19
13 additions, 19 deletions
bob/bio/base/database/utils.py
bob/bio/base/test/dummy/fileset.py
+4
-3
4 additions, 3 deletions
bob/bio/base/test/dummy/fileset.py
with
17 additions
and
22 deletions
bob/bio/base/database/utils.py
+
13
−
19
View file @
b590fed2
...
@@ -40,36 +40,30 @@ class FileSet:
...
@@ -40,36 +40,30 @@ class FileSet:
Use this class, whenever the database provides several files that belong to the same probe.
Use this class, whenever the database provides several files that belong to the same probe.
Each file set has an id, an associated client (aka. identity, person, user), and a list of associated files.
Each file set has an id, and a list of associated files, which are of type :py:class:`File` of the same client.
Usually, these files are part of a database, which has a common directory for all files.
The file set id can be anything hashable, but needs to be unique all over the database.
The paths of this file set are usually *relative* to that common directory, and they are usually stored *without* filename extension.
The file id can be anything hashable, but needs to be unique all over the database.
The client id can be anything hashable, but needs to be identical for different files of the same client, and different between clients.
**Parameters:**
**Parameters:**
file_id : str or int
file_set_id : str or int
A unique ID that identifies the file.
A unique ID that identifies the file set.
This ID might be identical to the ``path``, though integral IDs perform faster.
client_id : str or int
A unique ID that identifies the client (user) to which this file belongs.
This ID might be the name of the person, though integral IDs perform faster.
path : str
files : [:py:class:`File`]
The file path of the file, which is relative to the common database directory, and without filename extension.
A list of File objects that should be stored inside this file.
All files of that list need to have the same client ID.
"""
"""
def
__init__
(
self
,
file_set_id
,
client_id
,
file_set_nam
e
):
def
__init__
(
self
,
file_set_id
,
files
,
path
=
Non
e
):
# The **unique** id of the file set
# The **unique** id of the file set
self
.
id
=
file_set_id
self
.
id
=
file_set_id
# The id of the client that is attached to the file
# The id of the client that is attached to the file
self
.
client_id
=
client_id
assert
len
(
files
)
# A name of the file set
self
.
client_id
=
files
[
0
].
client_id
self
.
path
=
file_set_name
assert
all
(
f
.
client_id
==
self
.
client_id
for
f
in
files
)
# The list of files contained in this set
# The list of files contained in this set
self
.
files
=
[]
self
.
files
=
files
def
__lt__
(
self
,
other
):
def
__lt__
(
self
,
other
):
"""
Defines an order between file sets by using the order of the file set ids.
"""
# compare two File set objects by comparing their IDs
# compare two File set objects by comparing their IDs
return
self
.
id
<
other
.
id
return
self
.
id
<
other
.
id
This diff is collapsed.
Click to expand it.
bob/bio/base/test/dummy/fileset.py
+
4
−
3
View file @
b590fed2
import
bob.db.atnt
import
bob.db.atnt
import
os
import
os
from
bob.bio.base.database
import
DatabaseBob
,
DatabaseBobZT
,
FileSet
from
bob.bio.base.database
import
DatabaseBob
,
DatabaseBobZT
,
File
,
FileSet
from
bob.bio.base.test.utils
import
atnt_database_directory
from
bob.bio.base.test.utils
import
atnt_database_directory
class
FileSetDatabase
(
DatabaseBobZT
):
class
FileSetDatabase
(
DatabaseBobZT
):
...
@@ -28,9 +28,10 @@ class FileSetDatabase (DatabaseBobZT):
...
@@ -28,9 +28,10 @@ class FileSetDatabase (DatabaseBobZT):
# arrange files by clients
# arrange files by clients
file_sets
=
[]
file_sets
=
[]
for
client_files
in
files
:
for
client_files
in
files
:
# convert into our File objects (so that they are tested as well)
our_files
=
[
File
(
f
.
id
,
f
.
client_id
,
f
.
path
)
for
f
in
client_files
]
# generate file set for each client
# generate file set for each client
file_set
=
FileSet
(
client_files
[
0
].
client_id
,
client_files
[
0
].
client_id
,
client_files
[
0
].
path
)
file_set
=
FileSet
(
our_files
[
0
].
client_id
,
our_files
)
file_set
.
files
=
client_files
file_sets
.
append
(
file_set
)
file_sets
.
append
(
file_set
)
return
file_sets
return
file_sets
...
...
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