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

Support for Aggregate CAS Multiplier #25

Open
wants to merge 23 commits into
base: main
Choose a base branch
from

Conversation

mac-op
Copy link
Contributor

@mac-op mac-op commented Aug 20, 2024

What's in the PR

  • This PR introduces support for Aggregate CAS Multipliers and the supporting facilities. Additions include:
  • FlowController and its child class FixedFlowController [1]. Custom Flow Controllers and Flow Controller descriptor files are not yet added.
  • Step class and Flow interface [2].
  • New CAS::release method to allow the CAS to release itself, similar to the Java API [3].
  • New error message type and ID in case of invalid CAS release.
  • New exception: EngineProcessingException.
  • Changes in internal API:
    • New constructor for CASPool to allow it to keep track of its AnnotatorContext owner.

Tests
The first test case added in #22 is now passing. The second test case should still be revised, as outlined in #24
Edit: #24 is now covered after the latest commit.

mac-op and others added 14 commits July 18, 2024 20:19
TODO: Documentation and exception handling
No longer have  to cast FlowController to FixedFlowController when we want to find an engine
Also introduced new Exception: EngineProcessingException
FlowController is not deleted on destruction
The constructor for the UNSPECIFIED case didn't initialize the union properly, so when SimpleStep's assignment operator is called later on it can segfault when assigning string.
The union needed to be properly destroyed in assignment operator, and initialized in copy constructor and AO
This introduces a new error ID and error message UIMA_MSG_ID_EXC_INVALID_CAS_RELEASE
Copy link
Contributor

@DrDub DrDub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

annotator_mgr diff is very big and full of whitespace changes. Please remove all the whitespace changes from this diff in all files, especially in annotator_mgr so I can finish the review.

@@ -635,9 +636,9 @@ void mainTest(uima::util::ConsoleUI & rclConsole,
testCallingSequence2(rclConsole, cpszConfigFilename);
testCallingSequence3(rclConsole, cpszConfigFilename);
}
testCasMultiplier(rclConsole);
testCasMultiplier(rclConsole); testAggregateCASMultiplier(rclConsole);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why ran it three times?

src/test/src/test_engine.cpp Show resolved Hide resolved
src/test/data/descriptors/SimpleTextSegmenter.xml Outdated Show resolved Hide resolved
src/framework/uima/msgstrtab.h Show resolved Hide resolved
@@ -64,6 +64,10 @@ namespace uima {
/* Types / Classes */
/* ----------------------------------------------------------------------- */
namespace uima {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So there's no other exception already defined by the framework that we could use? The framework already declares other 80 exceptions:

uima-uimacpp/src$ find . -name \*.hpp -exec grep -H  UIMA_EXC_CLASSDECLARE \{} \;
./cas/uima/featurestructure.hpp:  UIMA_EXC_CLASSDECLARE(InvalidFSObjectException, CASException);
./cas/uima/featurestructure.hpp:  UIMA_EXC_CLASSDECLARE(FeatureNotAppropriateException, CASException);
./cas/uima/featurestructure.hpp:  UIMA_EXC_CLASSDECLARE(IncompatibleValueTypeException, CASException);
./cas/uima/featurestructure.hpp:  UIMA_EXC_CLASSDECLARE(FSIsNotStringException, CASException);
./cas/uima/featurestructure.hpp:  UIMA_EXC_CLASSDECLARE(WrongStringValueException, CASException);
./cas/uima/arrayfs.hpp:  UIMA_EXC_CLASSDECLARE(FSIsNotArrayException, CASException);
./cas/uima/arrayfs.hpp:  UIMA_EXC_CLASSDECLARE(FSArrayOutOfBoundsException, CASException);
./cas/uima/fsindexrepository.hpp:  UIMA_EXC_CLASSDECLARE(InvalidIndexIDException, CASException);
./cas/uima/typesystem.hpp:  UIMA_EXC_CLASSDECLARE(TypeSystemAlreadyCommittedException, CASException);
./cas/uima/typesystem.hpp:  UIMA_EXC_CLASSDECLARE(InvalidFSFeatureObjectException, CASException);
./cas/uima/typesystem.hpp:  UIMA_EXC_CLASSDECLARE(InvalidFSTypeObjectException, CASException);
./cas/uima/casexception.hpp:  UIMA_EXC_CLASSDECLARE(CASException, Exception);
./cas/uima/casexception.hpp:  UIMA_EXC_CLASSDECLARE(NotYetImplementedException, CASException);
./cas/uima/casexception.hpp:  UIMA_EXC_CLASSDECLARE(SofaDataStreamException, CASException);
./cas/uima/cas.hpp:  UIMA_EXC_CLASSDECLARE(CouldNotCreateFSOfFinalTypeException, CASException);
./cas/uima/cas.hpp:  UIMA_EXC_CLASSDECLARE(DuplicateSofaNameException, CASException);
./cas/uima/cas.hpp:  UIMA_EXC_CLASSDECLARE(InvalidBaseCasMethod, CASException);
./cas/uima/xmltypesystemreader.hpp:  UIMA_EXC_CLASSDECLARE(XMLTypeSystemReaderException, uima::Exception);
./cas/uima/lowlevel_typesystem.hpp:    UIMA_EXC_CLASSDECLARE(FeatureIntroductionFailedException, CASException);
./cas/uima/lowlevel_typesystem.hpp:    UIMA_EXC_CLASSDECLARE(TypeCreationFailedException, CASException);
./cas/uima/fsindex.hpp:  UIMA_EXC_CLASSDECLARE(InvalidIndexObjectException, CASException);
./cas/uima/fsindex.hpp:  UIMA_EXC_CLASSDECLARE(WrongFSTypeForIndexException, CASException);
./cas/uima/listfs.hpp:  UIMA_EXC_CLASSDECLARE(FSIsNotListException, CASException);
./cas/uima/listfs.hpp:  UIMA_EXC_CLASSDECLARE(ListIsEmptyException, CASException);
./cas/uima/listfs.hpp:  UIMA_EXC_CLASSDECLARE(ListIsCircularException, CASException);
./cas/uima/internal_casdeserializer.hpp:    UIMA_EXC_CLASSDECLARE(DeserializationException, Exception);
./framework/uima/exceptions.hpp:   UIMA_EXCEPTION_DESCRIPTION, UIMA_EXC_CLASSDECLARE, UIMA_EXC_CLASSIMPLEMENT,
./framework/uima/exceptions.hpp:     <TT>UIMA_EXC_CLASSDECLARE</TT> in an .h/.hpp file there must be one use of
./framework/uima/exceptions.hpp:#define UIMA_EXC_CLASSDECLARE(child,parent)                                    \
./framework/uima/exceptions.hpp:     <TT>UIMA_EXC_CLASSDECLARE</TT> (see above) in the corresponding .h/.hpp file
./framework/uima/exceptions.hpp:  UIMA_EXC_CLASSDECLARE(Uima_logic_error,      Exception);
./framework/uima/exceptions.hpp:  UIMA_EXC_CLASSDECLARE(Uima_runtime_error,    Exception);
./framework/uima/exceptions.hpp:  UIMA_EXC_CLASSDECLARE(Uima_domain_error,     Uima_logic_error);
./framework/uima/exceptions.hpp:  UIMA_EXC_CLASSDECLARE(Uima_invalid_argument, Uima_logic_error);
./framework/uima/exceptions.hpp:  UIMA_EXC_CLASSDECLARE(Uima_length_error,     Uima_logic_error);
./framework/uima/exceptions.hpp:  UIMA_EXC_CLASSDECLARE(Uima_out_of_range,     Uima_logic_error);
./framework/uima/exceptions.hpp:  UIMA_EXC_CLASSDECLARE(Uima_range_error,      Uima_runtime_error);
./framework/uima/exceptions.hpp:  UIMA_EXC_CLASSDECLARE(Uima_overflow_error,   Uima_runtime_error);
./framework/uima/exceptions.hpp:  UIMA_EXC_CLASSDECLARE(Uima_underflow_error,  Uima_runtime_error);
./framework/uima/exceptions.hpp:  UIMA_EXC_CLASSDECLARE(ConsoleAbortExc,         Exception);
./framework/uima/exceptions.hpp:  UIMA_EXC_CLASSDECLARE(ExcDocBuffer,            Uima_out_of_range);
./framework/uima/exceptions.hpp:  UIMA_EXC_CLASSDECLARE(ParseHandlerExc,         Exception);
./framework/uima/exceptions.hpp://? UIMA_EXC_CLASSDECLARE(ExcAccessError,      Uima_runtime_error);
./framework/uima/exceptions.hpp://? UIMA_EXC_CLASSDECLARE(ExcAssertionFailure, Exception);
./framework/uima/exceptions.hpp:  UIMA_EXC_CLASSDECLARE(ExcIllFormedInputError,  Uima_runtime_error);
./framework/uima/exceptions.hpp:  UIMA_EXC_CLASSDECLARE(ExcInvalidParameter,     Uima_invalid_argument);
./framework/uima/exceptions.hpp:  UIMA_EXC_CLASSDECLARE(ExcIndexOutOfRange,      Uima_out_of_range);
./framework/uima/exceptions.hpp://? UIMA_EXC_CLASSDECLARE(ExcDeviceError,      _runtime_error);
./framework/uima/exceptions.hpp:  UIMA_EXC_CLASSDECLARE(ExcInvalidRequest,       Uima_runtime_error);
./framework/uima/exceptions.hpp:  UIMA_EXC_CLASSDECLARE(ExcResourceExhausted,    Uima_runtime_error);
./framework/uima/exceptions.hpp:  UIMA_EXC_CLASSDECLARE(ExcOutOfMemory,          ExcResourceExhausted);
./framework/uima/exceptions.hpp://? UIMA_EXC_CLASSDECLARE(ExcOutOfSystemResource, ResourceExhausted);
./framework/uima/exceptions.hpp://? UIMA_EXC_CLASSDECLARE(ExcOutOfWindowResource, ResourceExhausted);
./framework/uima/exceptions.hpp:  UIMA_EXC_CLASSDECLARE(ExcFileNotFoundError,    Uima_runtime_error);
./framework/uima/exceptions.hpp:  UIMA_EXC_CLASSDECLARE(ExcWinCException,        Uima_runtime_error);
./framework/uima/exceptions.hpp:  UIMA_EXC_CLASSDECLARE(CodePageConversionException, Exception);
./framework/uima/exceptions.hpp:  UIMA_EXC_CLASSDECLARE(AprFailureException, Exception);
./framework/uima/exceptions.hpp:  To declare a new exception class, use the <TT>UIMA_EXC_CLASSDECLARE</TT> macro in an .h/.hpp
./framework/uima/exceptions.hpp:     UIMA_EXC_CLASSDECLARE(AnnotatorException, InvalidRequest);
./framework/uima/casiterator.hpp:  UIMA_EXC_CLASSDECLARE(CASIteratorException, uima::Exception);
./framework/uima/engine.hpp:  UIMA_EXC_CLASSDECLARE(UnknownTypeException, Exception);
./framework/uima/engine.hpp:  UIMA_EXC_CLASSDECLARE(UnknownFeatureException, Exception);
./framework/uima/engine.hpp:  UIMA_EXC_CLASSDECLARE(UnknownRangeTypeException, Exception);
./framework/uima/engine.hpp:  UIMA_EXC_CLASSDECLARE(IncompatibleRangeTypeException, Exception);
./framework/uima/engine.hpp:  UIMA_EXC_CLASSDECLARE(AllowedStringValuesIncompatibleException, Exception);
./framework/uima/engine.hpp:  UIMA_EXC_CLASSDECLARE(TypePriorityConflictException, Exception);
./framework/uima/engine.hpp:  UIMA_EXC_CLASSDECLARE(IncompatibleIndexDefinitionsException, Exception);
./framework/uima/engine.hpp:  UIMA_EXC_CLASSDECLARE(IncompatibleParentTypesException, Exception);
./framework/uima/engine.hpp:  UIMA_EXC_CLASSDECLARE(CASIncompatibilityException, Exception);
./framework/uima/engine.hpp:  UIMA_EXC_CLASSDECLARE(UimaAnalysisComponentException, Exception);
./framework/uima/internal_jedii_engine.hpp:    UIMA_EXC_CLASSDECLARE(JavaException, Exception);
./framework/uima/internal_capability_container.hpp:  UIMA_EXC_CLASSDECLARE(CapabilityException, Exception);
./framework/uima/taespecifierbuilder.hpp:  UIMA_EXC_CLASSDECLARE(InvalidXMLException, uima::Exception);
./framework/uima/caspool.hpp:  UIMA_EXC_CLASSDECLARE(CASPoolException, uima::Exception);
./framework/uima/taespecifier.hpp:  UIMA_EXC_CLASSDECLARE(ConfigParamLookupException, ConfigException);
./framework/uima/taemetadata.hpp:  UIMA_EXC_CLASSDECLARE(DuplicateConfigElemException, uima::Exception);
./framework/uima/taemetadata.hpp:  UIMA_EXC_CLASSDECLARE(ValidationException, uima::Exception);
./framework/uima/annotator.hpp:  UIMA_EXC_CLASSDECLARE(ExcEnumerationOverflow, ExcIllFormedInputError);
./framework/uima/config_param.hpp:  UIMA_EXC_CLASSDECLARE(ConfigException, Exception);
./framework/uima/config_param.hpp:  UIMA_EXC_CLASSDECLARE(ConfigParamException, ConfigException);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you say UimaAnalysisComponentException is appropriate?

src/framework/annotator_mgr.cpp Outdated Show resolved Hide resolved
src/framework/annotator_mgr.cpp Outdated Show resolved Hide resolved
src/framework/annotator_mgr.cpp Outdated Show resolved Hide resolved
src/framework/annotator_mgr.cpp Outdated Show resolved Hide resolved
src/cas/cas.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@DrDub DrDub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still a few questions and comments but overall I managed to go through the whole thing this time.

I'll now proceed to stress test it a bit.

src/test/src/test_engine.cpp Outdated Show resolved Hide resolved
@@ -77,12 +77,12 @@
</array>
</value>
</nameValuePair>
<nameValuePair>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems like something didn't need to be committed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This override would fail the test case for the newer override spec. Do you want me to keep it for now and deal with the test case later, or just remove that portion?

src/framework/annotator_mgr.cpp Outdated Show resolved Hide resolved
src/framework/annotator_mgr.cpp Show resolved Hide resolved
return nullptr;
}

if (iv_bOutputNewCases && !finalStep->getForceDropCAS())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to double check I'm understanding the code correctly, this is where the DROP_IF_NEW_CAS_PRODUCED functionality is implemented?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes the finalStep will determine if that CAS is dropped or not. In this instance that finalStep is constructed by the FixedFlowController and FixedFlowObject, and the default action in the FixedFlowController is DROP_IF_NEW_CAS_PRODUCED

if (!result)
result = processUntilNextOutputCas();
if (!result) {
UIMA_EXC_THROW_NEW(Exception,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this call also release()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No when it is returned to the caller/user they will call release themselves. Or do you mean something else?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants