Skip to content
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
c4726e3
Start of adding mermaid graphs
jlheflin Dec 27, 2024
ce04f9f
Restart addition of mermaid graph, test with hello_world function
jlheflin Dec 27, 2024
d00bdb7
Trying to add tests for mermaid.cpp
jlheflin Dec 27, 2024
7259026
just like me, ctest keeps failing
jlheflin Dec 29, 2024
0d6659f
Committing clang-format changes
github-actions[bot] Dec 29, 2024
203a8c8
Update mermaid.cpp
ryanmrichard Dec 29, 2024
b08bf98
Update mermaid.cpp
ryanmrichard Dec 29, 2024
6e720d1
Committing clang-format changes
github-actions[bot] Dec 29, 2024
09fb829
Finally actually doing some code
jlheflin Jan 9, 2025
4a419c9
Committing clang-format changes
github-actions[bot] Jan 9, 2025
372538f
Made suggested changes regarding mermaid.cpp, mermaid.hpp and the tes…
jlheflin Jan 9, 2025
ee6fdd4
Made changes with usage of decltype
jlheflin Jan 9, 2025
f61012b
Preparing to add module with several nested modules
jlheflin Jan 10, 2025
29fe47e
Committing clang-format changes
github-actions[bot] Jan 10, 2025
98746b2
loaded test modules into mm
jlheflin Jan 14, 2025
c4ad8dd
Committing clang-format changes
github-actions[bot] Jan 14, 2025
0177e4f
adjusted code to work since it didn't in the previous commit
jlheflin Jan 14, 2025
ff92d0c
Lego'd the modules, compiled normally?
jlheflin Jan 16, 2025
a06ae22
added some debug printout
jlheflin Jan 16, 2025
fca1de6
Committing clang-format changes
github-actions[bot] Jan 16, 2025
af6a531
Added submodule printing function, adjusted module creation
jlheflin Jan 23, 2025
953195f
Added submodule printing function, adjusted module creation
jlheflin Jan 23, 2025
40d249e
In git commit purgatory, making sure I didn't kill anything
jlheflin Jan 23, 2025
5125681
Committing clang-format changes
github-actions[bot] Jan 23, 2025
8c9a575
Really close now
jlheflin Jan 23, 2025
8afb7a8
Committing clang-format changes
github-actions[bot] Jan 23, 2025
015c5af
I am really hating these clang-formats
jlheflin Jan 23, 2025
7e07b3b
Committing clang-format changes
github-actions[bot] Jan 23, 2025
5e5a879
Learned how to deal with missing submodules
jlheflin Jan 24, 2025
6a21485
Committing clang-format changes
github-actions[bot] Jan 24, 2025
7eac1b7
removed some debugging statements and learned clang-format
jlheflin Jan 24, 2025
2d30468
reflowed the files a bit
jlheflin Jan 24, 2025
1a26759
commiting clang-format changes, by myself
jlheflin Jan 24, 2025
ccb47bb
adding changes
jlheflin Jan 25, 2025
2c295a7
if my brain was a stringstream
jlheflin Jan 25, 2025
86a440d
I have an indent in my head
jlheflin Jan 26, 2025
db6470d
I am now a stringstream master (I only know ss.str())
jlheflin Jan 26, 2025
cc0e230
removed indent for modules, not needed
jlheflin Jan 27, 2025
75e9a42
function is now recursive
jlheflin Jan 28, 2025
1bb7e5a
bargain-bin GhostFragment test added
jlheflin Jan 30, 2025
8951fd1
commiting clang-format changes, but this time with more pizzazz
jlheflin Jan 30, 2025
3f3fbc6
removed multi-line comments
jlheflin Jan 30, 2025
9b5d8ab
started conversion to mermaid graph output
jlheflin Jan 30, 2025
9569cbc
clang-format, but with less pizzazz
jlheflin Jan 30, 2025
74bdff6
fixed the letter issue
jlheflin Feb 6, 2025
e373ecf
adjusted src mermaid.cpp to better follow the mermaid style
jlheflin Feb 13, 2025
1748a54
Committing clang-format changes
github-actions[bot] Feb 13, 2025
31ab2f1
Functional Mermaid Graph now implemented in mermaid.cpp
jlheflin Feb 17, 2025
2f33e42
Committing clang-format changes
github-actions[bot] Feb 17, 2025
85be342
Adjusted tests to unit tests instead of an integration test
jlheflin Mar 13, 2025
2cd6ca0
Committing clang-format changes
github-actions[bot] Mar 13, 2025
530d9c6
Merge branch 'master' into mermaid-graph
jlheflin Mar 13, 2025
d611a1c
Apply suggestions from code review
ryanmrichard Mar 13, 2025
3f712ee
remove ss.str() printing
jlheflin Mar 14, 2025
01208fa
unpdate include path
jlheflin Mar 14, 2025
fa74221
Committing clang-format changes
github-actions[bot] Mar 14, 2025
1574ef4
added functions to pluginplay::printing namespace
jlheflin Mar 14, 2025
4de393d
fixed letter code issue
jlheflin Mar 14, 2025
4150c25
adjusted letter generation code
jlheflin Mar 14, 2025
423a6ba
Update src/pluginplay/printing/mermaid.cpp
ryanmrichard Mar 14, 2025
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# These are directories used by IDEs for storing settings
.idea/
.vscode/
.cache

# These are common Python virtual enviornment directory names
venv/
Expand Down
21 changes: 21 additions & 0 deletions include/pluginplay/printing/mermaid.hpp
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);
71 changes: 71 additions & 0 deletions src/pluginplay/printing/mermaid.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* 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"
Copy link
Member

Choose a reason for hiding this comment

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

should use paths from the include root for files in the include directory.

#include <pluginplay/pluginplay.hpp>
#include <sstream>

void add_letter(std::string& code) {
for(int i = 2; i >= 0; --i) {
if(code[i] == 'Z') {
code[i] = 'A';
} else {
code[i]++;
return;
}
}
}

void print_submods(const std::string module_key,
const pluginplay::ModuleManager& mm, std::stringstream& ss,
std::string& module_code) {
const auto& mm_module = mm.at(module_key); // Results in a PluginPlay Module
const auto& submods = mm_module.submods(); // Results in list of Submodules
auto main_mod_code = module_code;

// Key is the ID/Tag, Value is the reference to the Module
for(const auto& [key, value] : submods) {
ss << "\n\t" << main_mod_code << "-->"
<< "|" << key << "| ";
if(value.has_module() == false) {
add_letter(module_code);
ss << module_code << "[No Submodule associated with Key]";
continue;
} else {
add_letter(module_code);
ss << module_code << "[" << value.get_name() << "]";
print_submods(value.get_name(), mm, ss, module_code);
}
}
}

std::string create_mermaid_graph(const pluginplay::ModuleManager& mm) {
auto n_modules = mm.size();
std::stringstream ss;
std::string module_code = "AAA";
for(decltype(n_modules) i = 0; i < n_modules; i++) {
ss << "\n```mermaid";
ss << "\nflowchart LR\n";
auto mod = mm.keys()[i];
ss << "\t" << module_code << "[" << mod << "]";
print_submods(mod, mm, ss, module_code);
ss << "\n```";
add_letter(module_code);
}
std::cout << ss.str();
return "Hello World!";
}
176 changes: 176 additions & 0 deletions tests/cxx/unit_tests/pluginplay/printing/mermaid.cpp
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"
#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!");
}
}