-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cluster estimation integration test #251
Open
RohanKatreddy
wants to merge
6
commits into
main
Choose a base branch
from
cluster-estimation-integration-test
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+154
−0
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2e1f340
Nearly completed test (with an unusual error)
RohanKatreddy ebc8470
wrote cluster estimation worker integration test
RohanKatreddy 8bd2fd7
Nearly completed test (with an unusual error)
RohanKatreddy 86456bc
wrote cluster estimation worker integration test
RohanKatreddy cc322ea
Merge branch 'cluster-estimation-integration-test' of github.com:UWAR…
RohanKatreddy 9f67587
Added review changes: type checking, created constants, and import st…
RohanKatreddy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
""" | ||
Test cluster_estimation_worker process. | ||
""" | ||
|
||
import time | ||
import multiprocessing as mp | ||
from typing import List | ||
|
||
import numpy as np | ||
|
||
from utilities.workers import queue_proxy_wrapper, worker_controller | ||
from modules.cluster_estimation.cluster_estimation_worker import cluster_estimation_worker | ||
from modules.detection_in_world import DetectionInWorld | ||
from modules.object_in_world import ObjectInWorld | ||
|
||
MIN_ACTIVATION_THRESHOLD = 3 | ||
MIN_NEW_POINTS_TO_RUN = 0 | ||
MAX_NUM_COMPONENTS = 3 | ||
RANDOM_STATE = 0 | ||
|
||
|
||
def test_cluster_estimation_worker() -> int: | ||
""" | ||
Integration test for cluster estimation worker. | ||
""" | ||
|
||
# Worker and controller setup. | ||
controller = worker_controller.WorkerController() | ||
|
||
mp_manager = mp.Manager() | ||
input_queue = queue_proxy_wrapper.QueueProxyWrapper(mp_manager) | ||
output_queue = queue_proxy_wrapper.QueueProxyWrapper(mp_manager) | ||
|
||
worker_process = mp.Process( | ||
target=cluster_estimation_worker, | ||
args=( | ||
MIN_ACTIVATION_THRESHOLD, | ||
MIN_NEW_POINTS_TO_RUN, | ||
MAX_NUM_COMPONENTS, | ||
RANDOM_STATE, | ||
input_queue, | ||
output_queue, | ||
controller, | ||
), | ||
) | ||
|
||
# Second test set: 1 clusters | ||
test_data_1 = [ | ||
# Landing pad 1 | ||
DetectionInWorld.create( | ||
np.array([[1, 1], [1, 2], [2, 2], [2, 1]]), np.array([1.5, 1.5]), 1, 0.9 | ||
)[1], | ||
DetectionInWorld.create( | ||
np.array([[1, 1], [1, 2], [2, 2], [2, 1]]), np.array([1.5, 1.5]), 1, 0.9 | ||
)[1], | ||
DetectionInWorld.create( | ||
np.array([[1, 1], [1, 2], [2, 2], [2, 1]]), np.array([1.5, 1.5]), 1, 0.9 | ||
)[1], | ||
DetectionInWorld.create( | ||
np.array([[1, 1], [1, 2], [2, 2], [2, 1]]), np.array([1.5, 1.5]), 1, 0.9 | ||
)[1], | ||
DetectionInWorld.create( | ||
np.array([[1, 1], [1, 2], [2, 2], [2, 1]]), np.array([1.5, 1.5]), 1, 0.9 | ||
)[1], | ||
] | ||
|
||
# First test set: 2 clusters | ||
test_data_2 = [ | ||
# Landing pad 1 | ||
DetectionInWorld.create( | ||
np.array([[1, 1], [1, 2], [2, 2], [2, 1]]), np.array([1.5, 1.5]), 1, 0.9 | ||
)[1], | ||
DetectionInWorld.create( | ||
np.array([[1, 1], [1, 2], [2, 2], [2, 1]]), np.array([1.5, 1.5]), 1, 0.9 | ||
)[1], | ||
DetectionInWorld.create( | ||
np.array([[1, 1], [1, 2], [2, 2], [2, 1]]), np.array([1.5, 1.5]), 1, 0.9 | ||
)[1], | ||
DetectionInWorld.create( | ||
np.array([[1, 1], [1, 2], [2, 2], [2, 1]]), np.array([1.5, 1.5]), 1, 0.9 | ||
)[1], | ||
DetectionInWorld.create( | ||
np.array([[1, 1], [1, 2], [2, 2], [2, 1]]), np.array([1.5, 1.5]), 1, 0.9 | ||
)[1], | ||
# Landing pad 2 | ||
DetectionInWorld.create( | ||
np.array([[10, 10], [10, 11], [11, 11], [11, 10]]), np.array([10.5, 10.5]), 1, 0.9 | ||
)[1], | ||
DetectionInWorld.create( | ||
np.array([[10.1, 10.1], [10.1, 11.1], [11.1, 11.1], [11.1, 10.1]]), | ||
np.array([10.6, 10.6]), | ||
1, | ||
0.92, | ||
)[1], | ||
DetectionInWorld.create( | ||
np.array([[9.9, 9.9], [9.9, 10.9], [10.9, 10.9], [10.9, 9.9]]), | ||
np.array([10.4, 10.4]), | ||
1, | ||
0.88, | ||
)[1], | ||
DetectionInWorld.create( | ||
np.array([[10.2, 10.2], [10.2, 11.2], [11.2, 11.2], [11.2, 10.2]]), | ||
np.array([10.7, 10.7]), | ||
1, | ||
0.95, | ||
)[1], | ||
DetectionInWorld.create( | ||
np.array([[10.3, 10.3], [10.3, 11.3], [11.3, 11.3], [11.3, 10.3]]), | ||
np.array([10.8, 10.8]), | ||
1, | ||
0.93, | ||
)[1], | ||
] | ||
|
||
# Testing with test_data_1 (1 cluster) | ||
|
||
input_queue.queue.put(test_data_1) | ||
worker_process.start() | ||
time.sleep(1) | ||
|
||
output_results: List[List[DetectionInWorld]] = output_queue.queue.get() | ||
|
||
assert output_results is not None | ||
assert isinstance(output_results, list) | ||
assert len(output_results) == 1 | ||
assert all(isinstance(obj, ObjectInWorld) for obj in output_results) | ||
|
||
time.sleep(1) | ||
|
||
# Testing with test_data_2 (2 clusters) | ||
|
||
input_queue.queue.put(test_data_2) | ||
time.sleep(1) | ||
|
||
output_results: List[List[DetectionInWorld]] = output_queue.queue.get() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
|
||
assert output_results is not None | ||
assert isinstance(output_results, list) | ||
assert len(output_results) == 2 | ||
assert all(isinstance(obj, ObjectInWorld) for obj in output_results) | ||
|
||
controller.request_exit() | ||
input_queue.queue.put(None) | ||
worker_process.join() | ||
|
||
return 0 | ||
|
||
|
||
if __name__ == "__main__": | ||
result_main = test_cluster_estimation_worker() | ||
if result_main < 0: | ||
print(f"ERROR: Status code: {result_main}") | ||
|
||
print("Done!") |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to check to see if the output result is a list of ObjectInWorld, otherwise the worker wouldnt be doing anything