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

Refactor/remove codegen #65

Merged
merged 26 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
dbdadaa
refactor: update agents API
MakarenkoAI Sep 17, 2024
29079de
tests: update agents
MakarenkoAI Sep 17, 2024
28f5121
tests: clang refactoring
MakarenkoAI Sep 17, 2024
3964c28
docs: update changelog
MakarenkoAI Sep 17, 2024
786103d
fix: review fixes
MakarenkoAI Sep 18, 2024
dcb209a
kb: replace question by action
MakarenkoAI Oct 7, 2024
e5b6ee7
docs: replace question by action
MakarenkoAI Oct 7, 2024
80ece5b
refactor: update metasystem, fix warnings
MakarenkoAI Oct 29, 2024
a910497
refactor: change ScTypes on the new format
MakarenkoAI Oct 30, 2024
f69443b
fix: scweb repo path
Malina09 Nov 4, 2024
b98404a
refactor: update scs types
MakarenkoAI Nov 8, 2024
6f1b28a
fix(script): set_vars
MakarenkoAI Nov 8, 2024
636dd94
fix(scripts): set_vars
MakarenkoAI Nov 8, 2024
af2f35f
fix(kb): update scs types
MakarenkoAI Nov 9, 2024
d24c5d0
fix(scripts): use sc-machine with scripts
MakarenkoAI Nov 12, 2024
101f53e
fix(config): update ini-file
MakarenkoAI Nov 12, 2024
00ace2f
fix(config): activate env for sc-web and py-server
MakarenkoAI Nov 12, 2024
ee88e61
fix(kb): fix lang_en in user interface
Malina09 Nov 20, 2024
484fc8b
fix(kb): remove action from ui menu
MakarenkoAI Nov 25, 2024
19c7c66
fix(kb): remove action from tests in scs files
MakarenkoAI Nov 25, 2024
c97a1e5
fix(scripts): update sc-machine and sc-web commits
MakarenkoAI Nov 25, 2024
cf8f625
fix: add sc-core dependency in tests.cmake
MakarenkoAI Nov 26, 2024
15713d4
fix(cmake): add cmake-flags
MakarenkoAI Dec 3, 2024
d2dab86
refactor: sort includes
NikitaZotov Dec 3, 2024
d8dd2f1
feat(docs): update changelog
MakarenkoAI Dec 8, 2024
367c730
refactor(ps): use clang-formatter
MakarenkoAI Dec 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.11)
cmake_minimum_required(VERSION 3.14)
project(ostis-metasystem)
set(CMAKE_CXX_STANDARD 17)

Expand All @@ -15,18 +15,19 @@ link_directories(${SC_BIN_PATH} ${SC_EXTENSIONS_DIRECTORY})

