Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tango
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Insights
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
LOFAR2.0
tango
Commits
203d4ea2
Commit
203d4ea2
authored
Sep 30, 2021
by
Taya Snijder
Browse files
Options
Downloads
Patches
Plain Diff
added support for --fraction parameter
parent
42a543c6
No related branches found
No related tags found
1 merge request
!141
Resolve L2SS-414 "413 2021 09 30 branched from master add writer skip parameter"
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
devices/statistics_writer/hdf5_writer.py
+19
-3
19 additions, 3 deletions
devices/statistics_writer/hdf5_writer.py
devices/statistics_writer/statistics_writer.py
+3
-1
3 additions, 1 deletion
devices/statistics_writer/statistics_writer.py
with
22 additions
and
4 deletions
devices/statistics_writer/hdf5_writer.py
+
19
−
3
View file @
203d4ea2
...
@@ -26,19 +26,22 @@ class hdf5_writer:
...
@@ -26,19 +26,22 @@ class hdf5_writer:
XST_MODE
=
"
XST
"
XST_MODE
=
"
XST
"
BST_MODE
=
"
BST
"
BST_MODE
=
"
BST
"
def
__init__
(
self
,
new_file_time_interval
,
file_location
,
statistics_mode
,
store_fraction
):
def
__init__
(
self
,
new_file_time_interval
,
file_location
,
statistics_mode
):
# all variables that deal with the matrix that's currently being decoded
# all variables that deal with the matrix that's currently being decoded
self
.
current_matrix
=
None
self
.
current_matrix
=
None
self
.
current_timestamp
=
datetime
.
min
.
replace
(
tzinfo
=
pytz
.
UTC
)
self
.
current_timestamp
=
datetime
.
min
.
replace
(
tzinfo
=
pytz
.
UTC
)
# counter that tracks how many statistics have been received
self
.
statistics_counter
=
-
1
# the header of the first packet of a new matrix is written as metadata.
# the header of the first packet of a new matrix is written as metadata.
# Assumes all subsequent headers of the same matrix are identical (minus index)
# Assumes all subsequent headers of the same matrix are identical (minus index)
self
.
statistics_header
=
None
self
.
statistics_header
=
None
# file handing
# file handing
self
.
file_location
=
file_location
self
.
file_location
=
file_location
self
.
store_fraction
=
store_fraction
self
.
new_file_time_interval
=
timedelta
(
seconds
=
new_file_time_interval
)
self
.
new_file_time_interval
=
timedelta
(
seconds
=
new_file_time_interval
)
self
.
last_file_time
=
datetime
.
min
.
replace
(
tzinfo
=
pytz
.
UTC
)
self
.
last_file_time
=
datetime
.
min
.
replace
(
tzinfo
=
pytz
.
UTC
)
self
.
file
=
None
self
.
file
=
None
...
@@ -88,13 +91,22 @@ class hdf5_writer:
...
@@ -88,13 +91,22 @@ class hdf5_writer:
self
.
process_packet
(
packet
)
self
.
process_packet
(
packet
)
def
start_new_matrix
(
self
,
timestamp
):
def
start_new_matrix
(
self
,
timestamp
):
logger
.
info
(
f
"
starting new matrix with timestamp:
{
timestamp
}
"
)
"""
"""
is called when a statistics packet with a newer timestamp is received.
is called when a statistics packet with a newer timestamp is received.
Writes the matrix to the hdf5 file
Writes the matrix to the hdf5 file
Creates a new hdf5 file if needed
Creates a new hdf5 file if needed
updates current timestamp and statistics matrix collector
updates current timestamp and statistics matrix collector
"""
"""
# received new statistic, so increment counter
self
.
statistics_counter
+=
1
# only write the specified fraction of statistics, skip the rest
if
self
.
statistics_counter
%
self
.
store_fraction
!=
0
:
logger
.
info
(
f
"
Skipping statistic with timestamp:
{
timestamp
}
. Only writing 1/
{
self
.
store_fraction
}
statistics
"
)
return
logger
.
info
(
f
"
starting new matrix with timestamp:
{
timestamp
}
"
)
# write the finished (and checks if its the first matrix)
# write the finished (and checks if its the first matrix)
if
self
.
current_matrix
is
not
None
:
if
self
.
current_matrix
is
not
None
:
...
@@ -159,6 +171,10 @@ class hdf5_writer:
...
@@ -159,6 +171,10 @@ class hdf5_writer:
"""
"""
Adds the newly received statistics packet to the statistics matrix
Adds the newly received statistics packet to the statistics matrix
"""
"""
# only process the packets of the wanted fraction
if
self
.
statistics_counter
%
self
.
store_fraction
!=
0
:
return
self
.
current_matrix
.
process_packet
(
packet
)
self
.
current_matrix
.
process_packet
(
packet
)
def
start_new_hdf5
(
self
,
timestamp
):
def
start_new_hdf5
(
self
,
timestamp
):
...
...
This diff is collapsed.
Click to expand it.
devices/statistics_writer/statistics_writer.py
+
3
−
1
View file @
203d4ea2
...
@@ -18,6 +18,7 @@ parser.add_argument('--mode', type=str, choices=['SST', 'XST', 'BST'], default='
...
@@ -18,6 +18,7 @@ parser.add_argument('--mode', type=str, choices=['SST', 'XST', 'BST'], default='
parser
.
add_argument
(
'
--interval
'
,
type
=
float
,
default
=
3600
,
nargs
=
"
?
"
,
help
=
'
The time between creating new files in seconds (default: %(default)s)
'
)
parser
.
add_argument
(
'
--interval
'
,
type
=
float
,
default
=
3600
,
nargs
=
"
?
"
,
help
=
'
The time between creating new files in seconds (default: %(default)s)
'
)
parser
.
add_argument
(
'
--output_dir
'
,
type
=
str
,
default
=
"
.
"
,
nargs
=
"
?
"
,
help
=
'
specifies the folder to write all the files (default: %(default)s)
'
)
parser
.
add_argument
(
'
--output_dir
'
,
type
=
str
,
default
=
"
.
"
,
nargs
=
"
?
"
,
help
=
'
specifies the folder to write all the files (default: %(default)s)
'
)
parser
.
add_argument
(
'
--debug
'
,
dest
=
'
debug
'
,
action
=
'
store_true
'
,
default
=
False
,
help
=
'
increase log output
'
)
parser
.
add_argument
(
'
--debug
'
,
dest
=
'
debug
'
,
action
=
'
store_true
'
,
default
=
False
,
help
=
'
increase log output
'
)
parser
.
add_argument
(
'
--fraction
'
,
type
=
int
,
default
=
1
,
help
=
'
Fraction of statistics written to file to save space. When used only writes 1/n statistics
'
)
# create a data dumper that creates a new file every 10s (for testing)
# create a data dumper that creates a new file every 10s (for testing)
...
@@ -32,6 +33,7 @@ if __name__ == "__main__":
...
@@ -32,6 +33,7 @@ if __name__ == "__main__":
interval
=
args
.
interval
interval
=
args
.
interval
mode
=
args
.
mode
mode
=
args
.
mode
debug
=
args
.
debug
debug
=
args
.
debug
fraction
=
args
.
fraction
if
port
==
0
:
if
port
==
0
:
default_ports
=
{
"
SST
"
:
5101
,
"
XST
"
:
5102
,
"
BST
"
:
5103
}
default_ports
=
{
"
SST
"
:
5101
,
"
XST
"
:
5102
,
"
BST
"
:
5103
}
...
@@ -51,7 +53,7 @@ if __name__ == "__main__":
...
@@ -51,7 +53,7 @@ if __name__ == "__main__":
sys
.
exit
(
1
)
sys
.
exit
(
1
)
# create the writer
# create the writer
writer
=
hdf5_writer
(
new_file_time_interval
=
interval
,
file_location
=
output_dir
,
statistics_mode
=
mode
)
writer
=
hdf5_writer
(
new_file_time_interval
=
interval
,
file_location
=
output_dir
,
statistics_mode
=
mode
,
store_fraction
=
fraction
)
# start looping
# start looping
try
:
try
:
...
...
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