diff --git a/.gitmodules b/.gitmodules index 3ac5184..0e1f569 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "nsls2ptycho/core/ptycho"] - path = nsls2ptycho/core/ptycho +[submodule "nsls2ptycho/backend/ptycho"] + path = nsls2ptycho/backend/ptycho url = ../ptycho.git diff --git a/MANIFEST.in b/MANIFEST.in index 6de20cc..801786b 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1 +1 @@ -include nsls2ptycho/core/ptycho/*.cubin +include nsls2ptycho/backend/ptycho/*.cubin diff --git a/nsls2ptycho/__init__.py b/nsls2ptycho/__init__.py index d37d9c7..f1bedba 100644 --- a/nsls2ptycho/__init__.py +++ b/nsls2ptycho/__init__.py @@ -1,4 +1,6 @@ +import nsls2ptycho.backend import nsls2ptycho.core +import nsls2ptycho.databroker import nsls2ptycho.ui from ._version import __version__ diff --git a/nsls2ptycho/backend/__init__.py b/nsls2ptycho/backend/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/nsls2ptycho/core/ptycho b/nsls2ptycho/backend/ptycho similarity index 100% rename from nsls2ptycho/core/ptycho rename to nsls2ptycho/backend/ptycho diff --git a/nsls2ptycho/core/__init__.py b/nsls2ptycho/core/__init__.py index d96d5e5..bee326c 100644 --- a/nsls2ptycho/core/__init__.py +++ b/nsls2ptycho/core/__init__.py @@ -1,2 +1 @@ -import nsls2ptycho.core.ptycho import nsls2ptycho.core.widgets diff --git a/nsls2ptycho/core/ptycho_qt_utils.py b/nsls2ptycho/core/qt_utils.py similarity index 100% rename from nsls2ptycho/core/ptycho_qt_utils.py rename to nsls2ptycho/core/qt_utils.py diff --git a/nsls2ptycho/core/utils.py b/nsls2ptycho/core/utils.py index bfa2381..3849af3 100644 --- a/nsls2ptycho/core/utils.py +++ b/nsls2ptycho/core/utils.py @@ -11,7 +11,7 @@ mpi4py.rc.initialize = False from mpi4py import MPI -from nsls2ptycho.core.ptycho.utils import split +from nsls2ptycho.backend.ptycho.utils import split # DEPRECARED: migrated to nsls2ptycho.core.widgets.mplcanvas diff --git a/nsls2ptycho/core/widgets/mplcanvas.py b/nsls2ptycho/core/widgets/mplcanvas.py index 08b4b25..6bf91e1 100644 --- a/nsls2ptycho/core/widgets/mplcanvas.py +++ b/nsls2ptycho/core/widgets/mplcanvas.py @@ -11,7 +11,7 @@ import numpy as np from PIL import Image -from nsls2ptycho.core.ptycho.utils import split +from nsls2ptycho.backend.ptycho.utils import split def load_image_pil(path): diff --git a/nsls2ptycho/core/ptycho_recon.py b/nsls2ptycho/core/workers.py similarity index 98% rename from nsls2ptycho/core/ptycho_recon.py rename to nsls2ptycho/core/workers.py index a69b23d..b7008e0 100644 --- a/nsls2ptycho/core/ptycho_recon.py +++ b/nsls2ptycho/core/workers.py @@ -1,16 +1,17 @@ -from PyQt5 import QtCore from datetime import datetime -from nsls2ptycho.core.ptycho_param import Param import sys, os import pickle # dump param into disk import subprocess # call mpirun from shell from fcntl import fcntl, F_GETFL, F_SETFL from os import O_NONBLOCK -import numpy as np import traceback -from nsls2ptycho.core.databroker_api import load_metadata, save_data +import numpy as np +from PyQt5 import QtCore + +from nsls2ptycho.core.ptycho_param import Param from nsls2ptycho.core.utils import use_mpi_machinefile, set_flush_early +from nsls2ptycho.databroker import load_metadata, save_data class PtychoReconWorker(QtCore.QThread): @@ -81,7 +82,7 @@ def _parse_one_line(self): def recon_api(self, param:Param, update_fcn=None): # "1" is just a placeholder to be overwritten soon - mpirun_command = ["mpirun", "-n", "1", "python", "-W", "ignore", "-m","nsls2ptycho.core.ptycho.recon_ptycho_gui"] + mpirun_command = ["mpirun", "-n", "1", "python", "-W", "ignore", "-m","nsls2ptycho.backend.ptycho.recon_ptycho_gui"] if param.mpi_file_path == '': if param.gpu_flag: diff --git a/nsls2ptycho/core/CSX_databroker.py b/nsls2ptycho/databroker/CSX_databroker.py similarity index 99% rename from nsls2ptycho/core/CSX_databroker.py rename to nsls2ptycho/databroker/CSX_databroker.py index dc8be7b..60bb33e 100644 --- a/nsls2ptycho/core/CSX_databroker.py +++ b/nsls2ptycho/databroker/CSX_databroker.py @@ -17,7 +17,7 @@ # ***************************** "Public API" ***************************** -# The following functions must exist in nsls2ptycho/core/*_databroker.py, +# The following functions must exist in nsls2ptycho.databroker, # but the function signatures do not need to agree across modules # (obviously, it is impossible for all beamlines to have the same setup). # - load_metadata diff --git a/nsls2ptycho/core/HXN_databroker.py b/nsls2ptycho/databroker/HXN_databroker.py similarity index 99% rename from nsls2ptycho/core/HXN_databroker.py rename to nsls2ptycho/databroker/HXN_databroker.py index 4feca28..aaf1f94 100644 --- a/nsls2ptycho/core/HXN_databroker.py +++ b/nsls2ptycho/databroker/HXN_databroker.py @@ -20,7 +20,7 @@ # ***************************** "Public API" ***************************** -# The following functions must exist in nsls2ptycho/core/*_databroker.py, +# The following functions must exist in nsls2ptycho.databroker, # but the function signatures do not need to agree across modules # (obviously, it is impossible for all beamlines to have the same setup). # - load_metadata diff --git a/nsls2ptycho/core/databroker_api.py b/nsls2ptycho/databroker/__init__.py similarity index 91% rename from nsls2ptycho/core/databroker_api.py rename to nsls2ptycho/databroker/__init__.py index cf1c979..0eedf04 100644 --- a/nsls2ptycho/core/databroker_api.py +++ b/nsls2ptycho/databroker/__init__.py @@ -4,7 +4,7 @@ # ***************************** "Public API" ***************************** -# The following functions must exist in nsls2ptycho/core/*_databroker.py, +# The following functions must exist in nsls2ptycho.databroker, # but the function signatures do not need to agree across modules # (obviously, it is impossible for all beamlines to have the same setup). # - load_metadata @@ -22,7 +22,7 @@ def _load_HXN(): - import nsls2ptycho.core.HXN_databroker as hxn_databroker + from . import HXN_databroker as hxn_databroker global load_metadata, save_data, get_single_image, get_detector_names, db load_metadata = hxn_databroker.load_metadata save_data = hxn_databroker.save_data @@ -33,7 +33,7 @@ def _load_HXN(): def _load_CSX(): - import nsls2ptycho.core.CSX_databroker as csx_databroker + from . import CSX_databroker as csx_databroker global load_metadata, save_data, get_single_image, get_detector_names, db load_metadata = csx_databroker.load_metadata save_data = csx_databroker.save_data diff --git a/nsls2ptycho/ptycho_gui.py b/nsls2ptycho/ptycho_gui.py index 0e8e3f5..bc02796 100644 --- a/nsls2ptycho/ptycho_gui.py +++ b/nsls2ptycho/ptycho_gui.py @@ -7,15 +7,15 @@ from nsls2ptycho.ui import ui_ptycho from nsls2ptycho.core.utils import clean_shared_memory, get_mpi_num_processes, parse_range from nsls2ptycho.core.ptycho_param import Param -from nsls2ptycho.core.ptycho_recon import PtychoReconWorker, PtychoReconFakeWorker, HardWorker -from nsls2ptycho.core.ptycho_qt_utils import PtychoStream +from nsls2ptycho.core.workers import PtychoReconWorker, PtychoReconFakeWorker, HardWorker +from nsls2ptycho.core.qt_utils import PtychoStream from nsls2ptycho.core.widgets.list_widget import ListWidget from nsls2ptycho.core.widgets.mplcanvas import load_image_pil -from nsls2ptycho.core.ptycho.utils import parse_config +from nsls2ptycho.backend.ptycho.utils import parse_config from nsls2ptycho._version import __version__ # databroker related -from nsls2ptycho.core.databroker_api import db, load_metadata, get_single_image, get_detector_names, beamline_name +from nsls2ptycho.databroker import db, load_metadata, get_single_image, get_detector_names, beamline_name from nsls2ptycho.reconStep_gui import ReconStepWindow from nsls2ptycho.roi_gui import RoiWindow @@ -570,7 +570,7 @@ def start(self, batch_mode=False): else: self._scan_points[0] *= -1.*self.param.x_direction self._scan_points[1] *= self.param.y_direction - # borrowed from nsls2ptycho/core/ptycho_recon.py + # borrowed from nsls2ptycho/core/workers.py if self.param.mpi_file_path == '': if self.param.gpu_flag: num_processes = str(len(self.param.gpus)) diff --git a/nsls2ptycho/roi_gui.py b/nsls2ptycho/roi_gui.py index d46327b..9589511 100644 --- a/nsls2ptycho/roi_gui.py +++ b/nsls2ptycho/roi_gui.py @@ -4,9 +4,9 @@ import numpy as np from nsls2ptycho.core.widgets.imgTools import find_outlier_pixels, find_brightest_pixels, rm_outlier_pixels -from nsls2ptycho.core.ptycho_recon import HardWorker +from nsls2ptycho.core.workers import HardWorker from nsls2ptycho.core.widgets.badpixel_dialog import BadPixelDialog -from nsls2ptycho.core.databroker_api import save_data +from nsls2ptycho.databroker import save_data class RoiWindow(QtWidgets.QMainWindow, ui_roi.Ui_MainWindow): diff --git a/setup.py b/setup.py index f4b1109..8b23376 100644 --- a/setup.py +++ b/setup.py @@ -24,12 +24,12 @@ from glob import glob extensions = [] # this doesn't work because setuptools doesn't support glob pattern... - #extensions = [Extension("*", ["nsls2ptycho/core/ptycho/*.c"])] - for filename in glob("nsls2ptycho/core/ptycho/*.c"): + #extensions = [Extension("*", ["nsls2ptycho/backend/ptycho/*.c"])] + for filename in glob("nsls2ptycho/backend/ptycho/*.c"): mod = os.path.basename(filename)[:-2] - extensions.append(Extension("nsls2ptycho.core.ptycho."+mod, [filename])) + extensions.append(Extension("nsls2ptycho.backend.ptycho."+mod, [filename])) else: - extensions = cythonize("nsls2ptycho/core/ptycho/*.pyx") + extensions = cythonize("nsls2ptycho/backend/ptycho/*.pyx") # see if PyQt5 is already installed --- pip and conda use different names... try: @@ -39,7 +39,7 @@ # for generating .cubin files # TODO: add a flag to do this only if GPU support is needed? -import nsls2ptycho.core.ptycho.build_cuda_source as bcs +import nsls2ptycho.backend.ptycho.build_cuda_source as bcs cubin_path = bcs.compile() # if GPU support is needed, check if cupy exists @@ -71,10 +71,16 @@ setup(name=NAME, version=__version__, #packages=find_packages(), - packages=["nsls2ptycho", "nsls2ptycho.core", "nsls2ptycho.ui", "nsls2ptycho.core.ptycho", "nsls2ptycho.core.widgets"], + packages=["nsls2ptycho", + "nsls2ptycho.core", + "nsls2ptycho.backend", + "nsls2ptycho.backend.ptycho", + "nsls2ptycho.databroker", + "nsls2ptycho.core.widgets", + "nsls2ptycho.ui"], entry_points={ 'gui_scripts': ['run-ptycho = nsls2ptycho.ptycho_gui:main'], - 'console_scripts': ['run-ptycho-backend = nsls2ptycho.core.ptycho.recon_ptycho_gui:main'] + 'console_scripts': ['run-ptycho-backend = nsls2ptycho.backend.ptycho.recon_ptycho_gui:main'] }, install_requires=REQUIREMENTS, #extras_require={'GPU': 'cupy'}, # this will build cupy from source, may not be the best practice!