-
Notifications
You must be signed in to change notification settings - Fork 12
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
Refactor/remove codegen #65
Open
MakarenkoAI
wants to merge
9
commits into
main
Choose a base branch
from
fix/new_api
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.
Open
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ddbc162
[refactor] Update agents API
MakarenkoAI 92c54a2
[tests] Update agents
MakarenkoAI 5f564e2
[refactor][tests] Clang refactoring
MakarenkoAI 64ff45f
[docs] Update changelog
MakarenkoAI f8fd5ca
Review fixes
MakarenkoAI 106ee07
Review fixes
MakarenkoAI 49e420b
Review fixes
MakarenkoAI a85147c
Review fixes
MakarenkoAI 8dd32b5
Review fixes
MakarenkoAI 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
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
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
This file was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
|
@@ -5,28 +5,20 @@ | |
*/ | ||
|
||
#include "sc-agents-common/utils/CommonUtils.hpp" | ||
#include "sc-agents-common/utils/AgentUtils.hpp" | ||
#include "keynodes/identifiers_keynodes.hpp" | ||
#include "translate_main_system_idtfs_from_sc_to_file_agent.hpp" | ||
|
||
using namespace identifiersModule; | ||
|
||
SC_AGENT_IMPLEMENTATION(TranslateMainSystemIdtfsFromScToFileAgent) | ||
ScResult TranslateMainSystemIdtfsFromScToFileAgent::DoProgram(ScActionInitiatedEvent const & event, ScAction & action) | ||
{ | ||
ScAddr const & actionAddr = otherAddr; | ||
|
||
if (!CheckAction(actionAddr)) | ||
return SC_RESULT_OK; | ||
|
||
SC_LOG_DEBUG("TranslateMainSystemIdtfsFromScToFileAgent started"); | ||
|
||
// TODO: replace by CoreKeynodes::nrel_system_identifier after release | ||
ScAddr const & nrelSystemIdtf = m_memoryCtx.HelperFindBySystemIdtf("nrel_system_identifier"); | ||
// TODO: replace by ScKeynodes::nrel_system_identifier after release | ||
ScAddr const & nrelSystemIdtf = m_context.SearchElementBySystemIdentifier("nrel_system_identifier"); | ||
|
||
std::stringstream streamIdtfs; | ||
|
||
ScIterator3Ptr const & iterator3PtrEdgeBelongsToNrelSystemIdtf = | ||
m_memoryCtx.Iterator3(nrelSystemIdtf, ScType::EdgeAccessConstPosPerm, ScType::EdgeDCommonConst); | ||
m_context.CreateIterator3(nrelSystemIdtf, ScType::EdgeAccessConstPosPerm, ScType::EdgeDCommonConst); | ||
|
||
ScAddr edgeBelongsToNrelSystemIdtf; | ||
ScAddr sourceOfEdgeBelongsToNrelSystemIdtf; | ||
|
@@ -38,24 +30,27 @@ SC_AGENT_IMPLEMENTATION(TranslateMainSystemIdtfsFromScToFileAgent) | |
while (iterator3PtrEdgeBelongsToNrelSystemIdtf->Next()) | ||
{ | ||
edgeBelongsToNrelSystemIdtf = iterator3PtrEdgeBelongsToNrelSystemIdtf->Get(2); | ||
sourceOfEdgeBelongsToNrelSystemIdtf = m_memoryCtx.GetEdgeSource(edgeBelongsToNrelSystemIdtf); | ||
sourceOfEdgeBelongsToNrelSystemIdtf = m_context.GetArcSourceElement(edgeBelongsToNrelSystemIdtf); | ||
try | ||
{ | ||
systemIdentifier = GetSystemIdtfAndVerifyNode(m_memoryCtx, sourceOfEdgeBelongsToNrelSystemIdtf); | ||
mainIdentifier = GetMainIdtfAndVerifyNode(m_memoryCtx, sourceOfEdgeBelongsToNrelSystemIdtf); | ||
systemIdentifier = GetSystemIdtfAndVerifyNode(m_context, sourceOfEdgeBelongsToNrelSystemIdtf); | ||
mainIdentifier = GetMainIdtfAndVerifyNode(m_context, sourceOfEdgeBelongsToNrelSystemIdtf); | ||
stringType = GetStrScType(sourceOfEdgeBelongsToNrelSystemIdtf); | ||
|
||
if (!systemIdentifier.empty() && !mainIdentifier.empty() && !stringType.empty()) | ||
{ | ||
streamIdtfs << "{\"" << mainIdentifier << "\", " | ||
<< "{\"" << systemIdentifier << "\", \"" << stringType << "\"}},\n"; | ||
streamIdtfs << R"({")" << mainIdentifier << R"(", )" | ||
<< R"({")" << systemIdentifier << R"(", ")" << stringType << R"("}},\n)"; | ||
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. |
||
} | ||
} | ||
catch (utils::ScException const & exception) | ||
{ | ||
SC_LOG_ERROR(exception.Description()); | ||
utils::AgentUtils::finishAgentWork(&m_memoryCtx, actionAddr, false); | ||
return SC_RESULT_ERROR; | ||
|
||
ScStructure result = m_context.GenerateStructure(); | ||
result << action; | ||
action.SetResult(result); | ||
return action.FinishUnsuccessfully(); | ||
} | ||
} | ||
|
||
|
@@ -73,76 +68,79 @@ SC_AGENT_IMPLEMENTATION(TranslateMainSystemIdtfsFromScToFileAgent) | |
bool const & resultOfWrite = WriteInFile(strIdtfs); | ||
|
||
if (resultOfWrite) | ||
{ | ||
SC_LOG_DEBUG("File has been created"); | ||
return action.FinishSuccessfully(); | ||
} | ||
else | ||
{ | ||
SC_LOG_ERROR("File hasn't been created"); | ||
utils::AgentUtils::finishAgentWork(&m_memoryCtx, actionAddr, resultOfWrite); | ||
SC_LOG_DEBUG("TranslateMainSystemIdtfsFromScToFileAgent finished"); | ||
return SC_RESULT_OK; | ||
return action.FinishUnsuccessfully(); | ||
} | ||
} | ||
|
||
ScAddr TranslateMainSystemIdtfsFromScToFileAgent::GetActionClass() const | ||
{ | ||
return IdentifiersKeynodes::action_find_identifiers; | ||
} | ||
|
||
bool TranslateMainSystemIdtfsFromScToFileAgent::CheckAction(ScAddr const & actionAddr) | ||
kilativ-dotcom marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
return m_memoryCtx.HelperCheckEdge( | ||
return m_context.CheckConnector( | ||
IdentifiersKeynodes::action_find_identifiers, actionAddr, ScType::EdgeAccessConstPosPerm); | ||
} | ||
|
||
std::string TranslateMainSystemIdtfsFromScToFileAgent::GetSystemIdtfAndVerifyNode( | ||
ScMemoryContext & m_memoryCtx, | ||
ScMemoryContext & m_context, | ||
ScAddr const & node) | ||
{ | ||
std::string identifier; | ||
ScAddr identifierLink; | ||
ScIterator5Ptr const & iterator5PtrCheckOnlyOneIdtf = m_memoryCtx.Iterator5( | ||
ScIterator5Ptr const & iterator5PtrCheckOnlyOneIdtf = m_context.CreateIterator5( | ||
node, | ||
ScType::EdgeDCommonConst, | ||
ScType::LinkConst, | ||
ScType::EdgeAccessConstPosPerm, | ||
m_memoryCtx.HelperFindBySystemIdtf("nrel_system_identifier")); | ||
m_context.SearchElementBySystemIdentifier("nrel_system_identifier")); | ||
|
||
if (iterator5PtrCheckOnlyOneIdtf->Next()) | ||
{ | ||
identifierLink = iterator5PtrCheckOnlyOneIdtf->Get(2); | ||
if (iterator5PtrCheckOnlyOneIdtf->Next()) | ||
SC_THROW_EXCEPTION(utils::ScException, "You have more than one system identifier for " + identifier); | ||
m_memoryCtx.GetLinkContent(identifierLink, identifier); | ||
m_context.GetLinkContent(identifierLink, identifier); | ||
} | ||
return identifier; | ||
} | ||
|
||
std::string TranslateMainSystemIdtfsFromScToFileAgent::GetMainIdtfAndVerifyNode( | ||
ScMemoryContext & m_memoryCtx, | ||
ScMemoryContext & m_context, | ||
ScAddr const & node) | ||
{ | ||
std::string identifier; | ||
ScAddr mainIdentifierLink; | ||
ScAddr mainAnotherIdentifierLink; | ||
ScIterator5Ptr const & iterator5PtrCheckOnlyOneIdtf = m_memoryCtx.Iterator5( | ||
node, | ||
ScType::EdgeDCommonConst, | ||
ScType::LinkConst, | ||
ScType::EdgeAccessConstPosPerm, | ||
scAgentsCommon::CoreKeynodes::nrel_main_idtf); | ||
ScIterator5Ptr const & iterator5PtrCheckOnlyOneIdtf = m_context.CreateIterator5( | ||
node, ScType::EdgeDCommonConst, ScType::LinkConst, ScType::EdgeAccessConstPosPerm, ScKeynodes::nrel_main_idtf); | ||
|
||
bool isLangRu; | ||
while (iterator5PtrCheckOnlyOneIdtf->Next()) | ||
{ | ||
mainIdentifierLink = iterator5PtrCheckOnlyOneIdtf->Get(2); | ||
isLangRu = m_memoryCtx.HelperCheckEdge( | ||
scAgentsCommon::CoreKeynodes::lang_ru, mainIdentifierLink, ScType::EdgeAccessConstPosPerm); | ||
isLangRu = m_context.CheckConnector(ScKeynodes::lang_ru, mainIdentifierLink, ScType::EdgeAccessConstPosPerm); | ||
|
||
if (isLangRu) | ||
{ | ||
while (iterator5PtrCheckOnlyOneIdtf->Next()) | ||
{ | ||
mainAnotherIdentifierLink = iterator5PtrCheckOnlyOneIdtf->Get(2); | ||
isLangRu = m_memoryCtx.HelperCheckEdge( | ||
scAgentsCommon::CoreKeynodes::lang_ru, mainAnotherIdentifierLink, ScType::EdgeAccessConstPosPerm); | ||
isLangRu = | ||
m_context.CheckConnector(ScKeynodes::lang_ru, mainAnotherIdentifierLink, ScType::EdgeAccessConstPosPerm); | ||
|
||
if (isLangRu) | ||
return identifier; | ||
} | ||
m_memoryCtx.GetLinkContent(mainIdentifierLink, identifier); | ||
m_context.GetLinkContent(mainIdentifierLink, identifier); | ||
break; | ||
} | ||
} | ||
|
@@ -152,7 +150,7 @@ std::string TranslateMainSystemIdtfsFromScToFileAgent::GetMainIdtfAndVerifyNode( | |
std::string TranslateMainSystemIdtfsFromScToFileAgent::GetStrScType(ScAddr const & node) | ||
{ | ||
std::string strType; | ||
ScType const & type = m_memoryCtx.GetElementType(node); | ||
ScType const & type = m_context.GetElementType(node); | ||
if (ScTypesOfNodesWithSCsClasses.count(type)) | ||
strType = ScTypesOfNodesWithSCsClasses[type]; | ||
else if (ScTypesOfEdgesWithSCsClasses.count(type)) | ||
|
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
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
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
15 changes: 0 additions & 15 deletions
15
...endent-components/problem-solver/cxx/identifiers-module/keynodes/identifiers_keynodes.cpp
This file was deleted.
Oops, something went wrong.
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
2 changes: 1 addition & 1 deletion
2
...nt-components/problem-solver/cxx/identifiers-module/test/test-structures/correct_test.scs
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
test_action_node | ||
<- action_find_identifiers; | ||
<- question;; | ||
<- action;; | ||
|
||
knowledge | ||
<- sc_node_class; | ||
|
2 changes: 1 addition & 1 deletion
2
...-components/problem-solver/cxx/identifiers-module/test/test-structures/incorrect_test.scs
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
test_action_node | ||
<- action_find_identifiers; | ||
<- question;; | ||
<- action;; | ||
|
||
Knowledge | ||
<- sc_node_class; | ||
|
2 changes: 1 addition & 1 deletion
2
...nts/problem-solver/cxx/identifiers-module/test/test-structures/many_system_idtfs_test.scs
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
test_action_node | ||
<- action_find_identifiers; | ||
<- question;; | ||
<- action;; | ||
|
||
Knowledge | ||
<- sc_node_class; | ||
|
2 changes: 1 addition & 1 deletion
2
...ndent-components/problem-solver/cxx/identifiers-module/test/test-structures/void_test.scs
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
test_action_node | ||
<- action_find_identifiers; | ||
<- question;; | ||
<- action;; |
Oops, something went wrong.
Oops, something went wrong.
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.
this agent has question_initiated in docs translate_agent_input.png