Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
Stingray
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LOFAR2.0
Stingray
Commits
41383d82
Commit
41383d82
authored
7 months ago
by
Jan David Mol
Browse files
Options
Downloads
Patches
Plain Diff
Wait for longer for data to appear
parent
48cb8e20
No related branches found
Branches containing commit
No related tags found
1 merge request
!13
Wait for longer for data to appear
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lofar_stingray/aggregate.py
+8
-3
8 additions, 3 deletions
lofar_stingray/aggregate.py
lofar_stingray/reader/_s3_packet_loader.py
+8
-7
8 additions, 7 deletions
lofar_stingray/reader/_s3_packet_loader.py
tests/reader/test_s3_packet_loader.py
+10
-9
10 additions, 9 deletions
tests/reader/test_s3_packet_loader.py
with
26 additions
and
19 deletions
lofar_stingray/aggregate.py
+
8
−
3
View file @
41383d82
...
@@ -95,12 +95,17 @@ def main() -> int:
...
@@ -95,12 +95,17 @@ def main() -> int:
minio_client
,
minio_client
,
)
)
# wait for data to arrive on S3
# wait for metadata to arrive on S3. files can have data 10 minutes old,
# so we need to wait for files 10 minutes younger.
logger
.
info
(
"
Waiting for metadata to arrive on S3 for %s
"
,
args
.
begin
)
logger
.
info
(
"
Waiting for metadata to arrive on S3 for %s
"
,
args
.
begin
)
if
not
metadata_storage
.
wait_for_packets
(
args
.
begin
):
if
not
metadata_storage
.
wait_for_filenames_after
(
args
.
begin
+
timedelta
(
minutes
=
10
)
):
logger
.
error
(
"
Metadata not available on S3
"
)
logger
.
error
(
"
Metadata not available on S3
"
)
# wait for data to arrive on S3.
logger
.
info
(
"
Waiting for statistics to arrive on S3 for %s
"
,
args
.
end
)
logger
.
info
(
"
Waiting for statistics to arrive on S3 for %s
"
,
args
.
end
)
if
not
statistics_storage
.
wait_for_
packets
(
args
.
end
):
if
not
statistics_storage
.
wait_for_
filenames_after
(
args
.
end
+
timedelta
(
seconds
=
5
)
):
logger
.
error
(
"
Statistics not available on S3
"
)
logger
.
error
(
"
Statistics not available on S3
"
)
return
1
# this is fatal
return
1
# this is fatal
...
...
This diff is collapsed.
Click to expand it.
lofar_stingray/reader/_s3_packet_loader.py
+
8
−
7
View file @
41383d82
...
@@ -60,15 +60,15 @@ class S3PacketLoader: # pylint: disable=too-few-public-methods
...
@@ -60,15 +60,15 @@ class S3PacketLoader: # pylint: disable=too-few-public-methods
f
"
{
timestamp
.
day
:
02
d
}
/
{
timestamp
.
isoformat
()
}
.json
"
,
f
"
{
timestamp
.
day
:
02
d
}
/
{
timestamp
.
isoformat
()
}
.json
"
,
)
)
def
wait_for_
packets
(
self
,
timestamp
:
datetime
)
->
bool
:
def
wait_for_
filenames_after
(
self
,
timestamp
:
datetime
)
->
bool
:
"""
Wait until
packets for
the given timestamp are on disk.
"""
Wait until
filenames with
the given timestamp are on disk.
Returns whether such
packet
s were found.
"""
Returns whether such
file
s were found.
"""
# if the packets are there, always return True
# if the packets are there, always return True
if
next
(
self
.
_list_objects_after
(
timestamp
),
False
):
if
next
(
self
.
_list_objects_after
(
timestamp
),
False
):
logger
.
info
(
logger
.
info
(
"
wait_for_
packets
: Requested timestamp are available at startup
"
"
wait_for_
filenames_after
: Requested timestamp are available at startup
"
)
)
return
True
return
True
...
@@ -81,7 +81,7 @@ class S3PacketLoader: # pylint: disable=too-few-public-methods
...
@@ -81,7 +81,7 @@ class S3PacketLoader: # pylint: disable=too-few-public-methods
max_wait_time
:
=
max_arrival_time
-
datetime
.
now
(
tz
=
timestamp
.
tzinfo
)
max_wait_time
:
=
max_arrival_time
-
datetime
.
now
(
tz
=
timestamp
.
tzinfo
)
)
>
timedelta
(
0
):
)
>
timedelta
(
0
):
logger
.
info
(
logger
.
info
(
"
wait_for_
packets
: Requested timestamp are not available,
"
"
wait_for_
filenames_after
: Requested timestamp are not available,
"
"
will wait at most %s for them
"
,
"
will wait at most %s for them
"
,
max_wait_time
,
max_wait_time
,
)
)
...
@@ -91,13 +91,14 @@ class S3PacketLoader: # pylint: disable=too-few-public-methods
...
@@ -91,13 +91,14 @@ class S3PacketLoader: # pylint: disable=too-few-public-methods
if
next
(
self
.
_list_objects_after
(
timestamp
),
False
):
if
next
(
self
.
_list_objects_after
(
timestamp
),
False
):
logger
.
info
(
logger
.
info
(
"
wait_for_packets: Requested timestamp appeared after waiting %s
"
,
"
wait_for_filenames_after: Requested timestamp appeared
"
"
after waiting %s
"
,
datetime
.
now
(
tz
=
timestamp
.
tzinfo
)
-
start_time
,
datetime
.
now
(
tz
=
timestamp
.
tzinfo
)
-
start_time
,
)
)
return
True
return
True
logger
.
info
(
logger
.
info
(
"
wait_for_
packets
: Requested timestamp are NOT available,
"
"
wait_for_
filenames_after
: Requested timestamp are NOT available,
"
"
even after waiting for %s
"
,
"
even after waiting for %s
"
,
datetime
.
now
(
tz
=
timestamp
.
tzinfo
)
-
start_time
,
datetime
.
now
(
tz
=
timestamp
.
tzinfo
)
-
start_time
,
)
)
...
...
This diff is collapsed.
Click to expand it.
tests/reader/test_s3_packet_loader.py
+
10
−
9
View file @
41383d82
...
@@ -43,8 +43,8 @@ class TestS3PacketLoader(TestCase):
...
@@ -43,8 +43,8 @@ class TestS3PacketLoader(TestCase):
seconds
=
5
seconds
=
5
)
)
def
test_wait_for_
packets
_already_there
(
self
):
def
test_wait_for_
filenames_after
_already_there
(
self
):
"""
Test wait_for_
packets
for data from the distant past.
"""
"""
Test wait_for_
filenames_after
for data from the distant past.
"""
timestamp
=
datetime
.
fromisoformat
(
"
2024-06-07T13:21:32+00:00
"
)
timestamp
=
datetime
.
fromisoformat
(
"
2024-06-07T13:21:32+00:00
"
)
self
.
mock_minio
.
list_objects
.
return_value
=
iter
(
self
.
mock_minio
.
list_objects
.
return_value
=
iter
(
...
@@ -57,7 +57,7 @@ class TestS3PacketLoader(TestCase):
...
@@ -57,7 +57,7 @@ class TestS3PacketLoader(TestCase):
packet_loader
=
S3PacketLoader
(
"
bucket
"
,
"
prefix/
"
,
self
.
mock_minio
)
packet_loader
=
S3PacketLoader
(
"
bucket
"
,
"
prefix/
"
,
self
.
mock_minio
)
result
=
packet_loader
.
wait_for_
packets
(
timestamp
)
result
=
packet_loader
.
wait_for_
filenames_after
(
timestamp
)
self
.
assertTrue
(
result
)
# objects were returned
self
.
assertTrue
(
result
)
# objects were returned
self
.
mock_minio
.
list_objects
.
assert_called_with
(
self
.
mock_minio
.
list_objects
.
assert_called_with
(
...
@@ -67,8 +67,8 @@ class TestS3PacketLoader(TestCase):
...
@@ -67,8 +67,8 @@ class TestS3PacketLoader(TestCase):
start_after
=
"
prefix/2024/06/07/2024-06-07T13:21:32+00:00.json
"
,
start_after
=
"
prefix/2024/06/07/2024-06-07T13:21:32+00:00.json
"
,
)
)
def
test_wait_for_
packets
_never_arrive
(
self
):
def
test_wait_for_
filenames_after
_never_arrive
(
self
):
"""
Test wait_for_
packets
for future packets that do not arrive.
"""
"""
Test wait_for_
filenames_after
for future packets that do not arrive.
"""
timestamp
=
datetime
.
fromisoformat
(
"
2024-06-07T13:21:32+00:00
"
)
timestamp
=
datetime
.
fromisoformat
(
"
2024-06-07T13:21:32+00:00
"
)
packet_loader
=
S3PacketLoader
(
packet_loader
=
S3PacketLoader
(
...
@@ -82,11 +82,12 @@ class TestS3PacketLoader(TestCase):
...
@@ -82,11 +82,12 @@ class TestS3PacketLoader(TestCase):
]
]
self
.
mock_minio
.
list_objects
.
side_effect
=
[
iter
([])
for
n
in
range
(
50
)]
self
.
mock_minio
.
list_objects
.
side_effect
=
[
iter
([])
for
n
in
range
(
50
)]
result
=
packet_loader
.
wait_for_
packets
(
timestamp
)
result
=
packet_loader
.
wait_for_
filenames_after
(
timestamp
)
self
.
assertFalse
(
result
)
# no objects were returned
self
.
assertFalse
(
result
)
# no objects were returned
def
test_wait_for_packets_arrive_during_wait
(
self
):
def
test_wait_for_filenames_after_arrive_during_wait
(
self
):
"""
Test wait_for_packets for future packets that arrive while waiting.
"""
"""
Test wait_for_filenames_after for future packets that
arrive while waiting.
"""
timestamp
=
datetime
.
fromisoformat
(
"
2024-06-07T13:21:32+00:00
"
)
timestamp
=
datetime
.
fromisoformat
(
"
2024-06-07T13:21:32+00:00
"
)
packet_loader
=
S3PacketLoader
(
packet_loader
=
S3PacketLoader
(
...
@@ -101,7 +102,7 @@ class TestS3PacketLoader(TestCase):
...
@@ -101,7 +102,7 @@ class TestS3PacketLoader(TestCase):
self
.
mock_minio
.
list_objects
.
side_effect
=
[
iter
([])
for
n
in
range
(
5
)]
+
[
self
.
mock_minio
.
list_objects
.
side_effect
=
[
iter
([])
for
n
in
range
(
5
)]
+
[
iter
([
Mock
(
object_name
=
"
file3
"
)]),
iter
([
Mock
(
object_name
=
"
file3
"
)]),
]
]
result
=
packet_loader
.
wait_for_
packets
(
timestamp
)
result
=
packet_loader
.
wait_for_
filenames_after
(
timestamp
)
self
.
assertTrue
(
result
)
# objects were returned
self
.
assertTrue
(
result
)
# objects were returned
def
test_load_packets
(
self
):
def
test_load_packets
(
self
):
...
...
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