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

[Core][MappingApplication] Make MapperFactory use Registry #12542

Merged
merged 5 commits into from
Jul 16, 2024

Conversation

jcotela
Copy link
Member

@jcotela jcotela commented Jul 15, 2024

📝 Description
Refactoring the MapperFactory in order to use the Registry infrastructure instead of its internal registered_mappers list.

The motivation for the change is related to the new gtests and the need to load application dependencies dynamically. Consider a test suite that loads MappingApplication as a runtime dependency (because the tested application does not have compile-time dependencies to it and does not link to it)

  1. Kratos Core imported (including MapperFactory)
  2. MappingApplication imported dynamically on SetUpTestSuite
  3. For each test:
    3.1 Mappers registered in MapperFactory on each test start (when the test suite imports its dependencies in the kernel)
    3.2 Test run
    3.3 Applications de-registered
  4. MappingApplication unloaded on TearDownTestSuite
  5. MapperFactory mapper list deallocated, but the mapper class definitions are no longer available -> Memory error

If the MapperFactory uses the registry instead, mappers are automatically registered when MapperApplication is de-registered in 3.3, so the deallocation in 5 is no longer a problem.

🆕 Changelog

  • MapperFactory uses Registry to hold registered mappers instead of an internal static variable.

@jcotela jcotela requested review from a team as code owners July 15, 2024 10:31
@jcotela jcotela self-assigned this Jul 15, 2024
@loumalouomega loumalouomega changed the title [core] Make MapperFactory use Registry [Core][MappingApplication] Make MapperFactory use Registry Jul 15, 2024
@loumalouomega loumalouomega added Kratos Core Applications Refactor When code is moved or rewrote keeping the same behavior Update API Refactor code to the new API labels Jul 15, 2024
Copy link
Member

@loumalouomega loumalouomega left a comment

Choose a reason for hiding this comment

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

Okay from my side, maybe we should wait for @philbucher approval

philbucher
philbucher previously approved these changes Jul 15, 2024
Comment on lines +168 to +170
return std::string("mappers.all.mpi");
}
return std::string("mappers.all");
Copy link
Member

Choose a reason for hiding this comment

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

those names are only internally used in the registry right? I.e. nothing the user has to deal with?

Copy link
Member Author

Choose a reason for hiding this comment

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

The users of MapperFactory should be able to continue interacting with it as usual. One could get the mappers directly form the registry using those paths, but this is not used at the moment.

@jcotela
Copy link
Member Author

jcotela commented Jul 15, 2024

Sorry, I forgot to remove some debug messages

@jcotela jcotela merged commit a355e9a into master Jul 16, 2024
9 of 11 checks passed
@jcotela jcotela deleted the core/mapper-factory-use-registry branch July 16, 2024 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Applications Kratos Core Refactor When code is moved or rewrote keeping the same behavior Update API Refactor code to the new API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants