Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
beat.backend.python
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
beat
beat.backend.python
Commits
647fe253
Commit
647fe253
authored
May 14, 2020
by
Samuel GAIST
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[data_loaders] Add reset in the same idea as DataSource
parent
bc8cb7f7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
0 deletions
+27
-0
beat/backend/python/data_loaders.py
beat/backend/python/data_loaders.py
+8
-0
beat/backend/python/test/test_data_loaders.py
beat/backend/python/test/test_data_loaders.py
+19
-0
No files found.
beat/backend/python/data_loaders.py
View file @
647fe253
...
...
@@ -210,6 +210,14 @@ class DataLoader(object):
self
.
data_index_start
=
-
1
# Lower index across all inputs
self
.
data_index_end
=
-
1
# Bigger index across all inputs
def
reset
(
self
):
"""Reset all the data sources"""
for
infos
in
self
.
infos
.
values
():
data_source
=
infos
.
get
(
"data_source"
)
if
data_source
:
data_source
.
reset
()
def
add
(
self
,
input_name
,
data_source
):
self
.
infos
[
input_name
]
=
dict
(
data_source
=
data_source
,
...
...
beat/backend/python/test/test_data_loaders.py
View file @
647fe253
...
...
@@ -630,6 +630,25 @@ class DataLoaderTest(DataLoaderBaseTest):
view
=
data_loader
.
view
(
"input2"
,
2
)
self
.
assertTrue
(
view
is
None
)
def
test_reset
(
self
):
# Setup
input_name
=
"input1"
self
.
writeData
(
input_name
,
[(
0
,
0
),
(
1
,
1
),
(
2
,
2
)],
1000
)
data_loader
=
DataLoader
(
"channel1"
)
cached_file
=
CachedDataSource
()
cached_file
.
setup
(
self
.
filenames
[
input_name
],
prefix
)
data_loader
.
add
(
input_name
,
cached_file
)
_
,
_
,
_
=
data_loader
[
0
]
cached_source
=
data_loader
.
infos
[
input_name
][
"data_source"
]
self
.
assertIsNotNone
(
cached_source
.
current_file_index
)
self
.
assertIsNotNone
(
cached_source
.
current_file
)
data_loader
.
reset
()
self
.
assertIsNone
(
cached_source
.
current_file_index
)
self
.
assertIsNone
(
cached_source
.
current_file
)
# ----------------------------------------------------------
...
...
Write
Preview
Markdown
is supported
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