Skip to content
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

Feat/wfm trigger #1644

Merged
merged 39 commits into from Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
ae5a988
Add trigger support to workflow manager
brosenberg42 Feb 6, 2023
0f5a186
Refactor trigger
brosenberg42 Feb 7, 2023
c00cc06
Apply triggers to all previous tasks
brosenberg42 Feb 9, 2023
62152a4
Fix derivative media
brosenberg42 Feb 9, 2023
984d3ae
Use MockitoTest base class
brosenberg42 Feb 9, 2023
153bdc2
Fix test
brosenberg42 Feb 10, 2023
c06ff4a
Merge branch 'develop' into feat/wfm-trigger
brosenberg42 May 25, 2023
9bc681d
Merge branch 'develop' into feat/wfm-trigger
brosenberg42 Jun 8, 2023
0ff5076
Address PR issues
brosenberg42 Jul 6, 2023
1499e12
Fix OUTPUT_LAST_TASK_ONLY
brosenberg42 Jul 18, 2023
1db6e21
Fix TestRedis
brosenberg42 Jul 18, 2023
8a86ae1
Add missing header
brosenberg42 Jul 18, 2023
883972e
Address PR issues
brosenberg42 Jul 27, 2023
a8faa79
Apply trigger filter before getting next set of tracks.
brosenberg42 Jul 28, 2023
adf8a77
Fix task merging
brosenberg42 Aug 9, 2023
a6e70c5
Add trackType to Algorithm
brosenberg42 Aug 15, 2023
e04e3b3
Allow multiple trigger values
brosenberg42 Aug 25, 2023
c425657
Get rid of detectionType
brosenberg42 Aug 25, 2023
556cb5f
Remove redundant templates in mpf-system-tests.
brosenberg42 Aug 28, 2023
fee9d3c
Fix task merging
brosenberg42 Aug 28, 2023
8e2b797
Remove detectionType from streaming
brosenberg42 Aug 28, 2023
f24cc3f
Remove remaining references to detectionType
brosenberg42 Aug 29, 2023
4f7cbb7
Fix sortJsonActionOutputObjectSets
brosenberg42 Aug 29, 2023
d589c1e
Fix sortJsonActionOutputObjectSets
brosenberg42 Aug 29, 2023
930dfae
Fix switched actual and expected params
brosenberg42 Aug 30, 2023
38b04ef
Comments and clean up
brosenberg42 Aug 31, 2023
3ea1f4e
Simplify TaskMergingManager.
brosenberg42 Sep 1, 2023
3e653e8
Clean up
brosenberg42 Sep 5, 2023
fe3a69a
Add trackType to CplusplusHelloWorld
brosenberg42 Sep 5, 2023
3047abc
Merge branch 'develop' into feat/wfm-trigger
brosenberg42 Sep 15, 2023
ce57c31
Add action to json output
brosenberg42 Oct 30, 2023
85aeb04
Merge branch 'develop' into feat/wfm-trigger
brosenberg42 Oct 30, 2023
68b314c
Fix test
brosenberg42 Oct 30, 2023
383d34b
Address PR issues
brosenberg42 Oct 30, 2023
30f7b05
Update missing action output.
brosenberg42 Nov 1, 2023
7debbe8
Update system tests.
brosenberg42 Nov 1, 2023
414ece9
Fix system test
brosenberg42 Nov 1, 2023
672b2f3
Merge branch 'develop' into feat/wfm-trigger
brosenberg42 Nov 8, 2023
1827882
Address PR issues
brosenberg42 Nov 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 0 additions & 4 deletions trunk/detection/executor/cpp/batch/CppComponentHandle.cpp
Expand Up @@ -51,10 +51,6 @@ namespace MPF::COMPONENT {
return component_->Init();
}

std::string CppComponentHandle::GetDetectionType() {
return component_->GetDetectionType();
}

bool CppComponentHandle::Supports(MPFDetectionDataType data_type) {
return component_->Supports(data_type);
}
Expand Down
2 changes: 0 additions & 2 deletions trunk/detection/executor/cpp/batch/CppComponentHandle.h
Expand Up @@ -47,8 +47,6 @@ namespace MPF::COMPONENT {

bool Init();

std::string GetDetectionType();

bool Supports(MPFDetectionDataType data_type);

std::vector<MPFVideoTrack> GetDetections(const MPFVideoJob &job);
Expand Down
8 changes: 0 additions & 8 deletions trunk/detection/executor/cpp/batch/MPFDetectionBuffer.cpp
Expand Up @@ -202,7 +202,6 @@ std::vector<unsigned char> MPFDetectionBuffer::PackVideoResponse(
const MPFDetectionDataType data_type,
const int start_frame,
const int stop_frame,
const string &detection_type,
const MPFDetectionError error,
const std::string &error_message) const {

Expand All @@ -212,7 +211,6 @@ std::vector<unsigned char> MPFDetectionBuffer::PackVideoResponse(
DetectionResponse_VideoResponse *video_response = detection_response.add_video_responses();
video_response->set_start_frame(start_frame);
video_response->set_stop_frame(stop_frame);
video_response->set_detection_type(detection_type);

for (vector<MPFVideoTrack>::const_iterator tracks_iter = tracks.begin(); tracks_iter != tracks.end(); tracks_iter++) {
MPFVideoTrack track = *tracks_iter;
Expand Down Expand Up @@ -258,7 +256,6 @@ std::vector<unsigned char> MPFDetectionBuffer::PackAudioResponse(
const MPFDetectionDataType data_type,
const int start_time,
const int stop_time,
const string &detection_type,
const MPFDetectionError error,
const std::string &error_message) const {

Expand All @@ -268,7 +265,6 @@ std::vector<unsigned char> MPFDetectionBuffer::PackAudioResponse(
DetectionResponse_AudioResponse *audio_response = detection_response.add_audio_responses();
audio_response->set_start_time(start_time);
audio_response->set_stop_time(stop_time);
audio_response->set_detection_type(detection_type);

for (vector<MPFAudioTrack>::const_iterator tracks_iter = tracks.begin(); tracks_iter != tracks.end(); tracks_iter++) {
MPFAudioTrack track = *tracks_iter;
Expand All @@ -290,15 +286,13 @@ std::vector<unsigned char> MPFDetectionBuffer::PackImageResponse(
const vector<MPFImageLocation> &locations,
const MPFMessageMetadata &msg_metadata,
const MPFDetectionDataType data_type,
const string &detection_type,
const MPFDetectionError error,
const std::string &error_message) const {

DetectionResponse detection_response;
PackCommonFields(msg_metadata, data_type, error, error_message, detection_response);

DetectionResponse_ImageResponse *image_response = detection_response.add_image_responses();
image_response->set_detection_type(detection_type);

for (vector<MPFImageLocation>::const_iterator locations_iter = locations.begin(); locations_iter != locations.end(); locations_iter++) {
MPFImageLocation detection = *(locations_iter);
Expand All @@ -323,15 +317,13 @@ std::vector<unsigned char> MPFDetectionBuffer::PackGenericResponse(
const vector<MPFGenericTrack> &tracks,
const MPFMessageMetadata &msg_metadata,
const MPFDetectionDataType data_type,
const string &detection_type,
const MPFDetectionError error,
const std::string &error_message) const {

DetectionResponse detection_response;
PackCommonFields(msg_metadata, data_type, error, error_message, detection_response);

DetectionResponse_GenericResponse *generic_response = detection_response.add_generic_responses();
generic_response->set_detection_type(detection_type);

for (vector<MPFGenericTrack>::const_iterator tracks_iter = tracks.begin(); tracks_iter != tracks.end(); tracks_iter++) {
MPFGenericTrack track = *tracks_iter;
Expand Down
4 changes: 0 additions & 4 deletions trunk/detection/executor/cpp/batch/MPFDetectionBuffer.h
Expand Up @@ -135,7 +135,6 @@ class MPFDetectionBuffer {
const MPFDetectionDataType data_type,
const int start_frame,
const int stop_frame,
const string &detection_type,
const MPFDetectionError error,
const std::string &error_message) const;

Expand All @@ -145,23 +144,20 @@ class MPFDetectionBuffer {
const MPFDetectionDataType data_type,
const int start_time,
const int stop_time,
const string &detection_type,
const MPFDetectionError error,
const std::string &error_message) const;

std::vector<unsigned char> PackImageResponse(
const vector<MPFImageLocation> &locations,
const MPFMessageMetadata &msg_metadata,
const MPFDetectionDataType data_type,
const string &detection_type,
const MPFDetectionError error,
const std::string &error_message) const;

std::vector<unsigned char> PackGenericResponse(
const vector<MPFGenericTrack> &tracks,
const MPFMessageMetadata &msg_metadata,
const MPFDetectionDataType data_type,
const string &detection_type,
const MPFDetectionError error,
const std::string &error_message) const;

Expand Down
22 changes: 1 addition & 21 deletions trunk/detection/executor/cpp/batch/PythonComponentHandle.cpp
Expand Up @@ -441,7 +441,6 @@ namespace MPF::COMPONENT {


struct ComponentAttrs {
std::string detection_type;
py::function get_detections_from_image_method;
py::function get_detections_from_video_method;
py::function get_detections_from_audio_method;
Expand All @@ -454,8 +453,7 @@ namespace MPF::COMPONENT {
}

explicit ComponentAttrs(py::object &&component_instance)
: detection_type(GetDetectionType(component_instance))
, get_detections_from_image_method(get_method(component_instance, "get_detections_from_image"))
: get_detections_from_image_method(get_method(component_instance, "get_detections_from_image"))
, get_detections_from_video_method(get_method(component_instance, "get_detections_from_video"))
, get_detections_from_audio_method(get_method(component_instance, "get_detections_from_audio"))
, get_detections_from_generic_method(get_method(component_instance, "get_detections_from_generic"))
Expand All @@ -471,14 +469,6 @@ namespace MPF::COMPONENT {
"or get_detections_from_generic.");
}
}

private:
static std::string GetDetectionType(py::handle obj) {
if (!py::hasattr(obj, "detection_type")) {
throw ComponentLoadError("The Python component does not contain a field named \"detection_type\".");
}
return to_std_string(obj.attr("detection_type"));
}
};

struct LoggerAttrs {
Expand Down Expand Up @@ -562,11 +552,6 @@ namespace MPF::COMPONENT {
}
}

std::string GetDetectionType() const {
return component_.detection_type;
}


std::vector<MPFVideoTrack> GetDetections(const MPFVideoJob &job) {
try {
if (component_.get_detections_from_video_method.is_none()) {
Expand Down Expand Up @@ -732,11 +717,6 @@ namespace MPF::COMPONENT {
}


std::string PythonComponentHandle::GetDetectionType() {
return impl_->GetDetectionType();
}


bool PythonComponentHandle::Supports(MPFDetectionDataType data_type) {
return impl_->Supports(data_type);
}
Expand Down
2 changes: 0 additions & 2 deletions trunk/detection/executor/cpp/batch/PythonComponentHandle.h
Expand Up @@ -52,8 +52,6 @@ namespace MPF::COMPONENT {

bool Init();

std::string GetDetectionType();

bool Supports(MPFDetectionDataType data_type);

std::vector<MPFVideoTrack> GetDetections(const MPFVideoJob &job);
Expand Down
10 changes: 4 additions & 6 deletions trunk/detection/executor/cpp/batch/main.cpp
Expand Up @@ -371,8 +371,6 @@ int run_jobs(Logger &logger, const std::string &broker_uri, const std::string &r
auto ctx = logger.GetJobContext(job_name);
logger.Info("Processing message on ", service_name, '.');

string detection_type = detection_engine.GetDetectionType();

if (detection_engine.Supports(data_type)) {
MPFDetectionError rc = MPF_DETECTION_SUCCESS;
std::string error_message;
Expand Down Expand Up @@ -424,7 +422,7 @@ int run_jobs(Logger &logger, const std::string &broker_uri, const std::string &r
detection_response_body = detection_buf.PackVideoResponse(
tracks, msg_metadata, data_type,
video_request.start_frame, video_request.stop_frame,
detection_type, rc, error_message);
rc, error_message);

} else if (data_type == MPFDetectionDataType::AUDIO) {
vector <MPFAudioTrack> tracks;
Expand Down Expand Up @@ -474,7 +472,7 @@ int run_jobs(Logger &logger, const std::string &broker_uri, const std::string &r
detection_response_body = detection_buf.PackAudioResponse(
tracks, msg_metadata, data_type,
audio_request.start_time, audio_request.stop_time,
detection_type, rc, error_message);
rc, error_message);

} else if (data_type == MPFDetectionDataType::IMAGE) {
vector <MPFImageLocation> locations;
Expand Down Expand Up @@ -518,7 +516,7 @@ int run_jobs(Logger &logger, const std::string &broker_uri, const std::string &r

// Pack image response
detection_response_body = detection_buf.PackImageResponse(
locations, msg_metadata, data_type, detection_type, rc, error_message);
locations, msg_metadata, data_type, rc, error_message);

} else {
vector <MPFGenericTrack> tracks;
Expand Down Expand Up @@ -563,7 +561,7 @@ int run_jobs(Logger &logger, const std::string &broker_uri, const std::string &r

// Pack generic response
detection_response_body = detection_buf.PackGenericResponse(
tracks, msg_metadata, data_type, detection_type, rc, error_message);
tracks, msg_metadata, data_type, rc, error_message);
}

} else {
Expand Down
Expand Up @@ -145,8 +145,6 @@ void assert_has_echo_properties(const Properties &properties) {

TEST(PythonComponentHandleTest, TestImageJob) {
PythonComponentHandle py_component = get_test_component();
ASSERT_EQ(py_component.GetDetectionType(), "TEST DETECTION TYPE");

MPFImageJob job("Test Job Name", "path/to/media",
{ { "job prop 1" , "job val 1" }, job_echo_pair },
{ { "media prop 1" , "media val 1" }, media_echo_pair });
Expand Down
Expand Up @@ -32,8 +32,6 @@


class GenericTestComponent(object):
detection_type = 'TEST GENERIC DETECTION TYPE'


@staticmethod
def get_detections_from_generic(generic_job):
Expand Down
Expand Up @@ -31,7 +31,6 @@
logger = logging.getLogger('TestComponent')

class TestComponent(object):
detection_type = 'TEST DETECTION TYPE'

def __init__(self):
logger.info('Creating instance of TestComponent')
Expand Down
Expand Up @@ -173,9 +173,6 @@ PYBIND11_MODULE(mpf_cpp_sdk, m) {
.def("Close",
[](CppComponent& c) { return c->Close(); },
call_guard_t())
.def("GetDetectionType",
[](CppComponent& c) { return c->GetDetectionType(); },
call_guard_t())
.def("Supports",
[](CppComponent& c, MPFDetectionDataType type) { return c->Supports(type); },
"data_type"_a,
Expand Down
Expand Up @@ -97,7 +97,6 @@ namespace MPF { namespace COMPONENT {


void BasicAmqMessageSender::SendSummaryReport(int frame_number,
const std::string &detection_type,
const std::vector<MPFVideoTrack> &tracks,
const std::unordered_map<int, long> &frame_timestamps,
const std::string &error_message) {
Expand All @@ -107,7 +106,6 @@ namespace MPF { namespace COMPONENT {
protobuf_response.set_segment_number(segment_number);
protobuf_response.set_segment_start_frame(segment_size_ * segment_number);
protobuf_response.set_segment_stop_frame(frame_number);
protobuf_response.set_detection_type(detection_type);
if (!error_message.empty()) {
protobuf_response.set_error(error_message);
}
Expand Down
Expand Up @@ -58,7 +58,7 @@ namespace MPF { namespace COMPONENT {
void SendActivityAlert(int frame_number, long timestamp);

void SendSummaryReport(
int frame_number, const std::string &detection_type,
int frame_number,
const std::vector<MPF::COMPONENT::MPFVideoTrack> &tracks,
const std::unordered_map<int, long> &frame_timestamps,
const std::string &error_message = {});
Expand Down
Expand Up @@ -69,7 +69,6 @@ class AMQSegmentSummaryConverter : public AMQMessageConverter<MPFSegmentSummaryM
int seg_num = -1;
int start_frame = -1;
int stop_frame = -1;
std::string detection_type;
MPF::COMPONENT::MPFDetectionError err = MPF::COMPONENT::MPFDetectionError::MPF_DETECTION_SUCCESS;

const cms::BytesMessage &bytes_msg = dynamic_cast<const cms::BytesMessage&>(msg);
Expand All @@ -82,7 +81,6 @@ class AMQSegmentSummaryConverter : public AMQMessageConverter<MPFSegmentSummaryM
seg_num = response.segment_number();
start_frame = response.start_frame();
stop_frame = response.stop_frame();
detection_type = response.detection_type();
err = translateProtobufError(response.error());
for (auto &msg_track : response.video_tracks()) {
MPF::COMPONENT::MPFVideoTrack mpf_track;
Expand Down Expand Up @@ -117,8 +115,7 @@ class AMQSegmentSummaryConverter : public AMQMessageConverter<MPFSegmentSummaryM
return MPFSegmentSummaryMessage(msg.getStringProperty("JOB_NAME"),
msg.getIntProperty("JOB_ID"),
seg_num, start_frame, stop_frame,
detection_type, err,
mpfTracks);
err, mpfTracks);
}

virtual void toCMSMessage(const MPFSegmentSummaryMessage &mpfMsg, cms::Message &msg) override {
Expand All @@ -132,7 +129,6 @@ class AMQSegmentSummaryConverter : public AMQMessageConverter<MPFSegmentSummaryM
response.set_segment_number(mpfMsg.segment_number_);
response.set_start_frame(mpfMsg.segment_start_frame_);
response.set_stop_frame(mpfMsg.segment_stop_frame_);
response.set_detection_type(mpfMsg.detection_type_);
response.set_error(translateMPFDetectionError(mpfMsg.segment_error_));

for (auto &track : mpfMsg.tracks_) {
Expand Down
Expand Up @@ -51,7 +51,6 @@ struct MPFSegmentSummaryMessage : MPFMessage {
int segment_number_;
int segment_start_frame_;
int segment_stop_frame_;
std::string detection_type_; // such as: "FACE", "PERSON", "MOTION"
MPF::COMPONENT::MPFDetectionError segment_error_;
std::vector<MPF::COMPONENT::MPFVideoTrack> tracks_;
MPFSegmentSummaryMessage() = default;
Expand All @@ -60,14 +59,12 @@ struct MPFSegmentSummaryMessage : MPFMessage {
const int seg_num,
const int start_frame,
const int stop_frame,
const std::string type,
MPF::COMPONENT::MPFDetectionError error,
const std::vector<MPF::COMPONENT::MPFVideoTrack> &tracks)
: MPFMessage(job_name, job_number),
segment_number_(seg_num),
segment_start_frame_(start_frame),
segment_stop_frame_(stop_frame),
detection_type_(type),
segment_error_(error),
tracks_(tracks) {}
~MPFSegmentSummaryMessage() = default;
Expand Down
Expand Up @@ -244,7 +244,6 @@ TEST_F(AMQMessengerTest, TestSegmentSummaryMessage) {
EXPECT_EQ(seg_num, dst_msg.segment_number_);
EXPECT_EQ(start_frame, dst_msg.segment_start_frame_);
EXPECT_EQ(stop_frame, dst_msg.segment_stop_frame_);
EXPECT_EQ(type, dst_msg.detection_type_);
EXPECT_EQ(err, dst_msg.segment_error_);

// Check the segment summary tracks
Expand Down