-
Notifications
You must be signed in to change notification settings - Fork 2
Mermaid graph #363
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
Merged
Merged
Mermaid graph #363
Changes from 44 commits
Commits
Show all changes
60 commits
Select commit
Hold shift + click to select a range
c4726e3
Start of adding mermaid graphs
jlheflin ce04f9f
Restart addition of mermaid graph, test with hello_world function
jlheflin d00bdb7
Trying to add tests for mermaid.cpp
jlheflin 7259026
just like me, ctest keeps failing
jlheflin 0d6659f
Committing clang-format changes
github-actions[bot] 203a8c8
Update mermaid.cpp
ryanmrichard b08bf98
Update mermaid.cpp
ryanmrichard 6e720d1
Committing clang-format changes
github-actions[bot] 09fb829
Finally actually doing some code
jlheflin 4a419c9
Committing clang-format changes
github-actions[bot] 372538f
Made suggested changes regarding mermaid.cpp, mermaid.hpp and the tes…
jlheflin ee6fdd4
Made changes with usage of decltype
jlheflin f61012b
Preparing to add module with several nested modules
jlheflin 29fe47e
Committing clang-format changes
github-actions[bot] 98746b2
loaded test modules into mm
jlheflin c4ad8dd
Committing clang-format changes
github-actions[bot] 0177e4f
adjusted code to work since it didn't in the previous commit
jlheflin ff92d0c
Lego'd the modules, compiled normally?
jlheflin a06ae22
added some debug printout
jlheflin fca1de6
Committing clang-format changes
github-actions[bot] af6a531
Added submodule printing function, adjusted module creation
jlheflin 953195f
Added submodule printing function, adjusted module creation
jlheflin 40d249e
In git commit purgatory, making sure I didn't kill anything
jlheflin 5125681
Committing clang-format changes
github-actions[bot] 8c9a575
Really close now
jlheflin 8afb7a8
Committing clang-format changes
github-actions[bot] 015c5af
I am really hating these clang-formats
jlheflin 7e07b3b
Committing clang-format changes
github-actions[bot] 5e5a879
Learned how to deal with missing submodules
jlheflin 6a21485
Committing clang-format changes
github-actions[bot] 7eac1b7
removed some debugging statements and learned clang-format
jlheflin 2d30468
reflowed the files a bit
jlheflin 1a26759
commiting clang-format changes, by myself
jlheflin ccb47bb
adding changes
jlheflin 2c295a7
if my brain was a stringstream
jlheflin 86a440d
I have an indent in my head
jlheflin db6470d
I am now a stringstream master (I only know ss.str())
jlheflin cc0e230
removed indent for modules, not needed
jlheflin 75e9a42
function is now recursive
jlheflin 1bb7e5a
bargain-bin GhostFragment test added
jlheflin 8951fd1
commiting clang-format changes, but this time with more pizzazz
jlheflin 3f3fbc6
removed multi-line comments
jlheflin 9b5d8ab
started conversion to mermaid graph output
jlheflin 9569cbc
clang-format, but with less pizzazz
jlheflin 74bdff6
fixed the letter issue
jlheflin e373ecf
adjusted src mermaid.cpp to better follow the mermaid style
jlheflin 1748a54
Committing clang-format changes
github-actions[bot] 31ab2f1
Functional Mermaid Graph now implemented in mermaid.cpp
jlheflin 2f33e42
Committing clang-format changes
github-actions[bot] 85be342
Adjusted tests to unit tests instead of an integration test
jlheflin 2cd6ca0
Committing clang-format changes
github-actions[bot] 530d9c6
Merge branch 'master' into mermaid-graph
jlheflin d611a1c
Apply suggestions from code review
ryanmrichard 3f712ee
remove ss.str() printing
jlheflin 01208fa
unpdate include path
jlheflin fa74221
Committing clang-format changes
github-actions[bot] 1574ef4
added functions to pluginplay::printing namespace
jlheflin 4de393d
fixed letter code issue
jlheflin 4150c25
adjusted letter generation code
jlheflin 423a6ba
Update src/pluginplay/printing/mermaid.cpp
ryanmrichard 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| /* | ||
| * Copyright 2023 NWChemEx-Project | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| #pragma once | ||
| #include <pluginplay/module_manager/module_manager_class.hpp> | ||
| #include <string> | ||
|
|
||
| std::string create_mermaid_graph(const pluginplay::ModuleManager& mm); | ||
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| /* | ||
| * Copyright 2024 NWChemEx-Project | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| #include "module/module_class.hpp" | ||
| #include "module_manager/module_manager_class.hpp" | ||
ryanmrichard marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
ryanmrichard marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| #include <pluginplay/pluginplay.hpp> | ||
ryanmrichard marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| #include <sstream> | ||
|
|
||
| void print_submods(const std::string module_key, | ||
| const pluginplay::ModuleManager& mm, std::stringstream& ss, | ||
| int level = 0) { | ||
| const auto& mm_module = mm.at(module_key); // Results in a PluginPlay Module | ||
| const auto& submods = mm_module.submods(); // Results in list of Submodules | ||
| char letter = 65 + level; | ||
|
|
||
| // Key is the ID/Tag, Value is the reference to the Module | ||
| for(const auto& [key, value] : submods) { | ||
| ss << "\t" << letter + level << level + 1 << "[" << key | ||
| << "]\n"; // Second indent: ---- | ||
| if(value.has_module() == false) { | ||
ryanmrichard marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ss << "\t" << letter + level << level + 2 | ||
| << "[Submod Name: No Submodule associated with Key]\n"; | ||
| continue; | ||
ryanmrichard marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } else { | ||
| ss << "\t" << letter + level << level + 2 << "[" << value.get_name() | ||
| << "]\n"; // Second indent: ---- | ||
| print_submods(value.get_name(), mm, ss, level + 1); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| std::string create_mermaid_graph(const pluginplay::ModuleManager& mm) { | ||
| auto n_modules = mm.size(); | ||
| std::stringstream ss; | ||
| for(decltype(n_modules) i = 0; i < n_modules; i++) { | ||
| ss << "flowchart LR\n"; | ||
| auto mod = mm.keys()[i]; | ||
| char letter = 65; | ||
| ss << "\t" << letter << "[" << mod << "]\n"; | ||
| print_submods(mod, mm, ss); | ||
| } | ||
| std::cout << ss.str(); | ||
jlheflin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return "Hello World!"; | ||
| } | ||
ryanmrichard marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,176 @@ | ||
| /* | ||
| * Copyright 2024 NWChemEx-Project | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| #include "../catch.hpp" | ||
| #include "../test_common.hpp" | ||
| #include "module/macros.hpp" | ||
jlheflin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| #include "unit_testing_pts.hpp" | ||
| #include <pluginplay/module_manager/module_manager.hpp> | ||
| #include <pluginplay/printing/mermaid.hpp> | ||
|
|
||
| DECLARE_MODULE(Allnmers); | ||
| inline MODULE_CTOR(Allnmers) { | ||
| satisfies_property_type<testing::NullPT>(); | ||
| add_submodule<testing::NullPT>("Monomer Maker"); | ||
| } | ||
| inline MODULE_RUN(Allnmers) { return results(); } | ||
|
|
||
| DECLARE_MODULE(AtomicCapping); | ||
| inline MODULE_CTOR(AtomicCapping) { | ||
| satisfies_property_type<testing::NullPT>(); | ||
| } | ||
| inline MODULE_RUN(AtomicCapping) { return results(); } | ||
|
|
||
| DECLARE_MODULE(BondBasedFragmenter); | ||
| inline MODULE_CTOR(BondBasedFragmenter) { | ||
| satisfies_property_type<testing::NullPT>(); | ||
| } | ||
| inline MODULE_RUN(BondBasedFragmenter) { return results(); } | ||
|
|
||
| DECLARE_MODULE(BrokenBonds); | ||
| inline MODULE_CTOR(BrokenBonds) { satisfies_property_type<testing::NullPT>(); } | ||
| inline MODULE_RUN(BrokenBonds) { return results(); } | ||
|
|
||
| DECLARE_MODULE(ClusterPartition); | ||
| inline MODULE_CTOR(ClusterPartition) { | ||
| satisfies_property_type<testing::NullPT>(); | ||
| } | ||
| inline MODULE_RUN(ClusterPartition) { return results(); } | ||
|
|
||
| DECLARE_MODULE(CovalentRadius); | ||
| inline MODULE_CTOR(CovalentRadius) { | ||
| satisfies_property_type<testing::NullPT>(); | ||
| } | ||
| inline MODULE_RUN(CovalentRadius) { return results(); } | ||
|
|
||
| DECLARE_MODULE(DCLCCapping); | ||
| inline MODULE_CTOR(DCLCCapping) { | ||
| satisfies_property_type<testing::NullPT>(); | ||
| add_submodule<testing::NullPT>("Connectivity"); | ||
| } | ||
| inline MODULE_RUN(DCLCCapping) { return results(); } | ||
|
|
||
| DECLARE_MODULE(EnergyMethod); | ||
| inline MODULE_CTOR(EnergyMethod) { satisfies_property_type<testing::NullPT>(); } | ||
| inline MODULE_RUN(EnergyMethod) { return results(); } | ||
|
|
||
| DECLARE_MODULE(FragmentBasedMethod); | ||
| inline MODULE_CTOR(FragmentBasedMethod) { | ||
| satisfies_property_type<testing::NullPT>(); | ||
| add_submodule<testing::NullPT>("Energy method"); | ||
| add_submodule<testing::NullPT>("Subsystem former"); | ||
| add_submodule<testing::NullPT>("Weighter"); | ||
| } | ||
| inline MODULE_RUN(FragmentBasedMethod) { return results(); } | ||
|
|
||
| DECLARE_MODULE(FragmentDriver); | ||
| inline MODULE_CTOR(FragmentDriver) { | ||
| satisfies_property_type<testing::NullPT>(); | ||
| add_submodule<testing::NullPT>("Atomic connectivity"); | ||
| add_submodule<testing::NullPT>("Cap broken bonds"); | ||
| add_submodule<testing::NullPT>("Find broken bonds"); | ||
| add_submodule<testing::NullPT>("Fragment builder"); | ||
| add_submodule<testing::NullPT>("Intersection finder"); | ||
| add_submodule<testing::NullPT>("Molecular graph"); | ||
| add_submodule<testing::NullPT>("N-mer builder"); | ||
| } | ||
| inline MODULE_RUN(FragmentDriver) { return results(); } | ||
|
|
||
| DECLARE_MODULE(FragmentedChemicalSystemDriver); | ||
| inline MODULE_CTOR(FragmentedChemicalSystemDriver) { | ||
| satisfies_property_type<testing::NullPT>(); | ||
| add_submodule<testing::NullPT>("Fragmenter"); | ||
| } | ||
| inline MODULE_RUN(FragmentedChemicalSystemDriver) { return results(); } | ||
|
|
||
| DECLARE_MODULE(GMBEWeights); | ||
| inline MODULE_CTOR(GMBEWeights) { satisfies_property_type<testing::NullPT>(); } | ||
| inline MODULE_RUN(GMBEWeights) { return results(); } | ||
|
|
||
| DECLARE_MODULE(HeavyAtomPartition); | ||
| inline MODULE_CTOR(HeavyAtomPartition) { | ||
| satisfies_property_type<testing::NullPT>(); | ||
| add_submodule<testing::NullPT>("Connectivity"); | ||
| } | ||
| inline MODULE_RUN(HeavyAtomPartition) { return results(); } | ||
|
|
||
| DECLARE_MODULE(Intersections); | ||
| inline MODULE_CTOR(Intersections) { | ||
| satisfies_property_type<testing::NullPT>(); | ||
| } | ||
| inline MODULE_RUN(Intersections) { return results(); } | ||
|
|
||
| DECLARE_MODULE(NuclearGraph); | ||
| inline MODULE_CTOR(NuclearGraph) { | ||
| satisfies_property_type<testing::NullPT>(); | ||
| add_submodule<testing::NullPT>("Connectivity"); | ||
| add_submodule<testing::NullPT>("Nodes"); | ||
| } | ||
| inline MODULE_RUN(NuclearGraph) { return results(); } | ||
|
|
||
| DECLARE_MODULE(WeightedDistance); | ||
| inline MODULE_CTOR(WeightedDistance) { | ||
| satisfies_property_type<testing::NullPT>(); | ||
| } | ||
| inline MODULE_RUN(WeightedDistance) { return results(); } | ||
|
|
||
| TEST_CASE("hello_world") { | ||
| pluginplay::ModuleManager mm; | ||
| mm.add_module<Allnmers>("All nmers"); | ||
| mm.add_module<AtomicCapping>("Atomic Capping"); | ||
| mm.add_module<BondBasedFragmenter>("Bond-Based Fragmenter"); | ||
| mm.add_module<BrokenBonds>("Broken Bonds"); | ||
| mm.add_module<ClusterPartition>("Cluster Partition"); | ||
| mm.add_module<CovalentRadius>("Covalent Radius"); | ||
| mm.add_module<DCLCCapping>("DCLC Capping"); | ||
| mm.add_module<EnergyMethod>("Energy Method"); | ||
| mm.add_module<FragmentBasedMethod>("Fragment Based Method"); | ||
| mm.add_module<FragmentDriver>("Fragment Driver"); | ||
| mm.add_module<FragmentedChemicalSystemDriver>( | ||
| "FragmentedChemicalSystem Driver"); | ||
| mm.add_module<GMBEWeights>("GMBE Weights"); | ||
| mm.add_module<HeavyAtomPartition>("Heavy Atom Partition"); | ||
| mm.add_module<Intersections>("Intersections"); | ||
| mm.add_module<NuclearGraph>("Nuclear Graph"); | ||
| mm.add_module<WeightedDistance>("Weighted Distance"); | ||
| mm.change_submod("DCLC Capping", "Connectivity", "Covalent Radius"); | ||
| mm.change_submod("Fragment Based Method", "Energy method", "Energy Method"); | ||
| mm.change_submod("Fragment Based Method", "Subsystem former", | ||
| "FragmentedChemicalSystem Driver"); | ||
| mm.change_submod("Fragment Based Method", "Weighter", "GMBE Weights"); | ||
| mm.change_submod("Fragment Driver", "Atomic connectivity", | ||
| "Covalent Radius"); | ||
| mm.change_submod("Fragment Driver", "Cap broken bonds", | ||
| "Weighted Distance"); | ||
| mm.change_submod("Fragment Driver", "Find broken bonds", "Broken Bonds"); | ||
| mm.change_submod("Fragment Driver", "Fragment builder", | ||
| "Bond-Based Fragmenter"); | ||
| mm.change_submod("Fragment Driver", "Intersection finder", "Intersections"); | ||
| mm.change_submod("Fragment Driver", "Molecular graph", "Nuclear Graph"); | ||
| mm.change_submod("Fragment Driver", "N-mer builder", "All nmers"); | ||
| mm.change_submod("FragmentedChemicalSystem Driver", "Fragmenter", | ||
| "Fragment Driver"); | ||
| mm.change_submod("Heavy Atom Partition", "Connectivity", "Covalent Radius"); | ||
| mm.change_submod("Nuclear Graph", "Connectivity", "Covalent Radius"); | ||
| mm.change_submod("Nuclear Graph", "Nodes", "Heavy Atom Partition"); | ||
|
|
||
| SECTION("huh") { | ||
| auto hello = create_mermaid_graph(mm); | ||
| std::cout << "Bro the test ran but idk if the internals ran" | ||
| << std::endl; | ||
| REQUIRE(hello == "Hello World!"); | ||
| } | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.