Skip to content

Commit

Permalink
Release vs. experimental split (#70)
Browse files Browse the repository at this point in the history
* CMakeLists update, tests/cxx/unit -> test/cxx/unit_tests, some refactoring

* move files to experimental, fix tests, update python scripts

* remove unused script, update ref data generation script
  • Loading branch information
jwaldrop107 authored Jan 16, 2024
1 parent 3274b77 commit 2908916
Show file tree
Hide file tree
Showing 35 changed files with 214 additions and 1,422 deletions.
68 changes: 0 additions & 68 deletions .github/workflows/scripts/build_and_test.sh

This file was deleted.

7 changes: 4 additions & 3 deletions .github/workflows/scripts/generate_reference_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ REF_DATA="reference_data"

# Set source code output directories
SRC="src/chemcache"
ATOM_DEN="${SRC}/atomic_densities"
EXP_SRC="experimental/src/chemcache"
ATOM_DEN="${EXP_SRC}/atomic_densities"
ATOM="${SRC}/atoms"
BASES="${SRC}/bases"
ELEC_CONFIGS="${SRC}/electronic_configurations"
ELEC_CONFIGS="${EXP_SRC}/electronic_configurations"
MOLES="${SRC}/molecules"

# Set data directories
Expand Down Expand Up @@ -53,7 +54,7 @@ TESTS="tests/chemcache"
echo "Calling ${REF_DATA}/generate_atomicinfo.py ${ATOMIC_INFO} ${ATOM}"
${PYTHON} ${REF_DATA}/generate_atomicinfo.py ${ATOMIC_INFO} ${ATOM}

echo "Calling ${REF_DATA}/generate_densities.py ${DENSITIES} ${ATOM_DEN} ${TESTS} -r"
echo "Calling ${REF_DATA}/generate_densities.py ${DENSITIES} ${ATOM_DEN} -r"
${PYTHON} ${REF_DATA}/generate_densities.py ${DENSITIES} ${ATOM_DEN} -r

echo "Calling ${REF_DATA}/generate_molecules.py ${MOLECULES} ${MOLES} -r"
Expand Down
120 changes: 70 additions & 50 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,98 +13,118 @@
# limitations under the License.

cmake_minimum_required(VERSION 3.14)
set(VERSION 1.0.0) #TODO: Get from git
project(chemcache VERSION "${VERSION}" LANGUAGES CXX)

include(FetchContent)
FetchContent_Declare(
nwx_cmake
GIT_REPOSITORY https://github.com/NWChemEx/NWXCMake
)
FetchContent_MakeAvailable(nwx_cmake)
list(APPEND CMAKE_MODULE_PATH "${nwx_cmake_SOURCE_DIR}/cmake")
#Downloads common CMake modules used throughout NWChemEx
include(cmake/get_nwx_cmake.cmake)

set(
CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${PROJECT_SOURCE_DIR}/cmake"
CACHE STRING "" FORCE
)
#Sets the version to whatever git thinks it is
include(get_version_from_git)
get_version_from_git(chemcache_version "${CMAKE_CURRENT_LIST_DIR}")
project(chemcache VERSION "${chemcache_version}" LANGUAGES CXX)

include(nwx_versions)
include(get_cmaize)
include(nwx_cxx_api_docs)

# Work out the project paths
set(project_inc_dir "${CMAKE_CURRENT_LIST_DIR}/include/${PROJECT_NAME}")
set(project_src_dir "${CMAKE_CURRENT_LIST_DIR}/src/${PROJECT_NAME}")
### Paths ###
set(CHEMCACHE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")
set(CHEMCACHE_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
set(CHEMCACHE_TESTS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/tests")
set(CHEMCACHE_EXP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/experimental")

nwx_cxx_api_docs("${CHEMCACHE_SOURCE_DIR}" "${CHEMCACHE_INCLUDE_DIR}")

### Options ###
option(BUILD_TESTING "Should we build the tests?" OFF)
option(BUILD_DOCS "Should we build the documentation?" OFF)
option(
ONLY_BUILD_DOCS
"If enabled and BUILD_DOCS is true no libraries will be built" OFF
cmaize_option_list(
BUILD_TESTING OFF "Should we build the tests?"
BUILD_PYBIND11_PYBINDINGS OFF "Build pybind11 python3 bindings?"
ENABLE_EXPERIMENTAL_FEATURES OFF "Build features which are not 1.0-ed yet?"
)
option(BUILD_PYBIND11_PYBINDINGS "Use pybind11 to build Python3 bindings?" OFF)
option(BUILD_CPPYY_PYBINDINGS "Use Cppyy to build Python3 bindings?" OFF)

# Generate C++ API documentation, if BUILD_DOCS is set
nwx_cxx_api_docs("${project_inc_dir}")

cmaize_find_or_build_dependency(
simde
URL github.com/NWChemEx/SimDE
PRIVATE TRUE
VERSION ${NWX_SIMDE_VERSION}
BUILD_TARGET simde
FIND_TARGET nwx::simde
CMAKE_ARGS BUILD_TESTING=OFF
BUILD_PYBIND11_PYBINDINGS=${BUILD_PYBIND11_PYBINDINGS}
ENABLE_EXPERIMENTAL_FEATURES=${ENABLE_EXPERIMENTAL_FEATURES}
)

cmaize_add_library(
${PROJECT_NAME}
SOURCE_DIR "${project_src_dir}"
INCLUDE_DIRS "${project_inc_dir}"
DEPENDS nwx::simde
SOURCE_DIR "${CHEMCACHE_SOURCE_DIR}/${PROJECT_NAME}"
INCLUDE_DIRS "${CHEMCACHE_INCLUDE_DIR}/${PROJECT_NAME}"
DEPENDS simde
)

if("${ENABLE_EXPERIMENTAL_FEATURES}")

cmaize_add_library(
experimental_${PROJECT_NAME}
SOURCE_DIR "${CHEMCACHE_EXP_DIR}/src/${PROJECT_NAME}"
INCLUDE_DIRS "${CHEMCACHE_EXP_DIR}/include/${PROJECT_NAME}"
DEPENDS ${PROJECT_NAME}
)

else()
add_library(experimental_${PROJECT_NAME} INTERFACE)
endif()

# N.B. this is a no-op if BUILD_PYBIND11_PYBINDINGS is not turned on
include(nwx_pybind11)
nwx_add_pybind11_module(
${PROJECT_NAME}
SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/src/python"
SOURCE_DIR "${CHEMCACHE_SOURCE_DIR}/python"
DEPENDS "${PROJECT_NAME}"
)

include(nwx_python_mods)
cppyy_make_python_package(PACKAGE chemcache NAMESPACES chemcache DEPPACKAGES simde )

if("${BUILD_TESTING}")
set(CXX_TEST_DIR "${CMAKE_CURRENT_LIST_DIR}/tests/cxx")
set(PYTHON_TEST_DIR "${CMAKE_CURRENT_LIST_DIR}/tests/python")
set(CXX_TEST_DIR ${CHEMCACHE_TESTS_DIR}/cxx)
set(PYTHON_TEST_DIR ${CHEMCACHE_TESTS_DIR}/python)

cmaize_find_or_build_dependency(
Catch2
URL github.com/catchorg/Catch2
BUILD_TARGET Catch2
FIND_TARGET Catch2::Catch2
VERSION v2.x
VERSION ${NWX_CATCH2_VERSION}
)

cmaize_add_tests(
test_unit_${PROJECT_NAME}
SOURCE_DIR "${CXX_TEST_DIR}/unit"
INCLUDE_DIRS "${project_src_dir}"
DEPENDS Catch2 ${PROJECT_NAME}
)
cmaize_add_tests(
test_integration_${PROJECT_NAME}
SOURCE_DIR "${CXX_TEST_DIR}/integration"
INCLUDE_DIRS "${project_src_dir}"
SOURCE_DIR "${CXX_TEST_DIR}/unit_tests"
INCLUDE_DIRS "${CHEMCACHE_SOURCE_DIR}/${PROJECT_NAME}"
DEPENDS Catch2 ${PROJECT_NAME}
)
# Based on previous comment, not sure this test actually worked.
#nwx_pybind11_tests(
#scrape_bse ${PYTHON_TEST_DIR}/reference_data/test_scrape_bse.py
#)

# N.B. these are no-ops if BUILD_PYBIND11_PYBINDINGS is not turned on
nwx_pybind11_tests(
py_chem_cache ${PYTHON_TEST_DIR}/unit_tests/test_chemcache.py
py_chem_cache "${PYTHON_TEST_DIR}/unit_tests/test_chemcache.py"
SUBMODULES parallelzone pluginplay chemist simde
)

if("${ENABLE_EXPERIMENTAL_FEATURES}")

cmaize_add_tests(
test_unit_experimental_${PROJECT_NAME}
SOURCE_DIR "${CHEMCACHE_EXP_DIR}/tests/cxx/unit_tests"
INCLUDE_DIRS "${CHEMCACHE_EXP_DIR}/src/${PROJECT_NAME}"
DEPENDS Catch2::Catch2 experimental_${PROJECT_NAME}
)

nwx_pybind11_tests(
py_experimental_${PROJECT_NAME}
"${CHEMCACHE_EXP_DIR}/tests/python/unit_tests/test_python.py"
SUBMODULES pluginplay chemist parallelzone
)

endif()

endif()

cmaize_add_package(${PROJECT_NAME} NAMESPACE nwx::)
cmaize_add_package(
${PROJECT_NAME} experimental_${PROJECT_NAME} NAMESPACE nwx::
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#
# Copyright 2023 NWChemEx-Project
# 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.
Expand All @@ -12,21 +11,21 @@
# 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.
#

import pluginplay
import chemist
import simde
import chemcache
import unittest


class TestAtomicDensities(unittest.TestCase):

def test_sto3g_atomic_dm(self):
include_guard()

mm = pluginplay.ModuleManager()
chemcache.load_modules(mm)
mod = mm.at('sto-3g atomic dm')
macro(get_nwx_cmake)
include(FetchContent)
FetchContent_Declare(
nwx_cmake
GIT_REPOSITORY https://github.com/NWChemEx/NWXCMake
)
FetchContent_MakeAvailable(nwx_cmake)
set(
CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${nwx_cmake_SOURCE_DIR}/cmake"
CACHE STRING ""
FORCE
)
endmacro()

# TODO: Test when property type is exposed
get_nwx_cmake()
28 changes: 28 additions & 0 deletions experimental/include/chemcache_experimental.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright 2022 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.
*/

/**
* @file chemcache.hpp
*
* This is the main header of the chemcache library, defining the public API
* of the library. This file should NOT be included in any other chemcache
* header files, source files, or tests (except tests/chemcache.cpp, which
* tests the functions defined in this header file).
*/

#pragma once

#include "chemcache_experimental_mm.hpp"
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 NWChemEx-Project
* Copyright 2022 NWChemEx-Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,14 +14,13 @@
* limitations under the License.
*/

#define CATCH_CONFIG_MAIN
#include <catch2/catch.hpp>
#include <iostream>
#pragma once
#include <pluginplay/module_manager.hpp>

int print_and_return(int ii) {
std::cout << "This is only a blank model for an integration test."
<< std::endl;
return 0;
}
namespace chemcache {
/** @brief Loads the modules contained in the experimental ChemCache module
* collection into the provided ModuleManager instance.
*/
void load_experimental_modules(pluginplay::ModuleManager& mm);

TEST_CASE("Blank test", "[classic]") { REQUIRE(print_and_return(0) == 0); }
} // namespace chemcache
File renamed without changes.
Loading

0 comments on commit 2908916

Please sign in to comment.