From eb9f91027c3b088d90edf121bd3e426361cac4ab Mon Sep 17 00:00:00 2001 From: Henry Pinkard <7969470+henrypinkard@users.noreply.github.com> Date: Wed, 6 Sep 2023 17:25:13 -0700 Subject: [PATCH] run tests with latest pycromanager java source --- pycromanager/test/conftest.py | 19 ++++++++++++++----- pycromanager/test/test_viewer.py | 10 +++++----- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/pycromanager/test/conftest.py b/pycromanager/test/conftest.py index f2531bdd..9cc57187 100644 --- a/pycromanager/test/conftest.py +++ b/pycromanager/test/conftest.py @@ -7,6 +7,7 @@ import requests import re import time +import glob import pycromanager from pycromanager import start_headless @@ -17,7 +18,6 @@ def is_port_in_use(port): with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: return s.connect_ex(('localhost', port)) == 0 - def find_jar(pathname, jar_name): p = re.compile(jar_name + r"-(\d+).(\d+).(\d+).jar") @@ -82,6 +82,7 @@ def install_mm(download_mm_nightly): mm_running = False mm_install_dir = os.path.join(os.path.expanduser('~'), "Micro-Manager-nightly") + # check if there is currently a Micro-manager instance running (used for local testing) if is_port_in_use(4827): mm_running = True @@ -122,11 +123,19 @@ def install_mm(download_mm_nightly): else: raise RuntimeError('Could not find pycro-manager/java path') - # Update pycromanager jar files packaged with the Micro-manager nightly build + + # Copy the pycromanagerjava.jar file that was compiled by the github action + # into the nightly build so that it will test with the latest code + compiled_jar_path = os.path.join(java_path, 'target', 'PycromanagerJava-*.jar') + # Destination path where the jar file should be copied to + destination_path = os.path.join(mm_install_dir, 'plugins', 'Micro-Manager', 'PycromanagerJava.jar') + # Find the actual file that matches the pattern and copy it to the destination + for file_path in glob.glob(compiled_jar_path): + shutil.copy2(file_path, destination_path) + print(f'Copied {file_path} to {destination_path}') + + # Update pycromanager dependency jar files packaged with the Micro-manager nightly build # Files are updated only if they are larger version - if os.path.isdir(os.path.join(java_path, 'target')): - replace_jars(os.path.join(java_path, 'target'), os.path.join(mm_install_dir, 'plugins', 'Micro-Manager'), - ['PycroManagerJava']) # Copy dependency jar files if present in target/dependency if os.path.isdir(os.path.join(java_path, 'target/dependency')): replace_jars(os.path.join(java_path, 'target/dependency'), os.path.join(mm_install_dir, 'plugins', 'Micro-Manager'), diff --git a/pycromanager/test/test_viewer.py b/pycromanager/test/test_viewer.py index bf0e61b3..a7e6fb2d 100644 --- a/pycromanager/test/test_viewer.py +++ b/pycromanager/test/test_viewer.py @@ -1,6 +1,6 @@ import os import pytest -from pycromanager import JavaBackendAcquisition, ZMQRemoteMMCoreJ, multi_d_acquisition_events +from pycromanager import Acquisition, Core, multi_d_acquisition_events import napari # Skip tests in this module if it is running in GitHub Actions, which does not support NDViewer @@ -14,7 +14,7 @@ def test_timelapse_NDViewer(launch_mm_headless, setup_data_folder): time_interval_s=0, ) - with JavaBackendAcquisition(setup_data_folder, 'acq', show_display=True) as acq: + with Acquisition(setup_data_folder, 'acq', show_display=True) as acq: acq.acquire(events) # close viewer @@ -33,7 +33,7 @@ def test_multi_d_acq_NDViewer(launch_mm_headless, setup_data_folder): order="tcz", ) - with JavaBackendAcquisition(setup_data_folder, 'acq', show_display=True) as acq: + with Acquisition(setup_data_folder, 'acq', show_display=True) as acq: acq.acquire(events) # close viewer @@ -48,7 +48,7 @@ def test_timelapse_napari_viewer(launch_mm_headless, setup_data_folder): viewer = napari.Viewer() - acq = JavaBackendAcquisition(setup_data_folder, 'acq', napari_viewer=viewer) + acq = Acquisition(setup_data_folder, 'acq', napari_viewer=viewer) acq.acquire(events) acq.mark_finished() @@ -71,7 +71,7 @@ def test_multi_d_acq_napari_viewer(launch_mm_headless, setup_data_folder): viewer = napari.Viewer() - acq = JavaBackendAcquisition(setup_data_folder, 'acq', napari_viewer=viewer) + acq = Acquisition(setup_data_folder, 'acq', napari_viewer=viewer) acq.acquire(events) acq.mark_finished()