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

Mm integration #7

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
44 changes: 44 additions & 0 deletions .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,47 @@ jobs:
compilers: ''
doc_target: 'sphinx'
secrets: inherit

# PluginPlayer needs pluginplay_examples, which means PluginPlays test have to
# be built. This means that CTest will run both PluginPlayer's and
# PluginPlay's tests, which is not desired. For now, I'm running this job to
# test PluginPlayer using ctest -R to limit the tests.
# TODO: Either refactor the test to not need pluginplay_examples, refactor
# PluginPlay so that pluginplay_examples can be build without the tests,
# or refactor the common workflow to allow for regex specification.
test_library:
needs: Common-Pull-Request
runs-on: ubuntu-latest
container:
image: ghcr.io/nwchemex/nwx_buildenv:latest
credentials:
username: ${{ github.actor }}
password: ${{ secrets.CONTAINER_REPO_TOKEN }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set ownership
run: |
# Fix for git not liking owner of the checkout dir
chown -R $(id -u):$(id -g) $PWD
- name: Install requirements
run: |
pip install -r requirements.txt
shell: bash
- name: Build and Test
env:
CMAIZE_GITHUB_TOKEN: ${{secrets.CMAIZE_GITHUB_TOKEN}}
run: |
toolchain=/toolchains/nwx_gcc-11.cmake
echo 'set(CMAIZE_GITHUB_TOKEN '${CMAIZE_GITHUB_TOKEN}')' >> $toolchain

cmake -Bbuild -H. -GNinja \
-DCMAKE_INSTALL_PREFIX=./install \
-DCMAKE_TOOLCHAIN_FILE="${toolchain}"

cmake --build build --parallel

cd build
OMPI_ALLOW_RUN_AS_ROOT=1 OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 ctest -VV -R pluginplayer
shell: bash
81 changes: 81 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# 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.

cmake_minimum_required(VERSION 3.14)

#Downloads common CMake modules used throughout NWChemEx
include(cmake/get_nwx_cmake.cmake)

#Sets the version to whatever git thinks it is
include(get_version_from_git)
get_version_from_git(pluginplayer_version "${CMAKE_CURRENT_LIST_DIR}")
project(pluginplayer VERSION "${pluginplayer_version}" LANGUAGES CXX)

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

### Files and Paths ###
set(python_src_directory "${CMAKE_CURRENT_LIST_DIR}/src/")

# # Doxygen docs
nwx_cxx_api_docs("${CMAKE_CURRENT_SOURCE_DIR}/src" "${CMAKE_CURRENT_SOURCE_DIR}/include")

### Options ###
cmaize_option_list(
BUILD_TESTING OFF "Should we build the tests?"
)

### Tests need PluginPlay examples ##
if("${BUILD_TESTING}")
set(PP_BUILD_TARGETS pluginplay pluginplay_examples)
set(PP_FIND_TARGETS nwx::pluginplay nwx::pluginplay_depends)
set(PP_BUILD_TESTS ON)
else()
set(PP_BUILD_TARGETS pluginplay)
set(PP_FIND_TARGETS nwx::pluginplay)
set(PP_BUILD_TESTS OFF)
endif()

## Build FriendZone's dependencies ##
cmaize_find_or_build_dependency(
pluginplay
URL github.com/NWChemEx/PluginPlay
VERSION ${NWX_PLUGINPLAY_VERSION}
BUILD_TARGET ${PP_BUILD_TARGETS}
FIND_TARGET ${PP_FIND_TARGETS}
CMAKE_ARGS BUILD_TESTING=${PP_BUILD_TESTS}
BUILD_PYBIND11_PYBINDINGS=ON
)

#TOOD: Replace cmaize_add_library when it supports Python
add_library(${PROJECT_NAME} INTERFACE)
target_link_libraries(${PROJECT_NAME} INTERFACE pluginplay)

if("${BUILD_TESTING}")
include(CTest)
include(nwx_pybind11)
set(PYTHON_TEST_DIR "${CMAKE_CURRENT_LIST_DIR}/tests")

nwx_pybind11_tests(
py_${PROJECT_NAME}
"${PYTHON_TEST_DIR}/test_pluginplayer.py"
SUBMODULES pluginplay_examples pluginplay parallelzone
)
endif()

install(
DIRECTORY "${python_src_directory}/pluginplayer"
DESTINATION "${NWX_MODULE_DIRECTORY}"
)
31 changes: 31 additions & 0 deletions cmake/get_nwx_cmake.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 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_guard()

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()

get_nwx_cmake()
4 changes: 2 additions & 2 deletions src/pluginplayer/node_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ def link_submod(self, instance):
key_name = list(node.submod_dict.keys())[key_number]
plugin_number = int(instance.id.split()[2])
submodule_number = int(instance.id.split()[3])
submodule_name = self.saved_plugins[plugin_number].modules[
submodule_number]
submodule_name = self.plugin_player.plugin_manager.saved_plugins[
plugin_number].modules[submodule_number]

try:
self.plugin_player.mm.change_submod(module_name, key_name,
Expand Down
5 changes: 4 additions & 1 deletion src/pluginplayer/node_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from kivy.uix.image import Image
from kivy.uix.behaviors import ButtonBehavior
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.textinput import TextInput


class DraggableImageButton(ButtonBehavior, BoxLayout):
Expand Down Expand Up @@ -199,7 +200,9 @@ def __init__(self, module, module_name):
self.module_widget = None

#holds the widget of the custom declaration of the currently selected input
self.custom_declaration_widget = None
self.custom_declaration_widget = TextInput(hint_text="ex: Force()",
size_hint_x=3 / 5,
multiline=False)

#show the mapping of inputs, outputs and submodules used for running the tree
self.input_map = []
Expand Down
9 changes: 4 additions & 5 deletions src/pluginplayer/node_widget_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,12 @@ def view_config(self, instance):

#create an entry to declare a property type
custom_ptype = BoxLayout(orientation='horizontal', spacing=0)
text_entry = TextInput(hint_text="ex: Force()",
size_hint_x=3 / 5,
multiline=False)

if node.custom_declaration_widget.parent:
node.custom_declaration_widget.parent.remove_widget(
node.custom_declaration_widget)
#add text entry to the node's properties
node.custom_declaration_widget = text_entry
custom_ptype.add_widget(text_entry)
custom_ptype.add_widget(node.custom_declaration_widget)

#add button to set the property type
custom_entry_button = Button(
Expand Down
22 changes: 17 additions & 5 deletions src/pluginplayer/plugin_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@

#helper classes for a PluginPlayer interface
import pluginplay as pp
from plugin_manager import PluginManager
from tree_manager import TreeManager
from node_widget_manager import NodeWidgetManager
from node_manager import NodeManager
from utility_manager import UtilityManager
from pluginplayer.plugin_manager import PluginManager
from pluginplayer.tree_manager import TreeManager
from pluginplayer.node_widget_manager import NodeWidgetManager
from pluginplayer.node_manager import NodeManager
from pluginplayer.utility_manager import UtilityManager

#kivy helpers
from kivy.app import App
Expand Down Expand Up @@ -55,6 +55,7 @@ def build(self):
:return: The built Kivy application
:rtype: kivy.app.App
"""

self.popup = Popup()

#The app's module manager
Expand All @@ -78,6 +79,9 @@ def build(self):
#helper class handling browsing, imported class types, and importing new classes
self.utility_manager = UtilityManager()

#string array holding the filepaths of resized images
self.resized_images = []

#build the main application from the kivy script file
build = Builder.load_file('plugin_player_setup.kv')

Expand Down Expand Up @@ -146,6 +150,14 @@ def create_image(self, filepath, new_filepath, size):
image = PILImage.open(filepath)
resized_image = image.resize(size)
resized_image.save(new_filepath)
self.resized_images.append(new_filepath)

def on_stop(self):
"""On the closing of the application, the saved resized images used in the application are located and deleted.
"""
for filepath in self.resized_images:
if os.path.exists(filepath):
os.remove(filepath)


if __name__ == "__main__":
Expand Down
Loading
Loading