set(SC_MACHINE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/ostis-web-platform/sc-machine")
set(CMAKE_MODULE_PATH "${SC_MACHINE_PATH}/cmake")
include("${CMAKE_MODULE_PATH}/codegen.cmake")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")

if(${SC_CLANG_FORMAT_CODE})
include(${CMAKE_MODULE_PATH}/ClangFormat.cmake)
endif()

set(SC_MEMORY_SRC "${SC_MACHINE_PATH}/sc-memory/")
set(SC_KPM_SRC "${SC_MACHINE_PATH}/sc-kpm/")
set(SC_TOOLS_SRC "${SC_MACHINE_PATH}/sc-tools/")
set(SC_MEMORY_INCLUDE "${SC_MACHINE_PATH}/sc-memory/sc-memory/include")
set(SC_AGENTS_COMMON_INCLUDE "${SC_MACHINE_PATH}/sc-kpm/sc-agents-common/include")
set(SC_CORE_INCLUDE "${SC_MACHINE_PATH}/sc-memory/sc-core/include")
set(SC_BUILDER_INCLUDE "${SC_MACHINE_PATH}/sc-tools/sc-builder/include")
set(SC_CONFIG_INCLUDE "${SC_MACHINE_PATH}/sc-tools/sc-config/include")

include("${CMAKE_CURRENT_SOURCE_DIR}/dependencies.cmake")
sc_target_dependencies()
include(CTest)

# for multi-config builds (e.g. msvc)
foreach(OUTPUT_CONFIG ${CMAKE_CONFIGURATION_TYPES})
Expand Down
18 changes: 0 additions & 18 deletions dependencies.cmake

This file was deleted.

3 changes: 3 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added build of sc-machine and manager in `install_metasystem.sh`

### Changed
- This version of the Metasystem is not supported on macOS.
- Rename questions to actions
- Use `build_platform.sh` instead of `build_sc_machine.sh`
- Update ostis-web-platform to develop-branch

Expand All @@ -24,3 +26,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Deprecated

### Removed
- Remove codegen for agents
Binary file modified docs/images/translate_agent_input.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions ostis-metasystem.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ max_events_and_agents_threads = 32
dump_memory_period = 3600
dump_memory_statistics_period = 1800

repo_path = kb.bin
extensions_path = bin/extensions
storage = kb.bin
extensions = bin/extensions

log_type = Console
log_file = sc-memory.log
Expand Down
2 changes: 0 additions & 2 deletions platform-dependent-components/problem-solver/cxx/.gitignore

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ set(IDENTIFIERS_MODULE_SRC "${CMAKE_CURRENT_LIST_DIR}")
set(SOURCES
"agent/translate_main_system_idtfs_from_sc_to_file_agent.cpp"
"agent/translate_main_system_idtfs_from_sc_to_file_agent.hpp"
"keynodes/identifiers_keynodes.cpp"
"keynodes/identifiers_keynodes.hpp"
"identifiers_module.cpp"
"identifiers_module.hpp"
Expand All @@ -16,12 +15,12 @@ target_link_libraries(identifiers-module
)
target_include_directories(identifiers-module
PUBLIC ${IDENTIFIERS_MODULE_SRC}
PUBLIC ${SC_MEMORY_SRC}
PUBLIC ${SC_KPM_SRC}
PUBLIC ${SC_MEMORY_INCLUDE}
PUBLIC ${SC_CORE_INCLUDE}
PUBLIC ${SC_AGENTS_COMMON_INCLUDE}
PUBLIC ${SC_BUILDER_INCLUDE}
)

sc_codegen_ex(identifiers-module ${IDENTIFIERS_MODULE_SRC} ${IDENTIFIERS_MODULE_SRC}/generated)

if(${SC_CLANG_FORMAT_CODE})
target_clangformat_setup(identifiers-module)
endif()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,20 @@
* (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
*/

#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)
{
ScAddr const & actionAddr = otherAddr;
#include <sc-memory/sc_memory.hpp>

if (!CheckAction(actionAddr))
return SC_RESULT_OK;

SC_LOG_DEBUG("TranslateMainSystemIdtfsFromScToFileAgent started");
#include "keynodes/identifiers_keynodes.hpp"

// TODO: replace by CoreKeynodes::nrel_system_identifier after release
ScAddr const & nrelSystemIdtf = m_memoryCtx.HelperFindBySystemIdtf("nrel_system_identifier");
using namespace identifiersModule;

ScResult TranslateMainSystemIdtfsFromScToFileAgent::DoProgram(ScAction & action)
{
std::stringstream streamIdtfs;

ScIterator3Ptr const & iterator3PtrEdgeBelongsToNrelSystemIdtf =
m_memoryCtx.Iterator3(nrelSystemIdtf, ScType::EdgeAccessConstPosPerm, ScType::EdgeDCommonConst);
m_context.CreateIterator3(ScKeynodes::nrel_system_identifier, ScType::ConstPermPosArc, ScType::ConstCommonArc);

ScAddr edgeBelongsToNrelSystemIdtf;
ScAddr sourceOfEdgeBelongsToNrelSystemIdtf;
Expand All @@ -38,24 +29,24 @@ 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";
}
}
catch (utils::ScException const & exception)
{
SC_LOG_ERROR(exception.Description());
utils::AgentUtils::finishAgentWork(&m_memoryCtx, actionAddr, false);
return SC_RESULT_ERROR;
return action.FinishUnsuccessfully();
}
}

Expand All @@ -73,76 +64,72 @@ SC_AGENT_IMPLEMENTATION(TranslateMainSystemIdtfsFromScToFileAgent)
bool const & resultOfWrite = WriteInFile(strIdtfs);

if (resultOfWrite)
SC_LOG_DEBUG("File has been created");
{
SC_AGENT_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;
{
SC_AGENT_LOG_ERROR("File hasn't been created");
return action.FinishUnsuccessfully();
}
}

bool TranslateMainSystemIdtfsFromScToFileAgent::CheckAction(ScAddr const & actionAddr)
ScAddr TranslateMainSystemIdtfsFromScToFileAgent::GetActionClass() const
{
return m_memoryCtx.HelperCheckEdge(
IdentifiersKeynodes::action_find_identifiers, actionAddr, ScType::EdgeAccessConstPosPerm);
return IdentifiersKeynodes::action_find_identifiers;
}

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"));
ScType::ConstCommonArc,
ScType::ConstNodeLink,
ScType::ConstPermPosArc,
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::ConstCommonArc, ScType::ConstNodeLink, ScType::ConstPermPosArc, 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::ConstPermPosArc);

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::ConstPermPosArc);

if (isLangRu)
return identifier;
}
m_memoryCtx.GetLinkContent(mainIdentifierLink, identifier);
m_context.GetLinkContent(mainIdentifierLink, identifier);
break;
}
}
Expand All @@ -152,7 +139,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))
Expand Down
Loading
Loading